Commit Graph

32 Commits

Author SHA1 Message Date
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
AlexCatarino 22723204ff Fixes VolumeWeightedAveragePriceExecutionModel.IntradayVwap
`VolumeWeightedAveragePriceExecutionModel.IntradayVwap.Update` did not return a boolean.
2019-07-29 11:28:06 +01: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 d9195317e3 C# decimal to Python conversion
- This commit is related to PR 19 in QC/pythonnet
   - C# decimal will be cast to C# double and converted into python
   float
- Adding new `decimal.py` into the python algorithm project. This is
required for backwards compatibility with users performing operations
over expected decimal types (like `Price`)
- Updating two python regression test algorithms using custom python
execution models to be aware and ignore floating point precision errors
when handling order sizing.
2019-01-15 12:13:42 -03:00
Stefano Raggi 5c9b81cef1 Fix Python initialization and imports for multiple tests 2018-10-02 20:28:13 +02: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
AlexCatarino 7bffd60c2d Minor framework fixes
- `NullExecutionModel.py`: return array instead of void
- `NullRiskManagementModel.cs`: inherit from base class instead of interface
2018-05-16 13:37:38 +01:00
AlexCatarino 4ad1b5bd8a Python execution models subclass C# ExecutionModel
- Adds python version of `NullExecutionModel`
2018-05-15 20:48:13 +01:00
Michael Handschuh 2bb99a595b Add base class for risk management models
Update existing models to derive from new base class
2018-05-11 01:55:16 -04: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 534c95902c Use VWAP indicator from indicators project
The volume weighted average price execution model had its own implementation
of VWAP since the existing VWAP didn't perform the daily reset. The intraday
VWAP indicator has since been added to the indicators project so this is just
duplicate code.
2018-05-07 16:13:10 -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 64349fea13 Remove cash modelling logic from OrderSizing.GetUnorderedQuantity
After much review, it was determined that this was much more confusing than it
was helpful. The removed implementation hinged on the thinking that the construction
model would be emitting targets as quantities of cash and not quantities of virtual
positions. A previous commit added a warning message for cash modelling and this
commit removes a (bad) attempt at making cash modelling work as expected. For now,
if you want to use cash modelling with the algorithm framework, careful thought will
need to be applied to the implementation of the portofio construction model AND the
execution model. They'll each need to be speaking on the same terms. As of this point,
we're unsure of a means to address all concerns, and so are leaving it as a warning
message coupled with decent documentation in the commit history regarding our
discussions/thoughts on the topics.

Again, the key for cash modelling working properly is just that the portfolio
construction model and the execution model agree on what each target means and
also agree on how virual positions vs currency balances are handled and managed.
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
AlexCatarino b8cfbd7c24 Improves error message in python wrappers 2018-03-14 12:30:50 +00:00
AlexCatarino 35d29060d0 Implements python support for custom models in framework
Adds method overload that accept a `PyObject` to `SetAlpha`, `SetExecution`, `SetPortfolioConstruction`, `SetPortfolioSelection` and `SetRiskManagement`. In these methods, a custom model written in python will be wrapped around the respective `PythonWrapper`.
2018-03-13 11:35:31 +00:00
Michael Handschuh 1dd84c65df Add NullExecutionModel and NullPortfolioConstructionModel
When focusing on generating alpha signals we don't need t both with execution or
portfolio construction models. Instead we can judge how well we do based on our
generated alphas. By not submitting orders, backtests and live performance is
greatly improved.
2018-01-02 14:53:40 -05:00
Michael Handschuh 087c7a748d Rename INotifiedSecuritiesChanged -> INotifiedSecurityChanges
Also synchronizes the helper class's name
2017-12-08 10:07:54 -05:00
Michael Handschuh ff8842be5c Convert IPortfolioTarget.GetTargetQuantity to Quantity property
This forces the quantity computation to be performed from the portfolio construction model.
As a result of this change, we've removed the Percent and Quantity implementations and
replaced them with just a PortfolioTarget implementation that is equivalent to the previous
Quantity implementation. Users can still use the static Percent method to generate the
correct quantities for a target for the common case of a percent weighted portfolio.
2017-12-08 10:07:54 -05:00
Michael Handschuh 7076928904 Add IExecutionModel
The execution model is responsible for executing trades to achieve the desired
portfolio targets
2017-12-08 10:07:54 -05:00