395 Commits

Author SHA1 Message Date
Louis Szeto 20e9fd7899 bug-#4846-Fail on restart investing after liquidation on MaximumDrawdownPercentPortfolio.py (#4847)
* 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>
2020-10-15 13:34:08 -03:00
Martin-Molinero bfd319c91e OptionChain and OptionContract improvements (#4804)
* OptionChain and OptionContract improvements

- QCAlgorithm.AddUniverse will return the added Universe instance.
- Adding new OptionChainedUniverseSelectionModel will monitor a Universe changes
  and will spwan new OptionChainUniverse from it's selections. Adding
  regression test Py/C#.
- Adding new OptionContractUniverse that will own option contracts and
  their underlying symbol. Adding regression test
- Fix double notification for security changes, bug seen in updated
  UniverseSelectionRegressionAlgorithm
- Remove UniverseSelection special handling for Option and Future chains
- Fix DataManager not removing SubscriptionDataConfigs for Subscriptions
  which finished before being removed from the universe
- Refactor detection of user added Universe so that they do not get
  removed after calling the UniverseSelectionModel

* Add check for option underlying price is set

* Address reviews

- Adding python regression algorithm for
  `AddOptionContractFromUniverseRegressionAlgorithm`
  and `AddOptionContractExpiresRegressionAlgorithm`
- Rename QCAlgorithm new api method to `AddChainedOptionUniverse`

* Fix universe refresh bug

- Fix bug where a universe selection refresh would cause option or
  future chain universes from being removed. Adding regression algorithm
  reproducing the issue.

* Rename new option universe Algorithm API method

- Rename new option universe Algorith API method from
  AddChainedOptionUniverse to AddUniverseOptions
- Rebase and update regression test order hash because of
  option expiration message changed
2020-10-09 10:52:50 -03:00
Adalyat Nazirov 1e3a1e3c43 Historical data requests start & time fix (#4733)
* regression tests

* fix: apply the same time convertion to history request time as for data time

* ver2

* fixup

* unit tests

* do not need this conversion because RoundDownInTimeZone returns in proper TZ

* comment

* requested changes

* refactoring

* more refactoring

* fix existing test: should return Sunday if open

* more symbols

* fix existing tests: submit new btcusd data

* fix

* add Cfd symbol
2020-09-24 14:51:35 -03:00
Jasper van Merle 2d022fadff Fix unclosed summary tag 2020-06-17 20:27:40 +02:00
AlexCatarino 961f2292c2 Renames rebalancingParam to rebalance in PCMs 2020-05-27 20:48:29 +01:00
Stefano Raggi cfb3329f33 Update System.Net.Http to latest version
- also removed unused references
2020-05-22 22:55:18 +02:00
Martin Molinero 9631cd6749 Fix nuget QC dependency version 2020-05-21 16:21:59 -03:00
Martin Molinero 09c17b71ed Add assembly description to nuspec
- Due to bug in nuget failing to replace description and copyright token, setting
  .nuspec description to match assembly description
2020-05-21 14:42:12 -03:00
Martin-Molinero 1d0d4f4d7b Add assembly descriptions (#4442)
Add assembly descriptions
2020-05-21 09:35:12 -07:00
Martin-Molinero 9385707061 Merge pull request #4407 from michael-sena/feature-open-interest-future-universe
Add a futures universe selection model that uses open interest
2020-05-18 12:47:52 -03:00
Michael Sena a5d7bdafde Add a futures universe selection model that uses open interest 2020-05-19 00:30:58 +10:00
Martin Molinero 891cf4d69b Update to .Net 4.6.2 2020-05-15 17:32:46 -03:00
Martin Molinero afa39cc0b1 Fix exceptions in ReturnsSymbolData
- Fix out of range exception, if the returns array is smaller for some
  of the Symbols it will use double.NaN, similar behavior to when a date
  isn't found for a Symbol. Adding unit test
- Fix duplicate key exception at ReturnsSymbolData.Returns, this could
  happen with FF in history requests. Adding unit test
2020-05-13 17:22:14 -03:00
Martin Molinero 499248fe12 Revert "Revert "Adding Support for Equity L1 Quote Data""
This reverts commit 8cd8d206ca.
2020-04-06 10:32:59 -03:00
AlexCatarino 72f0f44f60 Updates Pythonnet Version
From 1.0.5.29 to 1.0.5.30
Ref.: https://github.com/QuantConnect/pythonnet/pull/42
2020-04-01 16:15:05 +01:00
AlexCatarino 12c71ee6f9 Fixes ReturnsSymbolData to Account New Security Additions
When new securities are added to the universe, the `ReturnsSymbolData` is warmed up with historical data that may not have the same timestamp causing an index mismatch that leads to a rejection to several valid data. In this case, we will assume that there is a time correspondence similar to what is done in Python. Unit test was added.

`BlackLittermanOptimizationPortfolioConstructionModel` will consider a new view only if there is a new last active insight by updating the `ReturnsSymbolData` with the `Insight.GeneratedTimeUtc` instead of the `IAlgorithm.Time`. Consequently, the timestamp of the historical data is converted to UTC for consistency.

`BlackLittermanSymbolData` now rejects duplicate keys like its C# version: `ReturnsSymbolData`.

Finally, `BlackLittermanPortfolioOptimizationFrameworkAlgorithm` statistics was updated because of the bug fixes.
2020-03-19 20:59:19 +00:00
Jared 8cd8d206ca Revert "Adding Support for Equity L1 Quote Data" 2020-03-11 19:16:05 -07:00
Martin Molinero f6c687b5f1 Fix regression and unit test
- Reduce MinimumVariancePortfolioOptimizar precision goal so that both
CSharp and Py MeanVarianceOptimizationFrameworkAlgorithm return the same
results
- Limit factor file dates in factor file generator unit test
2020-03-11 16:41:27 -03:00
Martin Molinero 75ca2862e6 Address reviews 2020-02-21 16:13:28 -03:00
Martin Molinero 983d84bf01 Implement PortfolioBias for MVOPCM, BLOPCM, AIPCM
- Implement portfolio bias for
`MeanVarianceOptimizationPortfolioConstructionModel`,
`BlackLittermanOptimizationPortfolioConstructionModel`,
`AccumulativeInsightPortfolioConstructionModel`. Adding unit tests
2020-02-21 12:12:59 -03:00
AlexCatarino c2ff03caad Implements PortfolioBias in EWPCM and IWPCM
Implements `PortfolioBias` in EWPCM, CWPCM and IWPCM. With this new feature, these PCM will ignore insights that do not respect the desired bias. E.g. for `PortfolioBias.Long`, on Insights with `InsightDirection.Up` will be converted into `PortfolioTarget.Quantity` greater than zero and other `InsightDirection` will result in `PortfolioTarget.Quantity` of zero.
2020-02-20 19:29:12 -03:00
Martin Molinero a8120c197a Improvements
- Adding new unit test for python PCM implementations, asserting each
method is correctly called
- Reverting some unrequired changes in the
`MeanVarianceOptimizationFrameworkAlgorithm`
2020-02-20 12:13:47 -03:00
Martin Molinero 8ff23936d1 Refactor EWPCM into base PCM
- Refactor shared logic from `EqualWeightingPortfolioConstructionModel`
into base `PortfolioConstructionModel` implementation
- `MeanVarianceOptimizationPortfolioConstructionModel` will respect
rebalancing period and will use all active inisights, not just the last
2020-02-19 15:13:20 -03:00
Martin-Molinero 685b231890 Merge pull request #4113 from QuantConnect/refactor-4112-accumulative-portfolio-construction-model
Refactor AccumulativeInsight PCM
2020-02-19 13:19:17 -03:00
AlexCatarino 8a1823de73 Addresses Peer-Review 2020-02-18 16:00:09 +00:00
AlexCatarino fcf2696809 Rebases With Master and Apply New API
Improves regression algorithm by adding more sanity checks.
2020-02-18 13:47:57 +00:00
AlexCatarino 21ce895c18 Implements SectorWeightingPortfolioConstructionModel
Provides an implementation of `IPortfolioConstructionModel` that generates percent targets based on the `CompanyReference.IndustryTemplateCode`.
2020-02-17 22:08:06 +00:00
Martin Molinero 1fccf4f263 Address reviews
- Use `InsightCollection.GetActiveInsights`
2020-02-17 19:01:18 -03:00
Martin Molinero 0ff713d8f9 Refactor AccumulativeInsight PCM
- Refactor AccumulativeInsightPortfolioConstructionModel to inherit from
the EWPCM, reducing code duplication and adding support for rebalancing
period
- Fixing bug where only 1 new insight per symbol was processed per loop
- Adding unit tests
2020-02-17 16:09:16 -03:00
Martin Molinero 3679ad591f Address reviews
- Improve custom rebalance function logic
- Add new PyObject C# PCM constructor overloads for performance
2020-02-14 16:38:16 -03:00
Martin Molinero e12788375b Adding IDateRule rebalacing PCM
- Adding IDateRule to be used by the PortfolioConstructionModel as
rebalancing function.
- Adding unit tests and C#/Py regression algorithms
2020-02-13 18:23:15 -03:00
Martin Molinero 0845f0802d Unknown next rebalance time
- Adding new `Func<DateTime, DateTime?>` that allows PCM to return null
if the next rebalance time is null, in which case the function will be
called again in the next loop.
- Adjusting PCM next rebalance time check to perform rebalance once the
time is reached
- Adding new regression test. Updating existing
2020-02-13 16:10:52 -03:00
Jared 873a392546 Merge pull request #4079 from QuantConnect/refactor-4075-portfolio-construction-rebalancing-period
Refactor PCM rebalacing
2020-02-11 16:54:52 -08:00
Martin Molinero d3a2c7ff5a Address reviews
- Moving InsightCollection into base `PortfolioConstructionModel`
- Will call `InsightCollection.GetNextExpiryTime()` on each check, and
for performance `InsightCollection` will keep track of next insight
expiry time
- Removing need for PCM base classes having to call `RefreshRebalance`
- Some refactor clean up at base
PortfolioConstructionModel.IsRebalanceDue()
2020-02-11 21:02:35 -03:00
Martin Molinero 4fc9a516fd Adding RebalanceOnInsightChanges flag
- Refactoring some PCM methods to be `protected` since they are not required
to be public
- Adding new `PortfolioConstructionModel.RebalanceOnInsightChanges`
flag, that will allow avoiding new insights or insight expirations to
trigger a rebalance
- Updating unit tests
- Fix for the MeanVarianceOptimizationPortfolioConstructionModel that
was skipping, in some cases, 0 magnitude insights
2020-02-11 16:06:27 -03: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 6cfa19697a Refactor PCM rebalacing
- Add missing PCM constructor methods for the different supported
rebalancing periods overloads
- Normalize rebalance behavior in the base `PortfolioConstructionModel`
- Adding new `PortfolioConstructionModel.RebalanceOnSecurityChanges`
that will allow disabling rebalance on security changes
- Adding unit tests
2020-02-10 22:32:09 -03:00
Jared b95973cf69 Merge pull request #3940 from wardjm/feature-accumulative-model
Feature accumulative model
2020-01-14 13:57:10 -08:00
Jeff Ward ad642bb951 Fixed typo and type mismatch. 2020-01-14 12:34:45 -05:00
Jeff Ward c738dc7d22 Fixed CI build errors. 2020-01-14 12:10:18 -05:00
Jeff Ward 8d9f68370a Added missing parenthesis. 2020-01-14 11:49:50 -05:00
Jeff Ward 8c7d63e80c Implemented 2nd code review changes. 2020-01-14 11:37:40 -05:00
AlexCatarino 898a5c2324 Addresses Peer-Review 2020-01-08 22:21:15 +00:00
AlexCatarino f205a7e8cd Refactors QC500 Universe and Universe Selection Model
The class field that tracks the current month is updated only if there are securities that passed the selection criteria. It prevents division by zero and allows the universe selection a new attempt on the next trading day while keeps the universe unchanged
2020-01-07 09:24:58 +00:00
Frank Norman 721e8c2c13 Added a check for zero denominator. 2020-01-07 08:45:17 +00:00
Jeffrey Ward a296d346a4 Pull request fixes. 2019-12-20 18:01:35 -05:00
Jeffrey Ward a796f30458 Added AccumulativeInsightPortfolioConstructionModel. 2019-12-20 18:01:35 -05:00
Michael Handschuh 1b509f9644 Call dispose on IDisposable entries when removed
This helper is a favorite of mine to use in models to handle OnSecuritiesChanged
event to maintain internal state in light of additions/removals. Sometimes, the
internal state objects implement IDisposable, and without this code, they would
never be disposed. A good usage of IDisposable here would be to remove any items
that are only used by that single security related internal state such as a consolidator
2019-12-10 18:54:39 -05:00
Michael Handschuh dd9829b646 Dispose removed entries
These entries are often SymbolData classes that may implement dispose
as a means of cleaning up consolidators/indicators/etc
2019-12-10 18:45:11 -05:00
Martin Molinero ec7a8fa906 Bump PythonNet to 1.0.5.29 2019-11-13 17:33:32 -03:00