-
-
Notifications
You must be signed in to change notification settings - Fork 19
Home
Key Features • How To Use • Architecture • License
The goal for LoopTrader is to provide a flexible engine for running one or more option trading strategies in real-time against provided broker APIs. The Key Features include:
- Simple to set up and run multiple trading bots
- Extensibility for various brokers, trading strategies, and logging patterns
- Local storage for trades and orders
- Support for notifications and interactions through tools like Telegram
LoopTrader is very much a work in progress and is currently not feature complete. See the Issues for what remains open or to make a suggestion.
Running LoopTrader does require some development experience. For example, configuring LoopTrader for various strategies, brokers, and enabling notifiers all take some editing of LoopTrader to work.
Documentation for this process is in the wiki
New Brokers can be added by creating a new class inheriting from Broker and Component and implementing the required abstract methods. This pattern will allow you to communicate with the Bot in a standard way and keep Brokers plug-and-play.
The Telegram notifier uses the python-telegram-bot for communicating with Telegram. For personal use, you must install the module and create a new bot through @BotFather.
The required configuration parameters should be set up in LoopTrader's .env file using the documented Environment Variables.
# Telegram Notifier Variables
TELEGRAM_TOKEN= ""
TELEGRAM_CHATID= ""
Strategies are currently configured in-code when the object is initialized. I plan to move this to YAML in a future enhancement.
Custom Strategies can be added by creating a new class inheriting from Strategy and Component and implementing the required abstract methods. This pattern will allow you to communicate with the bot in a standard way and keep strategies plug-and-play.
LoopTrader is built on top of the latest version of Python and implements two main patterns: Mediator and Strategy
The Mediator pattern allows us to maintain independent components for the Broker API, Strategy, and Local DB's. This lets the user pick and choose the components to include in their Bot.
The Strategy pattern allows us to develop multiple implementations of trading strategies for the bot to execute.
The core components of LoopTrader are outlined below. For anyone interested in extending LoopTrader to a new Broker or Strategy, take a look at main.py for setting up your Bot and the sections below for how to extend the components.
The Component abstract class is the base class for our Bot pieces; it should be on all classes that intend to be processed by the Bot.
The Mediator abstract class is represented in its concrete form as the Bot; it is the core object for coordinating the Component pieces and handling the looping of Strategies.
The Broker abstract class represents the base class for concrete Broker implementations. This includes basic information about connecting to the Broker and Abstract Methods for acting on the Broker.
The Notifier abstract class is how we can receive notifications and interact with our bot.
The Database abstract class provides the scaffolding CRUD operations for various concrete local storage implementations.
The Strategy abstract class is the base for all Strategies implemented in LoopTrader. Most of the logic within LoopTrader exists within the concrete Strategies to determine when to open and close positions. The first concrete strategy in progress is CashSecuredPuts, selected by target Delta.