Skip to content

Evleaps/InvestBot

Repository files navigation

🤖 InvestBot (Experimental)

Version Kotlin Gradle License Status

Automated trading bot for stocks and ETFs based on technical indicators

FeaturesInstallationConfigurationUsageDisclaimer


⚠️ 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


📊 About

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.

Performance Metrics (Synthetic Tests)

  • 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.

✨ Features

  • 🔄 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

📦 Installation

Prerequisites

  • Java 17 or higher
  • Trading Tinkoff API access (token required)

Build JAR

  1. Clone the repository:

  2. Build the shadow JAR:

./gradlew :app:shadowJar
  1. The JAR file will be located at:
app/build/libs/app-all.jar

⚙️ Configuration

Environment Variables

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)

Setup on macOS

  1. Open Terminal

  2. Edit your shell profile:

open -a TextEdit.app ~/.zprofile
  1. 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
  1. Save the file and restart your Terminal/IDE

Setup on Linux

  1. Open Terminal

  2. Create/edit profile files (if they don't exist, create them with touch):

nano ~/.zprofile
nano ~/.bashrc
nano /etc/environment
  1. 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
  1. Important: Save files manually (don't just close the editor)

  2. Restart your Terminal or reboot your system


📈 Trading Strategy

The current strategy uses:

  • MACD Indicator: Identifies momentum and trend direction
  • Moving Averages: Determines support/resistance levels and trend confirmation

Known Issues

  • 📉 Poor performance on highly volatile instruments
  • 💱 Spread prediction is not implemented
  • 🔄 High transaction costs impact profitability
  • ⚡ Liquidity issues cause execution errors

🤝 Contributing

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

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
  6. Write me by email: aymaletdinov2012@gmail.com or Telegram: t.me/raymaletdin

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


📧 Contact

For questions, suggestions or partnership:


⭐ Star History

If you find this project interesting or useful for educational purposes, please consider giving it a star!

About

It is a console program that can automatically purchase and sell stonks without any control.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages