I built this trading bot to see if I could use AI (specifically DeepSeek LLM) to make trading decisions in the crypto market. Spoiler alert: it didn't work, but I learned a ton ๐
Don't use this with real money ๐ธโ I tested three different strategies and they all lost money. This is a learning project, not a get-rich-quick scheme. The crypto market is way more complex than I initially thought.
I wanted to experiment with combining AI language models and algorithmic trading. The idea was simple: fetch BTC price data from Bybit, ask DeepSeek to analyze it, and make buy/sell decisions based on its recommendations. Then backtest everything on historical data to see if it would've worked ๐
- How to work with exchange APIs (Bybit in this case) ๐
- Using LLMs for financial analysis (harder than it sounds) ๐ง
- Building and running backtests ๐
- Working with financial data in Python ๐
- Why most simple trading bots fail ๐
- Python 3.x ๐
- Bybit API for market data ๐
- DeepSeek API for the AI part ๐ค
- Pandas for data wrangling ๐ผ
- Basic HTTP requests ๐
fetch_data.py โ Grabs BTC price history from Bybit ๐ฐ
deepseek_signal.py โ Asks DeepSeek for trading signals ๐ฏ
backtest.py โ Tests the basic momentum strategy ๐
backtest_hybrid.py โ Tests technical indicators + AI combo ๐ง
test_signal.py โ Quick tests to see what signals we get โก
btc_data.csv โ The historical data (auto-generated) ๐
pip install requests pandas- You don't need Bybit API keys for fetching data (public endpoint) โ
- Get a DeepSeek API key from platform.deepseek.com ๐
- Drop your API key into the scripts where it says:
DEEPSEEK_API_KEY = "your-api-key-here"
Fetch data:
python fetch_data.pyTest if signals are working:
python test_signal.pyRun the full backtest:
python backtest_hybrid.pyThe idea: If price goes up more than 2.5% in 24 hours, buy. If it drops more than 2.5%, sell.
Result: Lost 1.15% over 1000 hours ๐ Made literally 1 trade.
The idea: Give DeepSeek all the price data and let it figure out patterns.
Result: Lost 0.65% ๐ Still only 1 trade. AI was way too cautious.
The idea: Use actual technical indicators (RSI, moving averages, volume) and have DeepSeek confirm the signals.
Result: Lost 3.95% ๐ Worst performance yet. 0% win rate.
-
DeepSeek was too conservative ๐ - It basically said "HOLD" for everything. Even when I gave it clear rules, it barely pulled the trigger.
-
Crypto is chaotic ๐ช๏ธ - BTC dropped 3% over the test period and the bot just couldn't adapt fast enough.
-
My prompts weren't good enough ๐ - Getting an LLM to consistently make good trading decisions is really hard.
-
Not enough trades โธ๏ธ - 1-2 trades over 1000 hours means the strategy is way too picky.
Real trading bots that actually make money need:
- Way more sophisticated algorithms ๐งฎ
- High-frequency trading capabilities โก
- Proper risk management ๐ก๏ธ
- Years of development and testing โณ
- A lot more computing power than my laptop ๐ป
LLMs are probably better for:
- Analyzing news sentiment ๐ฐ
- Summarizing market reports ๐
- Supporting decisions, not making them ๐ค
And the biggest lesson: always backtest before risking real money ๐ฏ Even then, past performance doesn't mean future success.
Some ideas I didn't try:
- Copy trading ๐ฅ - Just follow people who actually know what they're doing
- Grid bots ๐ฏ - Buy low, sell high in a price range (works in sideways markets)
- DCA bots ๐ฐ - Invest small amounts regularly over time
- Sentiment analysis ๐ - Use AI to read crypto Twitter instead of predicting prices
- Multiple LLMs voting ๐ณ๏ธ - Get several AI opinions and average them out
Feel free to fork it and experiment ๐ด Just remember this didn't make money, so don't expect miracles. It's a learning project, not a money printer ๐จ๏ธโ
MIT - Do whatever you want with this code โ
- Bybit for free API access ๐
- DeepSeek for the LLM API ๐ค
- Everyone who told me this wouldn't work (you were right) ๐
Bottom line: I set out to build a trading bot and ended up learning why that's really hard ๐ The code works, the backtesting works, but the strategy doesn't. That's still valuable experience though - now I know what doesn't work and why ๐ก