A specialized AI trading assistant built on the ElizaOS platform that analyzes market sentiment and generates trade plans. Now with Discord integration for real-time channel monitoring!
- Sentiment Analysis: Analyzes Discord messages for crypto trading sentiment
- Trade Planning: Generates trade plans based on sentiment analysis
- Batch Analysis: Processes multiple messages for comprehensive market analysis
- Discord Integration: Real-time message processing from Discord channels
- On-Chain Trading: Execute trades, check balances, and transfer assets (mock implementation)
- Twitter Analysis: Fetch and analyze tweets for sentiment and alpha signals
- Alpha Detection: Identify high-confidence trading signals from social media
- Multi-API Support: Uses Gemini API with OpenAI fallback for sentiment analysis
-
Install Dependencies
npm install
-
Configure Environment
cp env.example .env # Edit .env with your API keys
-
Run Tests
# Test Discord integration npm run test # Test trading functionality npm run test:trading # Test trading actions npm run test:actions # Test Twitter sentiment analysis npm run test:twitter
-
Start the Bot
npm run dev
- Install dependencies:
npm install
- Set up your environment variables:
# Copy the example environment file
cp env.example .env
# Add your API keys
GEMINI_API_KEY=your_gemini_api_key_here
DISCORD_APPLICATION_ID=your_discord_application_id
DISCORD_API_TOKEN=your_discord_bot_token
# Optional: OpenAI API (fallback if Gemini fails)
OPENAI_API_KEY=your_openai_api_key_here
- Go to Discord Developer Portal
- Click "New Application"
- Give it a name (e.g., "TradeBot")
- Go to the "Bot" section
- Click "Add Bot"
- Copy the bot token (you'll need this for
DISCORD_API_TOKEN
) - Copy the Application ID (you'll need this for
DISCORD_APPLICATION_ID
)
In the Discord Developer Portal:
- Go to "OAuth2" β "URL Generator"
- Select scopes:
bot
,applications.commands
- Select bot permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Read Message History
- Copy the generated URL and use it to invite the bot to your server
npm run test:discord
This will verify your Discord configuration and test message processing.
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the API key and add it to your
.env
file asGEMINI_API_KEY
Note: Gemini API has a generous free tier (15 requests per minute, 1500 requests per day), making it perfect for development and testing.
- Go to OpenAI Platform
- Sign in and create a new API key
- Add it to your
.env
file asOPENAI_API_KEY
Note: The bot will automatically fall back to OpenAI if Gemini fails or hits rate limits.
npm start
This starts the full ElizaOS bot with Discord integration enabled. The bot will:
- Connect to Discord and monitor channels
- Analyze crypto-related messages for sentiment
- Generate trading signals and respond with formatted messages
- Provide real-time market analysis
npm run start:simple
This bypasses the complex ElizaOS initialization and provides a fast, interactive trading bot for console use.
Bot responds:
**Trading Signal Detected!**
Action: BUY
Pair: ETH/USDC
Amount: 0.1 ETH
Target: 3000 USD
Sentiment Score: 0.85
Remember: This is analysis only, not financial advice.
Bot responds:
**Trading Signal Detected!**
Action: SELL
Pair: BTC/USDC
Amount: 0.01 BTC
Target: 3500 USD
Sentiment Score: -0.72
Remember: This is analysis only, not financial advice.
The bot currently analyzes sentiment for:
- ETH (Ethereum)
- USDC (USD Coin)
- SOL (Solana)
- BTC (Bitcoin)
The bot includes on-chain trading capabilities inspired by the Coinbase CDP kit:
- Trade Execution: Execute trades based on sentiment analysis
- Balance Checking: Check wallet balances for various assets
- Asset Transfer: Transfer assets to other addresses
- Automated Trading: Trigger trades from Discord commands
See TRADING_ACTIONS.md for detailed documentation.
User: Check my ETH balance
Bot: **Balance Check**
**Asset:** ETH
**Balance:** 1.234567 ETH
User: execute trade
Bot: **Trade Executed Successfully!**
**Action:** BUY
**Pair:** ETH/USDC
**Amount:** 0.1 ETH
**Transaction Hash:** 0x1234...
User: Transfer 0.1 ETH to 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
Bot: **Transfer Successful!**
**Asset:** ETH
**Amount:** 0.1
**Transaction Hash:** 0x1234...
The bot can be customized by modifying:
src/character.ts
: Bot personality, Discord settings, and client configurationsrc/plugins/trade-planner.ts
: Trading logic, sentiment analysis, and response formattingsrc/clients/index.ts
: Client initialization and Discord integration
To restrict the bot to specific channels:
- Create a role for the bot in your Discord server
- Give the role permissions only to specific channels
- Assign the role to the bot
- New Tokens: Add to
supportedTokens
array in the plugin - New Actions: Create new action handlers in the plugin
- Enhanced Analysis: Extend the sentiment analysis logic
- Discord Commands: Add slash commands for additional functionality
# Test Discord integration
npm run test:discord
# Build the project
npm run build
# Start the simplified bot
npm run start:simple
# Start the full ElizaOS bot with Discord
npm start
-
"Missing required environment variables"
- Make sure you have a
.env
file with all required API keys - Check
DISCORD_SETUP.md
for detailed setup instructions
- Make sure you have a
-
Bot not responding in Discord
- Check that the bot token is correct
- Verify the bot has proper permissions
- Ensure the bot is online in Discord
- Test with
npm run test:discord
-
"Bot stuck on initialization"
- Use the simplified version:
npm run start:simple
- This bypasses complex ElizaOS initialization
- Use the simplified version:
-
API Rate Limits
- Gemini API has generous limits (15 req/min, 1500 req/day)
- If you hit Gemini limits, the bot will fall back to OpenAI
- OpenAI has rate limits based on your plan
-
Bot not joining channels
- Check bot permissions in Discord
- Verify the bot was invited with proper scopes
- Ensure the bot role has channel access
-
No trading signals in Discord
- Make sure messages contain crypto-related content
- Check that the sentiment score threshold is met (0.5)
- Verify API keys are working
- Never share your bot tokens publicly
- Use environment variables for all sensitive data
- The bot only analyzes messages, it doesn't execute trades
- All responses include disclaimers about financial advice
- Discord bot tokens should be kept secure
This trading bot is for educational and research purposes. Always do your own research and consider the risks involved in cryptocurrency trading. The bot's recommendations should not be considered as financial advice.
This project is licensed under the same terms as the ElizaOS platform.
The bot can fetch and analyze tweets for cryptocurrency sentiment and alpha signal detection:
- Tweet Fetching: Retrieves recent tweets for specific cryptocurrencies
- Sentiment Analysis: Analyzes tweet sentiment using AI (bullish/bearish/neutral)
- Alpha Detection: Identifies high-confidence trading signals from social media
- Risk Assessment: Evaluates risk levels and potential impact of signals
- Engagement Scoring: Considers retweets, likes, and replies for signal strength
User: Fetch tweets for ETH
Bot: **Twitter Sentiment Analysis for ETH**
**Tweets Analyzed:** 10
**Overall Sentiment:** Bullish
**Alpha Signals:** 3 high-confidence signals detected
**Top Keywords:** adoption, institutional, momentum
User: Find alpha signals for BTC
Bot: **Alpha Signal Analysis for BTC**
**High-Confidence Alphas:** 5 signals
**Average Alpha Score:** 8.2
**Risk Distribution:** Low: 3, Medium: 2, High: 0
**Top Signals:** institutional, adoption, momentum