Lean
$LEAN_TAG$
|
This transaction handler is used for processing transactions during backtests More...
Public Member Functions | |
override void | Initialize (IAlgorithm algorithm, IBrokerage brokerage, IResultHandler resultHandler) |
Creates a new BacktestingTransactionHandler using the BacktestingBrokerage More... | |
override void | ProcessSynchronousEvents () |
Processes all synchronous events that must take place before the next time loop for the algorithm More... | |
override void | ProcessAsynchronousEvents () |
Processes asynchronous events on the transaction handler's thread More... | |
Public Member Functions inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
OrderTicket | Process (OrderRequest request) |
Adds the specified order to be processed More... | |
OrderTicket | AddOrder (SubmitOrderRequest request) |
Add an order to collection and return the unique order id or negative if an error. More... | |
OrderTicket | UpdateOrder (UpdateOrderRequest request) |
Update an order yet to be filled such as stop or limit orders. More... | |
OrderTicket | CancelOrder (CancelOrderRequest request) |
Remove this order from outstanding queue: user is requesting a cancel. More... | |
IEnumerable< OrderTicket > | GetOrderTickets (Func< OrderTicket, bool > filter=null) |
Gets and enumerable of OrderTicket matching the specified filter More... | |
IEnumerable< OrderTicket > | GetOpenOrderTickets (Func< OrderTicket, bool > filter=null) |
Gets and enumerable of opened OrderTicket matching the specified filter More... | |
OrderTicket | GetOrderTicket (int orderId) |
Gets the order ticket for the specified order id. Returns null if not found More... | |
Order | GetOrderById (int orderId) |
Get the order by its id More... | |
List< Order > | GetOrdersByBrokerageId (string brokerageId) |
Gets the order by its brokerage id More... | |
IEnumerable< Order > | GetOrders (Func< Order, bool > filter=null) |
Gets all orders matching the specified filter. Specifying null will return an enumerable of all orders. More... | |
List< Order > | GetOpenOrders (Func< Order, bool > filter=null) |
Gets open orders matching the specified filter More... | |
void | AddOpenOrder (Order order, IAlgorithm algorithm) |
Register an already open Order More... | |
void | Exit () |
Signal a end of thread request to stop monitoring the transactions. More... | |
void | HandleOrderRequest (OrderRequest request) |
Handles a generic order request More... | |
decimal | RoundOffOrder (Order order, Security security) |
Rounds off the order towards 0 to the nearest multiple of Lot Size More... | |
Protected Member Functions | |
override void | WaitForOrderSubmission (OrderTicket ticket) |
For backtesting we will submit the order ourselves More... | |
override void | InitializeTransactionThread () |
For backtesting order requests will be processed by the algorithm thread sequentially at WaitForOrderSubmission and ProcessSynchronousEvents More... | |
Protected Member Functions inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
void | Run () |
Primary thread entry point to launch the transaction thread. More... | |
void | RoundOrderPrices (Order order, Security security) |
Rounds the order prices to its security minimum price variation. More... | |
void | RoundOrderPrices (Order order, Security security, bool comboIsReady, Dictionary< Order, Security > orders) |
Rounds the order prices to its security minimum price variation. More... | |
Protected Attributes | |
override DateTime | CurrentTimeUtc => _algorithm.UtcTime |
Gets current time UTC. This is here to facilitate testing More... | |
Protected Attributes inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
virtual TimeSpan | TimeSinceLastFill |
Gets the amount of time since the last call to algorithm.Portfolio.ProcessFill(fill) More... | |
virtual DateTime | CurrentTimeUtc => DateTime.UtcNow |
Gets current time UTC. This is here to facilitate testing More... | |
Additional Inherited Members | |
Public Attributes inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
IEnumerable< OrderEvent > | OrderEvents => _orderEvents |
Gets all order events More... | |
int | OrdersCount => _totalOrderCount |
Gets the current number of orders that have been processed More... | |
Properties inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
IBusyCollection< OrderRequest > | _orderRequestQueue [get, set] |
OrderQueue holds the newly updated orders from the user algorithm waiting to be processed. Once orders are processed they are moved into the Orders queue awaiting the brokerage response. More... | |
CancelPendingOrders | _cancelPendingOrders = new CancelPendingOrders() [get] |
The _cancelPendingOrders instance will help to keep track of CancelPending orders and their Status More... | |
ConcurrentDictionary< int, Order > | Orders [get] |
Gets the permanent storage for all orders More... | |
ConcurrentDictionary< int, OrderTicket > | OrderTickets [get] |
Gets the permanent storage for all order tickets More... | |
bool | IsActive [get] |
Boolean flag indicating the Run thread method is busy. False indicates it is completely finished processing and ready to be terminated. More... | |
Properties inherited from QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler | |
bool | IsActive [get] |
Boolean flag indicating the thread is busy. False indicates it is completely finished processing and ready to be terminated. More... | |
ConcurrentDictionary< int, Order > | Orders [get] |
Gets the permanent storage for all orders More... | |
IEnumerable< OrderEvent > | OrderEvents [get] |
Gets all order events More... | |
ConcurrentDictionary< int, OrderTicket > | OrderTickets [get] |
Gets the permanent storage for all order tickets More... | |
Properties inherited from QuantConnect.Securities.IOrderProvider | |
int | OrdersCount [get] |
Gets the current number of orders that have been processed More... | |
Events inherited from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler | |
EventHandler< OrderEvent > | NewOrderEvent |
Event fired when there is a new OrderEvent More... | |
Events inherited from QuantConnect.Securities.IOrderEventProvider | |
EventHandler< OrderEvent > | NewOrderEvent |
Event fired when there is a new OrderEvent More... | |
This transaction handler is used for processing transactions during backtests
Definition at line 30 of file BacktestingTransactionHandler.cs.
|
virtual |
Creates a new BacktestingTransactionHandler using the BacktestingBrokerage
algorithm | The algorithm instance |
brokerage | The BacktestingBrokerage |
resultHandler |
Reimplemented from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler.
Definition at line 48 of file BacktestingTransactionHandler.cs.
|
virtual |
Processes all synchronous events that must take place before the next time loop for the algorithm
Reimplemented from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler.
Definition at line 67 of file BacktestingTransactionHandler.cs.
|
virtual |
Processes asynchronous events on the transaction handler's thread
Reimplemented from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler.
Definition at line 87 of file BacktestingTransactionHandler.cs.
|
protectedvirtual |
For backtesting we will submit the order ourselves
ticket | The OrderTicket expecting to be submitted |
Reimplemented from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler.
Definition at line 98 of file BacktestingTransactionHandler.cs.
|
protectedvirtual |
For backtesting order requests will be processed by the algorithm thread sequentially at WaitForOrderSubmission and ProcessSynchronousEvents
Reimplemented from QuantConnect.Lean.Engine.TransactionHandlers.BrokerageTransactionHandler.
Definition at line 117 of file BacktestingTransactionHandler.cs.
|
protected |
Gets current time UTC. This is here to facilitate testing
Definition at line 40 of file BacktestingTransactionHandler.cs.