Automated trading system that combines social sentiment and technical analysis to identify and trade trending stocks.
- Stock appears in top 10 by combined ranking:
- Get sentiment ranks (1-20) from both sources:
- ApeWisdom: Ranked by mentions and sentiment
- Stocktwits: Ranked by bullish ratio * log(mentions) (requires >60% bullish)
- Take best rank between sources (or average if in both)
- Get technical rank (1-N) based on:
- Moving averages
- MACD
- RSI
- Momentum
- Final rank = sentiment_rank + technical_rank
- Lower is better (e.g. rank 1 sentiment + rank 1 technicals = best score of 2)
- Get sentiment ranks (1-20) from both sources:
- Technical score > 40%
- Not already in portfolio
- Places 8% position size order
Exits position if any 2 of these signals occur:
- Price below both moving averages
- Strong bearish MACD
-
5% loss in 24h
Also exits if:
- Falls out of top 10 AND technical score < 40%
- 8% position size per stock
- Maximum 10 positions (80% total exposure)
- Monitors every 5 minutes for:
- Exit signals
- New opportunities
- Technical score changes
-
Install TA-Lib (required for technical analysis):
- On Ubuntu/Debian:
sudo apt-get install ta-lib
- On macOS:
brew install ta-lib
-
Install Python dependencies:
pip install -r requirements.txt
-
Create an Alpaca paper trading account:
- Sign up at https://app.alpaca.markets/signup
- Go to Paper Trading section
- Get your API key and secret
-
Create .env file with your Alpaca credentials:
ALPACA_API_KEY=your_key_here
ALPACA_SECRET_KEY=your_secret_here
Note: The system uses paper trading by default for safety. Make sure you're using paper trading API keys, not live trading keys.
Run the trading loop:
python run_trader.py
This will:
- Check existing positions every 5 minutes
- Exit positions that trigger signals
- Enter new positions from top 10 list
- Queue orders for market open if after hours
social_scanner.py
: Gets and ranks stocks from:- ApeWisdom (Reddit sentiment)
- Stocktwits (watchers + sentiment)
technical_analysis.py
: Technical indicatorsposition_manager.py
: Order execution and position trackingtrader.py
: Main trading logicrun_trader.py
: Trading loop with 5-minute cycle
This is experimental software for educational purposes. Use paper trading to test strategies before considering real money. The system implements basic risk management through position sizing and technical exit signals, but you should adjust parameters based on your risk tolerance.