22 Commits

Author SHA1 Message Date
JosueNina ebaa355bf1 Fix Python inheritance issue with SelectionModels (#9069)
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
* Initial solution

* Solve review comments

* Add PythonSelectionModelHandler to reduce code duplication

* Refactor universe selection models

* Add python instance to Selection Models with virtual/override methods

* Add python instance to Alpha Models

* Add python instance to Execution models

* Solve review comments

* Solve new review comments

* Fix calling SetPythonInstance only when method exists and is callable

* Use unit test instead of regression algorithms

* Solve review comments

* Set python instance to the models

* Initialize Python containers only when instance is set

* Replace try-catch with explicit method existence check

* Initialize containers in BasePythonWrapper only when needed

* Add null instance check before method invocation

* Refactor TryExecuteMethod

* Refactor Python wrappers which inherit from BasePythonWrapper<>

* Solve review comments

* Remove ununsed methods

* Solve review comments
2025-11-13 17:21:55 -03:00
Jhonathan Abreu 546afd2a61 Async orders in execution models (#8872)
Syntax 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
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Changed default async to true and passed target.Tag

* Make execution models place orders asynchronously if specified

* Add unit tests

* Execution model default to asynchronous orders.

Also, minor fixes for tickets remaining fill quantity potential race conditions

* Add SecurityHolding.UnrealizedQuantity property

It gets the holding quantity the security will have once all open orders are filled.
Added for thread safety reasons when execution models place asynchronous orders and need to calculate the actual quantity needed to reach the target of there are open orders

* Some cleanup

* Adjust projected holdings quantity on splits

* Minor fix

* More changes and cleanup

* Minor fix

* Improvements for thread safety

* Add IOrderProvider.GetProjectedHoldings to get projected holdings atomically

* Minor unit tests fix

* Add ProjectedHoldings DTO class

* Address peer review

---------

Co-authored-by: arthiondaena <arthiondaena@gmail.com>
2025-07-21 13:11:03 -04:00
Martin-Molinero 37dca9d458 Remove log packet aggregation (#6538)
Regression 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
- Remove log packet aggregation
- Clean up Queue api usage
2022-08-11 19:06:11 -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 1dd742d1b8 Order sizing fix
- Improving OrderSizing.Value and Volume to include code in consumers
- OrderSizing.GetUnorderedQuantity() will adjust result by lot size
- ImmediateExecutionModels will use OrderSizing.GetUnorderedQuantity()
- OrderSizing.Value() will take into account ContractMultiplier
- Adding unit tests
2020-02-11 13:17:10 -03:00
Martin Molinero c77a7b9116 Add performance note 2019-06-04 19:05:36 -03:00
Martin Molinero ee4f8fee82 Overall performance improvements
- `TimeSliceFactory` will avoid creating empty collections
- `ExecutionModels` will check target collection count before trying to
enumerate
- Reduce calls to .`TotalPortfolioValue`
- `SecurityValues` will only be created when required
- `TimeKeeper` will use TimeZone unique Id as dictionary key. The
TimeZone hash is expensive.
- `AlgorithmManager` will avoid calling `DateTime.UtcNow`,
`ConvertFromUtc()` and `RoundDownInTimeZone()`
2019-06-03 15:09:02 -03:00
AlexCatarino b9f7b8fa52 Fixes StandardDeviationExecutionModel
This model was assuming that the history request used to warm up the indicators contains the 'close' column which is only valid for Equity.

The models were also refactored to update the indicators without a consolidator since the last data point from the history request was not pushed throught the indicators.
2019-04-18 16:38:45 +01:00
Martin Molinero cfa08a11fb Address reviews
- Removing `using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm`
- Removing `QCAlgorithmFrameworkBridge`
- Removing `IsFrameworkAlgorithm`
- Making `EmitInsightBasedOnFill` private. Adding new
`IOrderEventProvider` exposing an `event` to which `QCAlgorithm` will
subscribe.
- `AccountType.Cash` algorithms will be allowed to manually trade and
emight insights manually or with alpha model.
2019-04-03 21:55:44 -03:00
Martin Molinero 19f1806ddc Address review: readd Framework project 2019-04-03 21:55:43 -03:00
Martin Molinero 32ac3146b4 Merge Framework and Classic Algorithms
- Merging Framework and Bridge algorithms into classic QCAlgorithm
class.
- Removing Framework project, VS17 and VS15
2019-04-03 21:54:32 -03:00
Martin Molinero c73b7bb62f Adding smarter methods for PortfolioTargetCollection 2018-07-27 10:48:55 -03:00
Stefano Raggi 7bc991a621 Update execution models to execute trades ordered by margin impact 2018-06-22 18:07:13 +02:00
Michael Handschuh fc9380bcd8 Add base class for execution models
Update existing models to derive from new base class
2018-05-11 01:50:45 -04:00
Michael Handschuh d3bf5159ca Make execution models overrideable 2018-05-07 16:13:10 -04:00
AlexCatarino c820ad4c36 Adds python version of C# execution models
- Typoes were fixed in `ImmediateExecutionModel.cs`;
- Refactors `PriceIsFavorable` methods in `StandardDeviationExecutionModel` and `VolumeWeightedAveragePriceExecutionModel` C# models;
- Adds python version of C# execution models
2018-04-19 11:52:10 +01:00
Michael Handschuh 41a6e582f3 Convert framework model parameters to use arrays
Arrays make for easier consumption in python algorithms
2018-04-10 19:24:35 -04:00
Michael Handschuh 31bc9d0544 Add method to easily warmup indicators
Three methods were added to enable easier consumption of an enumerable
of slices returned from a history request. The dictionary version is
most likely to be used by python, while the functional versions allow
for lots of flexibility in how you'd like to consume the stream of slices.
2018-04-06 16:30:28 -04:00
Michael Handschuh 0b90c67f6f Warmup STD indicator in StandardDeviation exec model 2018-04-06 16:30:27 -04:00
Michael Handschuh 9221e954cd Remove securities after complete removal from universe
The execution models should maintain references to symbol data as long as
the security is a member of at least one universe. It's important to note
here that 'membership' in the universe is not the same as 'recently selected'
by the universe. A security remains a member even after it's been deselected
until it has zero holdings and zero open orders.

In the next commit we'll add an extra condition which will confirm that there
are also zero outstanding portfolio targets for the security.
2018-04-06 16:30:27 -04:00
Michael Handschuh 3b8c6124bc Improve readability of PriceIsFavorable
These methods were phrased in the negative sense. This change
reads how one would expect, if certain conditons are met, then
buy -- vs, if certain condition is not met, don't buy.
2018-04-06 16:30:26 -04:00
Michael Handschuh 92c5e64024 Adds VWAP and STD execution models
VWAP will submit market orders while the current price is more favorable than VWAP.
STD will submit market orders while the current price is a configured number of
standard deviations away from the mean in the favorable direction.
2018-04-06 16:30:26 -04:00