Commit Graph

978 Commits

Author SHA1 Message Date
Michael Handschuh 446e07aa56 Fix composition bug in CompositeRiskManagementModel
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.
2018-10-15 13:52:41 -04:00
Martin Molinero eaba3ab24e Fix ManualUniverse duplicate effort
- Removed usages of algorithm.Securities.key as a parameter for the
`ManualUniverseSelectionModel()` since those securities, added through
`AddXXXX` calls will be managed by the `UserDefinedUniverse`. This was
causing for Universes to try to add the same subscription requests
- Adding new empty constructor for ManualUniverseSelectionModel,
required for Python
- ManualUniverse will return any existing SDC for the
symbol. This is for maintaining existing behavior and
preventing breaking changes: Specifically motivated by usages of
Algorithm.Securities.Keys as constructor parameter of the
ManualUniverseSelectionModel, since those Symbols added by Addxxx()
calls will already be managed by the UserDefinedUniverse
- Making some format modifications to aling with used Lean formatting
2018-10-12 18:30:04 -03:00
David 28bc066692 Add CompositeRiskManagementModelFrameworkAlgorithm 2018-10-08 22:11:14 +01:00
AlexCatarino a4cd0a8412 Use bid/ask price to calculate the unrealized profit
In `SecurityHolding.TotalCloseProfit`, use the market order direction to define whether ithe method should use the bid or the ask to compute unrealized profit.

- Fix statistics of futures' algorithms.
- Adds unit test.
2018-09-21 20:32:14 +01:00
AlexCatarino 720e0400fc Implements custom seed function to CustomSecurityInitializerAlgorithm 2018-09-17 18:28:59 +01:00
Juan José D'Ambrosio 4f320d83ac BasicTemplateFuturesFrameworkAlgorithm statistics updated 2018-09-06 14:06:38 -03:00
Juan José D'Ambrosio c0b33daa3b BasicTemplateFuturesAlgorithm statistics updated. 2018-09-06 13:31:08 -03:00
Martin Molinero 165f6fa43e Adjusting unit and regression tests 2018-08-28 12:27:21 -03:00
AlexCatarino 93a88eda95 Updates FractionalQuantityRegressionAlgorithm to use SetBuyingPowerModel 2018-08-21 16:49:07 +01:00
Michael b30d429be6 Merge pull request #2427 from QuantConnect/bug-2064-add-option-contract-throw-if-underlying-not-raw
AddOptionContract - throw if existing underlying equity not in Raw mode
2018-08-21 11:44:16 -04:00
Stefano Raggi b4a2536b86 AddOptionContract - throw if existing underlying equity not in Raw mode
Also added OptionChainProviderAlgorithm to regression test suite
2018-08-21 14:51:43 +02:00
AlexCatarino 76cc75006c Refactors BlackLittermanOptimizationPortfolioConstructionModel
1. Apply the pattern used in `EqualWeightingPortfolioConstructionModel`
2. Change the logic to compute the views from the insights.
3. Change the logis to compute the posterior mean and covariance

Use `UnconstrainedMeanVariancePortfolioOptimizer` in `BlackLittermanPortfolioOptimizationFrameworkAlgorithm` to bypass the difference in regression tests with `IPortfolioOptimizer` that rely on different algorithms in C# and python.

