How silasspencer1/lean works
LEAN is an event-driven algorithmic trading engine for backtesting and live trading. The principal workflow is to load and initialize a user algorithm, provide market data, let it make trading decisions, process orders through a brokerage, and report results. Its modular handlers support different execution modes and pluggable integrations. The graph combines explicit initialization and transaction-handler evidence with the README’s product description; several runtime subsystems are represented at their enclosing directory because their implementation was not sampled.
Main entry points: Engine.cs Engine coordinator · BasicTemplateAlgorithm.cs Trading algorithm · BrokerageTransactionHandler.cs Order processing · Brokerages Brokerage
Components 15
Engine execution
- Trading algorithm
Algorithm.CSharp/BasicTemplateAlgorithm.cs - Engine coordinator
Engine/Engine.cs - Algorithm setup
Engine/Setup/BrokerageSetupHandler.cs - Pluggable handlers
Engine/LeanEngineAlgorithmHandlers.cs - Event synchronizer
Engine - Results reporting
Engine
Market data
- Data feed
Engine - Market data
- Universe selection
Algorithm.CSharp
Trading state
- Portfolio state
Common/Securities/SecurityPortfolioManager.cs - Order processing
Engine/TransactionHandlers/BrokerageTransactionHandler.cs
Brokerage integration
- Brokerage
Brokerages - Brokerage messages
Common/Brokerages/DefaultBrokerageMessageHandler.cs - WebSocket subscriptions
Brokerages/BrokerageMultiWebSocketSubscriptionManager.cs
Other components
- Algorithm author
Connections 18
- Algorithm author → Trading algorithm: defines strategy
- Engine coordinator → Pluggable handlers: uses handlers
- Engine coordinator → Algorithm setup: invokes setup
- Algorithm setup → Trading algorithm: creates algorithm
- Engine coordinator → Data feed: initializes feed
- Engine coordinator → Event synchronizer: initializes sync
- Engine coordinator → Order processing: initializes orders
- Engine coordinator → Results reporting: sets algorithm
- Market data → Data feed: supplies data
- Data feed → Trading algorithm: streams events
- Trading algorithm → Universe selection: selects assets
- Trading algorithm → Order processing: submits orders
- Order processing → Brokerage: sends orders
- Brokerage → Order processing: reports events
- Order processing → Portfolio state: updates holdings
- Results reporting → Algorithm author: reports outcomes
- Brokerage → Brokerage messages: emits messages
- Brokerage → WebSocket subscriptions: streams quotes