Skip to content

Floris/TradingBot

Repository files navigation

TradingBot (WIP)

This trading bot is a versatile and powerful tool that can help users automate their trading strategies, perform backtesting, and generate trading signals for various use cases, such as receiving notifications on platforms like Telegram. The bot's architecture is designed to manage trading signals, execute strategies, manage positions, and interact with crypto exchanges to execute trades. The core components of the trading bot are as follows:

Core Components

Signal Processor

The SignalProcessor is responsible for managing and processing trading signals generated by the SignalEngine. It interacts with the MarketDataProtocol to obtain market data. It uses the PositionManager to manage positions based on the signals generated. This component ensures that the trading bot can seamlessly integrate signals and execute trades based on those signals or send them as notifications to the user.

Signal Engine

The SignalEngine is at the heart of the trading bot, responsible for managing and executing trading strategies. It accepts a list of strategies (objects implementing the StrategyProtocol interface) and a configuration object (an instance of MainConfig class). The engine processes market data and generates trading signals based on the implemented strategies. Users can create custom strategies by implementing the StrategyProtocol interface.

Position Manager

The PositionManager is responsible for managing active positions, executing trades, and tracking the overall trading performance. It uses a TradeExecutor object to execute trades and manages active positions in a defaultdict. This component is essential in keeping track of open positions, handling buy and sell signals, and calculating the trading bot's performance metrics.

Trade Executor

The TradeExecutor class is responsible for submitting orders to a crypto exchange. It uses a CryptoExchangeProtocol object to interact with the exchange. This component ensures that the trading bot can place orders, such as buy and sell, on the desired crypto exchange. Users can utilize different exchanges by implementing the CryptoExchangeProtocol interface.

How It Works

The trading bot works by continuously processing market data through the SignalProcessor and SignalEngine. The SignalEngine analyzes the market data and generates trading signals based on the user-defined strategies. These signals are then passed to the PositionManager, which handles the signals and manages the active positions accordingly.

The PositionManager uses the TradeExecutor to submit orders to the crypto exchange based on the received signals. The TradeExecutor interacts with the CryptoExchangeProtocol to place orders on the desired exchange. The PositionManager keeps track of open positions, calculates the trading bot's performance metrics, and handles position closing when necessary.

With this architecture, users can easily implement custom trading strategies and manage their positions while interacting with various crypto exchanges. The trading bot offers a powerful and flexible solution for automating trading activities and maximizing profits in the world of cryptocurrencies.

Configuring Env

Create a new .env file.

BINANCE_API_KEY=
BINANCE_SECRET=


SYMBOL=BTCUSDT
INTERVAL=2h
LIMIT=1000
STARTING_BALANCE=10000
NOTIONAL=2000
MAX_OPEN_POSITIONS=4
BACKTEST=True
POLLING_INTERVAL_WEIGHT=1
START_DATE=2020-01-01  <--- OPTIONAL
END_DATE=2020-01-01  <--- OPTIONAL


CRYPTO_EXCHANGE=BinanceExchange  <--- OPTIONAL
MARKET_DATA_PROVIDER=BinanceMarketData
STRATEGIES=strategies.example_macd_strategy.MACDStrategy,strategies.example_rsi_strategy.SimpleRsiStrategy <--- Add your strategies here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages