Automated trading bot for stocks and ETFs based on technical indicators
Features • Installation • Configuration • Usage • Disclaimer
READ THIS BEFORE USING THE BOT
- ❌ I am NOT responsible for your money or any financial losses
- 💸 You will most likely LOSE money if you use this bot
- 🔬 This project is for RESEARCH and EDUCATIONAL purposes only
- 🚫 DO NOT use this bot if you don't understand investing and programming
- 💰 DO NOT use this bot with real money
- ⚙️ The bot is UNSTABLE, contains bugs, and requires constant supervision by an experienced developer who understands the source code
USE AT YOUR OWN RISK
InvestBot is an automated trading bot that makes buy/sell decisions based on technical analysis indicators. Currently, the bot uses MACD (Moving Average Convergence Divergence) and Moving Average indicators to determine entry and exit points.
- Annual Return: 11-13% (based on 5-year historical backtests)
- Win Rate: ~33% of trades are profitable, but they compensate for the 67% losing trades
- Broker: Currently works with Tinkoff API, but in potentially might work with any broker
- Limitations
⚠️ : Volatile instruments cause losses and high-frequency trading doesn't work because spreads and liquidity issues cause errors. Bot cannot predict spreads and doesn't understand real transaction prices.
- 🔄 Automated Trading: Automatic buy/sell execution based on indicators
- ⚖️ Portfolio Balancing: Dynamically adjusts positions based on available capital
- 📈 Performance Visualization: Generates profit/loss charts
- 📊 Price Charts: Displays stock/ETF price movements
- 📥 Historical Data: Downloads historical data for any period (e.g., 5 years)
- 🧪 Backtesting: Test strategies on extensive historical datasets
- Java 17 or higher
- Trading Tinkoff API access (token required)
-
Clone the repository:
-
Build the shadow JAR:
./gradlew :app:shadowJar- The JAR file will be located at:
app/build/libs/app-all.jar
The bot requires several environment variables to be set:
| Variable | Description |
|---|---|
BOT_PATH |
Absolute path to the directory where all historical data will be stored |
BOT_TOKEN_PROD |
Production API token |
BOT_TOKEN_SANDBOX |
Sandbox API token for testing |
BOT_WIFI_NAME |
WiFi network name (for auto-reconnect on Linux) |
BOT_WIFI_PASSWORD |
WiFi password (for auto-reconnect on Linux) |
-
Open Terminal
-
Edit your shell profile:
open -a TextEdit.app ~/.zprofile- Add the following variables:
export BOT_PATH=/absolute/path/to/data/directory
export BOT_TOKEN_PROD=your_production_token_here
export BOT_TOKEN_SANDBOX=your_sandbox_token_here
export BOT_WIFI_NAME=your_wifi_name
export BOT_WIFI_PASSWORD=your_wifi_password- Save the file and restart your Terminal/IDE
-
Open Terminal
-
Create/edit profile files (if they don't exist, create them with
touch):
nano ~/.zprofile
nano ~/.bashrc
nano /etc/environment- Add the following variables to each file:
export BOT_PATH=/absolute/path/to/data/directory
export BOT_TOKEN_PROD=your_production_token_here
export BOT_TOKEN_SANDBOX=your_sandbox_token_here
export BOT_WIFI_NAME=your_wifi_name
export BOT_WIFI_PASSWORD=your_wifi_password-
Important: Save files manually (don't just close the editor)
-
Restart your Terminal or reboot your system
The current strategy uses:
- MACD Indicator: Identifies momentum and trend direction
- Moving Averages: Determines support/resistance levels and trend confirmation
- 📉 Poor performance on highly volatile instruments
- 💱 Spread prediction is not implemented
- 🔄 High transaction costs impact profitability
- ⚡ Liquidity issues cause execution errors
This is an open-source project, and contributions are welcome! However, please note:
- This bot is experimental and not production-ready
- Always test changes in a sandbox environment
- Never test with real money
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write me by email: aymaletdinov2012@gmail.com or Telegram: t.me/raymaletdin
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, suggestions or partnership:
If you find this project interesting or useful for educational purposes, please consider giving it a star!