A comprehensive multi-broker trading automation system with integrated news and social media intelligence.
- Multi-Broker Support: Connect to multiple brokers (Alpaca, TD Ameritrade, Interactive Brokers)
- News & Social Intelligence: Automated collection from news APIs, Twitter, Reddit, and financial blogs
- Sentiment Analysis: Real-time sentiment analysis of news and social media posts
- Risk Management: Built-in risk controls with position sizing, stop losses, and daily limits
- Strategy Framework: Extensible strategy system with built-in news-based trading
- Real-time Notifications: Discord/Slack webhooks, email, and console alerts
- Configuration Management: Flexible JSON-based configuration with environment variable support
- Node.js 18+
- Valid broker API credentials (Alpaca recommended for getting started)
- Optional: News API key, Twitter Bearer Token for enhanced data collection
-
Clone and install dependencies:
git clone <repository-url> cd trading npm install
-
Set up environment variables:
cp .env.example .env # Edit .env with your API credentials -
Configure your settings:
# The application will create a default config.json on first run # You can also manually configure brokers, watchlist, and strategies
Alpaca (Recommended for beginners):
- Sign up at Alpaca Markets
- Get your API key and secret from the dashboard
- Set
ALPACA_API_KEYandALPACA_SECRET_KEYin your .env file - Use paper trading URL for testing:
https://paper-api.alpaca.markets
TD Ameritrade:
- Apply for API access at TD Ameritrade Developer
- Set
TD_AMERITRADE_CLIENT_IDand refresh token
News API:
- Get free API key from NewsAPI.org
- Set
NEWS_API_KEYin your .env file
Twitter API:
- Apply for Twitter API v2 access
- Set
TWITTER_BEARER_TOKENin your .env file
# Start the trading application
npm start
# Check application status
node src/index.js status
# Development mode with auto-restart
npm run dev{
"dataCollection": {
"watchlist": ["AAPL", "GOOGL", "MSFT", "TSLA"],
"keywords": ["earnings", "FDA approval", "merger"],
"interval": 300000
},
"riskManagement": {
"maxPositionSize": 1000,
"maxDailyLoss": 500,
"stopLossPercentage": 0.02
},
"trading": {
"strategies": {
"newsBasedTrading": {
"enabled": true,
"sentimentThreshold": 0.6,
"buzzThreshold": 50
}
}
}
}The included news-based strategy:
- Monitors news sentiment and social media buzz
- Buys on strong positive sentiment + high buzz volume
- Implements automatic stop-losses and take-profits
- Configurable holding periods and position sizes
Create custom strategies by extending BaseStrategy:
import BaseStrategy from '../strategy-base.js';
class MyStrategy extends BaseStrategy {
constructor(config) {
super('MyStrategy', config);
}
async evaluate(marketData) {
// Your trading logic here
return signals; // Array of trading signals
}
}Set up notifications via:
- Discord/Slack Webhooks: Real-time trading alerts
- Console: Development and debugging
- Email: High-priority alerts (requires setup)
Configure notification filters by priority, symbol, or event type.
Built-in safety features:
- Position Limits: Maximum position sizes per symbol
- Daily Loss Limits: Stop trading after daily loss threshold
- Portfolio Risk: Limit exposure as percentage of portfolio
- Symbol Blacklisting: Exclude problematic symbols
- Order Validation: Pre-trade risk checks
Paper Trading Recommended:
- Always test strategies with paper trading first
- Use Alpaca's paper trading environment
- Monitor performance before using real money
Backtesting:
- Historical data integration planned
- Strategy performance metrics included
src/
├── brokers/ # Broker integrations
├── data-collection/ # News & social media collectors
├── trading/ # Trading engine and strategies
├── config/ # Configuration management
├── notifications/ # Alert system
└── index.js # Main application entry point
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
IMPORTANT: This software is for educational and research purposes.
- Trading involves substantial risk of loss
- Past performance does not guarantee future results
- Test thoroughly with paper trading before using real money
- Comply with all applicable laws and regulations
- The authors assume no responsibility for trading losses
Common Issues:
- Broker Connection Failed: Check API credentials and network connectivity
- Data Collection Errors: Verify API keys and rate limits
- Strategy Not Executing: Check if trading is enabled and strategies are configured
- High CPU Usage: Reduce data collection frequency or disable unused features
Support:
- Check the logs in
logs/trading.log - Review your configuration with
node src/index.js status - Ensure all required environment variables are set
Happy Trading! 📈