Adds unit tests for BLOPCV to test the implementation against Black and Litterman 1999 paper.
2018-08-20 21:01:14 +01:00
Martin Molinero ed33286842 Updating regression statistics 2018-08-15 21:10:49 -03:00
Jared Broad db0f85122c Increase the universe of assets to increase insights 2018-08-15 18:41:46 -04:00
Martin Molinero c1272874fb Adding regression statistics 2018-08-15 11:58:46 -03:00
Jared Broad 8be3057354 Fix whitespace tab 2018-08-14 18:46:22 -04:00
Jared Broad c4d0baab49 Added 2 example benchmark alphas 2018-08-14 18:43:45 -04:00
AlexCatarino 45c8df325e Fixes the time guard condition using less and equal
If `algorithm.UtcTime` is equal to `nextExpireTime`, the model should not emit new targets.
2018-08-13 19:45:25 +01:00
AlexCatarino 239a5a909e Fixes EqualWeightingPortfolioConstructionModel not flattening expired insights
- When there are or aren'tt new insights, the EqualWeightingPortfolioConstructionModel will creates a target to flatten delisted securities from the universe of expired insights.
- Helper methods were added to deal with removing expired insights and getting active ones and used in `EqualWeightingPortfolioConstructionModel`
- Adds unit test
- Updates framework algorithms
2018-08-13 19:45:25 +01:00
Stefano Raggi 454d4acf43 Add missing data files for BasicTemplateFuturesFrameworkAlgorithm 2018-08-08 18:14:40 +02:00
Jared b9d4536b08 Merge pull request #2362 from QuantConnect/bug-2357-fix-insight-close-time
Fix insight close and analysis times
2018-08-07 16:26:18 -04:00
AlexCatarino ff85c2500a Fixes algorithms to reflect changes in EqualWeightingPortfolioConstructionModel 2018-08-07 19:40:01 +01:00
Martin Molinero 1c35ab6241 Fix WarmupConversionRatesRegressionAlgorithm 2018-08-07 14:21:39 -03:00
Michael Handschuh 4fd16f6daf Fix resolution of insight close times, allow user defined close times
Fixes a bug where we were using the security's data resolution to compute
the insight's close time. This led a case such as insight.Period == 20days
to step 20days worth of tradable minutes (assuming minute data resolution),
yielding a close time that was very far in the future.

We also add different means of specifying an insight's period/close time:
1. Specify insight period as a TimeSpan and we compute close time
2. Specify insight period and a resolution and bar count and we compute close time
3. Specify insight close time local directly and we compute the insight period

The key here is maintaining consistency between the three different approaches
which is heavily validated with the corresponding unit tests.

Edits also made to trust the insight's close time as the analysis end time in
the case where the analysis period == insight period (extra analysis period = 0).
Given the current setup (extra analysis period == 0), this guarantees that close
and analysis end times are equivalent.

Regression statistics were updated and expectedly we get many more insights that
have completed analysis, and as such, average scores have also changed.
2018-08-07 11:21:11 -04:00
Michael 67bd47948e Merge pull request #2331 from Martin-Molinero/bug-2318-fix-for-getmaximumorderquantityfortargetvalue
Improving GetMaximumOrderQuantityForTargetValue
2018-08-07 10:52:29 -04:00
Martin Molinero 6da57a1e12 Improving GetMaximumOrderQuantityForTargetValue 2018-08-03 16:26:14 -03:00
Michael cfb05d190f Merge pull request #2328 from AlexCatarino/feature-2326-implements-futures-template-framework
Implements BasicTemplateFuturesFrameworkAlgorithm
2018-08-02 10:44:09 -04:00
Michael a16d8b95b0 Merge pull request #2324 from AlexCatarino/bug-2279-remove-warmup-statistics-skew
Exclude warmup period from statistics sampling
2018-08-02 10:43:22 -04:00
Jared d2decfebf7 Merge pull request #2320 from QuantConnect/bug-2139-seed-insight-ema
Seed insight score EMAs with 50
2018-08-01 18:12:56 -04:00
AlexCatarino e23371d271 Adds a trade to WarmupConversionRatesRegressionAlgorithm
Adds a trade to `WarmupConversionRatesRegressionAlgorithm` and updates the `ExpectedStatistics`.
Before the changes proposed in this pull request, CAGR jumps from 1441.897% to 3067.390%.
2018-08-01 22:39:39 +01:00
Michael Handschuh b038839e78 Seed insight score EMAs with 5 point SMA
This is to remove some asymptotic behavior when the first insight
score is 1 or 0.
2018-08-01 12:21:01 -03:00
Stefano Raggi dc4b961ec8 Update CoarseFundamentalTop5Algorithm to run as cloud regression test
- The algorithm has been renamed to CoarseFundamentalTop3Algorithm and updated to select the Top 3 instead of Top 5.
- The only new data required is daily, map and factor file for FB and has been added (map and factor files are dated 6/4/2018, as required by all regression tests).
- The coarse fundamental open source data has been updated.
- The expected regression statistics for the algorithm have been updated.
2018-07-31 21:20:06 +02:00
AlexCatarino 0bc157a8e7 Removes logging from framework models and algorithms
Shipped modules should be silent unless error case.
2018-07-31 19:16:17 +01:00
AlexCatarino e5ed09924b Implements BasicTemplateFuturesFrameworkAlgorithm
This algorithm shows how to implement a futures strategy in a framework algorithm.
`FutureUniverseSelectionModel` portfolio selection model was implemented to provide a base class to help create other futures universe selection models.
2018-07-30 22:21:47 +01:00
Martin Molinero 2410726b92 Fix exception being thrown when using SetWarmup with an option contract 2018-07-25 18:45:19 -03:00
Michael d2bb02d786 Merge pull request #2253 from QuantConnect/bug-2226-Option-contract-not-delisted-if-expiry-date-is-a-holiday
Fixes option contract not delisted if expiry date is a holiday
2018-07-25 15:05:59 -04:00
Stefano Raggi 5382a0c72c Add Quandl API key to URL in CustomDataRegressionAlgorithm 2018-07-25 15:21:59 +02:00
Juan José D'Ambrosio 84e0074350 Adding a control to avoid set the last trading date in a holiday
Move delisting date estimation to the constructor

Using `MarketHoursDatabase` for option delisting date estimation instead USHolidays
Adding file header.
Regression algorithm added.

Use of  `ExchangeHours.IsDateOpen` instead  `ExchangeHours.IsDateOpen.Holidays`.
Extract values from `symbol.ID` into a local variable.


Improved Regression test
2018-07-24 16:04:33 -03:00
Stefano Raggi 16f856031c Update start date for OptionSplitRegressionAlgorithm 2018-07-24 18:59:53 +02:00
AlexCatarino b402c3673e Fixes MVOPC: it was not testing whether all magnitures are zero
- Changes `ExpectedStatistics` in MVOFA
  - All regression tests now
- Removes unnecessary constructor arguments in `ReturnsSymbolData`
- Tide up code and add method summaries.
2018-07-24 16:53:11 +01:00
wildart bbb6a2a771 updated statistics for BlackLittermanPortfolioOptimizationFrameworkAlgorithm 2018-07-24 16:53:11 +01:00
wildart b025f01293 review fixes
- separete classes for optimizers
- refactored `ReturnsSymbolData`
2018-07-24 16:53:11 +01:00
Art Wild d5996fb7c8 MV & BL portfolio optimization implementation
Closes #1998. Closes #2219.
2018-07-24 16:53:11 +01:00
Stefano Raggi 3d48efcbea Add Tiingo Daily Prices example algorithm 2018-07-24 13:24:52 +02:00
Michael 21a227eaae Merge pull request #2295 from AlexCatarino/bug-2293-python-custom-data-type
Fixes custom data type mismatch in python algorithms
2018-07-23 15:37:22 -04:00
AlexCatarino d75794ede2 Adds indicator with custom data in BasicTemplateIntrinioEconomicData.
This addition aims to show that the fix of the preivious commit solves the bug.
2018-07-23 17:26:43 +01:00
Stefano Raggi fde0239930 Fix failing internal feed regression algorithms 2018-07-23 14:25:28 +02:00
Stefano Raggi 1138b0c1e2 Fix TimeInForceAlgorithm regression tests 2018-07-19 11:52:40 +02:00
Michael df88433428 Merge pull request #2276 from QuantConnect/bug-2273-internal-feeds-end-time
Fix internal feed subscription end time in AlgorithmManager
2018-07-19 00:11:58 -04:00
Stefano Raggi bd3c48e05e Fix internal feed subscription end time in AlgorithmManager 2018-07-19 00:32:20 +02:00