* Update regression test
* Update model to expire insights
* Avoid remove insights
* Update regression test
* Use InsightManager Cancel to Expire All Insights
* Update CompositeRiskManagementModelFrameworkAlgorithm
This regression also depends on `MaximumUnrealizedProfitPercentPerSecurity` and `MaximumDrawdownPercentPerSecurity` but `MaximumDrawdownPercentPerSecurity` doesn't close positions.
---------
Co-authored-by: Alexandre Catarino <AlexCatarino@users.noreply.github.com>
Regression Tests / build (push) Has been cancelled
Python Virtual Environments / 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 OnEndOfAlgorithm and update expected trades
* Update models to cancel insights
* Update expected results
There are 3 trades instead of 2 because the PCM does a rebalance
* Remove `Remove` method call
* Update to use the new `Cancel` method
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
* Reproduce TrailingStopRiskManagementModel bug with test case
* Fix TrailingStopRiskManagementModel to make it relative to max price
* Adapted old TrailingStopRiskManagementModel test to new implementation
* Fix TrailingStopRiskManagementModel Python version
* Fixed TrailingStopRiskFrameworkAlgorithm regression tests data
* Handling both long and short positions in TrailingStopRiskManagementModel
* Traking holdings value instead of unrealized profit in TrailingStopRiskManagementModel
* Checking for position side change in TrailingStopRiskManagementModel
* Handling immediate liquidation in TrailingStopRiskManagementModel
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* Order handling improvements
- Execution model will only trigger market order if they are above the
minimum order margin portfolio percetage value
- SecurityCache.Reset is complete
* Python Import fixes
- Add regression test for ImmediateExecutionModel minimum order margin
check
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* To fix the referenced issue
* Fixing up TrailingStopRiskManagementModel
* Fix-ups to address review
* Impl. tests + relevant improvements
* Minor logic improvement at first dictionary update
* Regression test small fix
* Adds explicit 'D' suffix for numbers in test case double arr
* Use integer values in test cases
* Removes failing testcases in MaximumDrawdownPercentPerSecurityTests (!) & renaming
* Revert "Removes failing testcases in MaximumDrawdownPercentPerSecurityTests (!) & renaming"
This reverts commit f9cd279f8cc5e9e1ede5b6f1eae5f4266b7dd295.
* Fix up for failing test cases
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* Python research import improvements
- Improve start.py for research env
- Remove unrequired imports
* Centralize algorithm imports
* Add regression test GH action
* Unit test python import clean up
* Join research and main imports
* More python import clean up
* Fix failing skipped regression algorithm
* Fail on restart investing after liquidation
I added a line so that the trailing high value could be rebalanced and the investment process won't be stop by high value always more than current value by drawdown percent.
* Update MaximumDrawdownPercentPortfolio.py
* Fix for MaximumDrawdownPercentPortfolio
- Fix C# MaximumDrawdownPercentPortfolio to reset portfolio value after
liquidation. Only reset once we have actually adjusted some targets.
Updating regression algorithms.
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
- 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.
`MaximumSectorExposureRiskModel` needs `IndustryTemplateCode` which is only found in Equity data with Fundamental data. Thus, we check whether all active securities have such information.
The C# version was supposed to handle python modules, but when they inherit from a C# module, pythonnet send them as C# objects. Consequently, they are not wrapped and cannot be used. The python version of `CompositeRiskManagementModel` solves the issue.
- Implements python version of `MaximumUnrealizedProfitPercentPerSecurity`
- Updates `CompositeRiskManagementModelFrameworkAlgorithm` in order to use python risk model.
Restructured
Update message
Added removal of trailing highs for unnecessary securities
Add logging message
Improvements
Rename
Add regression Algorithm
Changed to use TradeBar values instead of only current price
Cleaned msg layout
Update Regression test
The CompositeRiskManagementModel aims to provide support for multiple
risk management models. In order to accomplish this, it must respect
the return values from each individual model. As previously written,
the composite model was allowing models run later to completely nuke
the targets produced by earlier models. This change performs the
composition of targets using the same technique as is used when over
laying the risk adjusted targets on top of the portfolio construction
model's targets. This approach gives preference, by symbol, to the
risk adjusted targets, but if there is no risk adjusted target, then
it uses the targets from the previous step. For example, if targets
for A, B, C, and D are produced by PCM, then risk model 1 adjusts to
zero targets for B and cuts the targets for C in half, these are then
piped to risk model 2 (A, C/2, D). Risk model 2 may return ZERO targets.
This doesn't mean we should remove all the targets, it simply means
that the risk model didn't adjust any and we should use the output
from risk model 1. Now, let's say risk model 2 zeroes out A and cuts
B in half again, the final result should (and now is) C/4, D. IOW,
risk models only return deltas, things to be changed, so returning
nothing means there are no changes.
This is the inverse of the MaximumDrawdownPercentPerSecurity risk model.
It's goal is to liquidate holdings for a security when the unrealized profit
passes a specified threshold. This can viewed as a 'take the money and run'
risk model.
Framework models should not loop over `algorithm.Securities` since it contains all securities that were ever added to the algorithm, but `UniverseManager.ActiveSecurities` that contains only the active securities.
Instances of `PortfolioTargetCollection` are intended to be a class level variables and not a method level variables. As a class member it maintains a complete set of all portfolio targets so you can operate against a 'full view' instead of the potentially streaming targets (which can come in one by one as alpha is generated).
The exception in ignored because the generator isn't closed until it is being deleted (automatically in this case, when Python exits); the generator __del__ handler closes the generator, which triggers an exception of there is one.
The current targets are passed into the risk model for risk assessment.
The risk model is only required to return any changes required from the
point of view of the risk model. The risk adjusted targets are given
priority, and if no risk adjusted target is specified for a symbol than
the target produced by porfolio construction will be used.