Contributions
Brokerages
00.json
Creating a fully supported brokerage is a challenging endeavor. LEAN requires a number of individual pieces which work together to form a complete brokerage implementation. This guide aims to describe in as much detail as possible what you need to do for each module.
The end goal is to submit a pull request that passes all tests. Partially-completed brokerage implementations are acceptable if they are merged to a branch. It's easy to fall behind master, so be sure to keep your branch updated with the master branch. Before you start, read LEAN's coding style guidelines to comply with the code commenting and design standards.
The root of the brokerage system is the algorithm job packets, which hold configuration information about how to run LEAN. The program logic is a little convoluted. It moves from config.json > create job packet > create brokerage factory matching name > set job packet brokerage data > factory creates brokerage instance. As a result, we'll start creating a brokerage at the root, the configuration and brokerage factory.
Setting Up Your Environment
Laying the Foundation
IBrokerageFactory
) Stub out the implementation and initialize a brokerage instance.
Creating the Brokerage
IBrokerage
) Instal key brokerage application logic, where possible using a brokerage SDK.
Translating Symbol Conventions
ISymbolMapper
) Translate brokerage specific tickers to LEAN format for a uniform algorithm design experience.
Describing Brokerage Limitations
IBrokerageModel
) Describe brokerage support of orders and set transaction models.
Enabling Live Data Streaming
IDataQueueHandler
) Set up a live streaming data service from a brokerage-supplied source.
Enabling Historical Data
IHistoryProvider
) Tap into the brokerage historical data API to serve history for live algorithms.
Downloading Data
IDataDownloader
) Save data from the brokerage to disk in LEAN format.
Modeling Fee Structures
IFeeModel
) Enable accurate backtesting with specific fee structures of the brokerage.
Updating the Algorithm API
ISecurityTransactionModel
) Combine the various models together to form a brokerage set.