18 Commits

Author SHA1 Message Date
JosueNina 52a55b504e Dynamic transaction thread pool (#9536)
Syntax Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add dynamic transaction thread pool that grows on demand

* Simplify dynamic worker pool

* Move dynamic thread pool into transaction handler

* Grow transaction threads on demand with order pinning

* Extract order request processing into a dedicated pool

* Move request routing and release into the processing pool

* Address review comments

* Simplify processing pool shutdown and queue lookup

* Fix combo re-routing when a simple order shares its group id

* Process order requests off a single shared worker queue

* Address review comments

* Log when the transaction pool grows a new thread

* Add test for processing many orders quickly

* Fix synchronous processing snapshot

* Address review comments

* Shutdown drain fix. TryExpand start thread without lock. Restore FIFO for non-concurrent live brokerages

---------

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2026-07-06 11:22:41 -03:00
Jhonathan Abreu ee7be1a233 Enable concurrency for live paper brokerage (#8972)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
* Enable concurrency for paper brokerage.

Implement PaperBrokerageTransactionHandler to handle concurrency for live paper trading transaction handler

* Remove PaperTradingBrokerageTransaction handler

Favor existing BacktestingTransactionHandler

* Minor fixes and cleanup

* Minor unit tests fix
2025-09-15 09:25:49 -04:00
Jhonathan Abreu d82d70dacf Support asynchronous non-market orders (#8946)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add 'asynchronous' parameter to trading api

* Add regression algorithms

* More fixes for asynchronous orders

* Fix failing unit tests

* Fix failing unit tests

* Add multiple orders requests in transaction handler

Make each transaction thread handle requests corresponding to the same order

* Refactor order state machine in BrokerageTransactionHandler

Now using a single dictionary to hold orders and their state, either pending for submission, open or closed.

* Revert: remove complete orders from new state machine in BTH

* Add order ticket to new BTH open orders state machine

* Run syn in Backtesting transaction handler for new orders submission

* Remove OpenOrderState.SubmissionPending property

* Add Security to OpenOrderState

* Minor fix

* Cleanup

* Some cleanup in BTH

* Cleanup

* Minor fix

* Minor unit test fix

* Minor fix

* Make Brokerage.ConcurrencyEnable property virtual

* Minor change

* Cleanup

* Add 'asynchronous' parameter to SetHoldings api

* Improve regression algorithms
2025-09-10 08:29:50 -04:00
Martin-Molinero 227ade63ed Refactor automatic option assignment (#7165)
Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
- Refactor automatic option assignment to allow overriding behavior.
  Adding & updating existing tests
2023-04-04 17:40:31 -03:00
Colton Sellers 33599b473d Refactor Delistings Processing (#6059)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* Move processing of delistings to Brokerage

* Deal with case that exchange is not open on OptionSymbol.ID.Date

* Refactor solution to use DelistingNotification event

* Adjust some regression expected liquidation time

* Mark some todos on deprecated functions

* Update expected liqudation time for Py regressions

* Update regressions that have been validated

* Use HandlePositionAssigned for assignment orders

* Update regressions

* Update some missed unit tests; remove one that is already covered by regression

* Cleanup deprecated backend functions

* nit - small cleanup adjustment

* Post rebase fix

* Address review

* Minor tweak to py regression
2021-11-17 17:43:35 -03:00
Stefano Raggi 29294cb1f4 Transaction handlers - minor updates (#5956)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
- Move debug logging of order events from Brokerage to BrokerageTransactionHandler
- Override CurrentTimeUtc in BacktestingTransactionHandler
2021-10-01 19:09:08 -03:00
Colton Sellers e2a0873b7c Fix Lean Warnings V1 (#5408)
Cleanup all non-breaking warnings
2021-03-22 11:08:48 -07:00
Martin Molinero 7f12cbb901 Addressing reviews 2019-05-15 18:56:08 -03:00
Martin Molinero f976ffa099 Removing BacktestingTransactionHandler thread
- For backtesting the algorithm thread will sequentially process pending
order requests
   - Adding new non blocking `BusyCollection`
- Updating `UpdateOrderRegressionAlgorithm` that suffered of a race
condition: it supposed `OnOrderEvent` would be called after the call to
`Transactions.AddOrder()` was finished
2019-05-10 16:15:24 -03:00
quant1729 2dce74e26d - Extended Option security and Option holding classes
- Updated IB fee model to support option exercise
- Added support for splits for options. Not tested on real data yet.
- Added option exercise functionality for long positions. Unit Tests. Not tested on real data yet.
- Added option assignment functionality for short positions. Assignment event. Unit Tests.
- Added basic option assignment simulator for backtesting brokerage. Simulates assignments for deep ITM short positions close to expiration. Unit Tests.
2016-08-31 18:00:00 +02:00
snugs 4de2ec4070 Make Engine an instance
Updated all interfaces to accept dependencies via Initialize methods
2015-06-18 13:50:11 -04:00
snugs fd3d5b2953 Load transaction handlers via MEF configuration 2015-06-17 22:34:02 -04:00
snugs 72a5fabc9a Brokerage cash sync every morning
Adds ProcessAsynchronousEvents in BrokerageTransactionHandler
2015-05-21 16:36:58 -04:00
Jared Broad d4c8c10f02 Rework to move synchronous events into transaction hander and result handler plugins so the events could be controlled on a plugin level. e.g. This allowed removing 1 thread context switch from primary algo loop and enabling live trading result handler to trigger its own updates every second independent of algorithm event timing 2015-02-06 12:50:55 -03:00
snugs 191b82c2cb Consolidates transaction handlers to use the IBrokerage interface
This is a fairly large change. We now have a BacktestingBrokerage (and PaperTradingBrokerage) which is consumed by the transaction handlers. We've also tested the BrokerageTransactionHandler. The IBrokerage interface has been through through and implemented. We've also added a spacial BacktestingTransactionHandler to delegate order filling to the BacktestingBrokerage implementation via the BacktestingBrokerage.Scan method.  Much of this is a code shuffle to bring live trading and backtesting transaction handling into a similar pattern.
2015-01-25 17:12:10 -03:00
snugs 57f272cf80 Creates new IBrokerage interface with new BrokerageTransactionHandler
IBBrokerage now implements new IBrokerage interface
Adds IBBrokerage tests
Created IBGatewayRunner to manage the IB gateway/TWS start/stop
Cleaned up ITransactionHandler interface, removed some duplication
2015-01-24 17:50:14 -03:00
snugs a289fe6b1c Renamed the Paper brokerage to PaperBrokerage 2015-01-23 18:27:06 -03:00
Jared Broad b3de520915 Initial commit 2015-01-12 12:03:33 -03:00