Commit Graph

156 Commits

Author SHA1 Message Date
Martin Molinero 1997197f47 Fix failing unit tests 2018-09-18 12:10:42 -03:00
Martin Molinero 41873b2315 Fixing unit tests 2018-08-31 16:06:41 -03:00
Martin Molinero 165f6fa43e Adjusting unit and regression tests 2018-08-28 12:27:21 -03:00
Stefano Raggi c694e9faae Post merge fixes 2018-08-21 18:10:52 +02:00
Stefano Raggi cead4e608e Update EqualWeightingPortfolioConstructionModel to check for null targets 2018-08-21 18:10:52 +02:00
Stefano Raggi b37fd75f59 Fix failing unit test 2018-08-21 18:10:51 +02:00
Stefano Raggi 4abc525a38 PortfolioTarget.Percent returns null if error 2018-08-21 18:10:51 +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
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
Michael Handschuh d5f88c6bb7 Add Insight.IsActive and Insight.IsExpired methods
Easily check if an insight is active or expired
2018-08-10 13:52:17 -04:00
Jared 709c1e969a Merge branch 'master' into testing-2360-vwap-execution-model-tests 2018-08-09 10:13:44 -04:00
Jared 68f0d3d608 Merge pull request #2364 from QuantConnect/testing-2361-travis-include-python-tests
Enable Python unit tests ignored with TravisExclude
2018-08-09 10:07:54 -04:00
Stefano Raggi fadda32e08 Enable ignored/excluded Python unit tests 2018-08-09 11:51:53 +02:00
Stefano Raggi 95dc7c711b Add unit tests for VolumeWeightedAveragePriceExecutionModel 2018-08-08 18:22:37 +02:00
Stefano Raggi 039c065be8 Add unit tests for ImmediateExecutionModel 2018-08-08 17:47:04 +02:00
Michael f59d9754dc Merge pull request #2343 from QuantConnect/feature-2339-stdev-execution-model-tests
Add unit tests for StandardDeviationExecutionModel
2018-08-07 17:07:42 -04:00
Stefano Raggi d2252412d1 Moved PythonHelper to PythonSetup as NUnit SetUpFixture
- also made a few minor changes in StandardDeviationExecutionModelTests
2018-08-07 17:36:38 +02: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 a366063aed Merge pull request #2354 from AlexCatarino/bug-2353-fix-equal-weighting-pcm
Fixes EqualWeightingPortfolioConstructionModel
2018-08-07 10:54:37 -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
AlexCatarino e0c380d08c Fixes EqualWeightingPortfolioConstructionModel
Adds targets with direction zero to remove invested securities that do not have active insights.
2018-08-06 13:19:03 +01:00
Stefano Raggi 265e18a3c4 Fix PYTHONPATH for all existing framework model unit tests 2018-08-04 00:24:28 +02:00
Stefano Raggi 1dbc5bfb49 Add default folders to PYTHONPATH environment variable 2018-08-03 21:33:03 +02:00
Stefano Raggi 3dd862262b Add unit tests for StandardDeviationExecutionModel 2018-08-03 21:33:02 +02:00
Martin Molinero 6da57a1e12 Improving GetMaximumOrderQuantityForTargetValue 2018-08-03 16:26:14 -03:00
Stefano Raggi 6e86634b21 Add unit tests for MaximumDrawdownPercentPerSecurity risk management model 2018-08-02 12:51:57 +02:00
AlexCatarino 47b3abfca2 Improves the logic to select active insights
- Also: adds unit tests for `EqualWeightingPortfolioConstructionModel`
2018-07-31 19:01:02 +01:00
Martin Molinero c73b7bb62f Adding smarter methods for PortfolioTargetCollection 2018-07-27 10:48:55 -03:00
AlexCatarino c59ff47ed7 Refactors PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm
- Moves `PearsonCorrelationPairsTradingAlphaModel` class to its own file in order to make it available as a framework model.
- Follows existing pattern design that alpha models receive a lookback and a `Resolution` object.
- Algorithm implements `IRegressionAlgorithmDefinition`.
2018-07-11 23:40:30 +01:00
AlexCatarino 6dbe83d0be Renames PairsTradingAlphaModel
- Since it will be used as a base class for other pairs trading models, it was ranamed as BasePairsTradingAlphaModel

- Use a tuple of symbols are key of BasePairsTradingAlphaModel._pairs dictionary.
2018-07-11 23:40:29 +01:00
AlexCatarino e815fe8cba Refactors PairsTradingAlphaModel
Instead of using a single, pre-defined, pair set in the class constructor, the pair is defined when securities are changed, therefore depending on the universe selection model.
2018-07-11 23:40:29 +01:00
Michael 0ec7f297f5 Merge pull request #2059 from QuantConnect/bug-insight-close-times-not-being-set
Refactor setting of insight close/generated times
2018-06-01 01:07:29 -04:00
Michael Handschuh b7c046565b Add unit test for checking insight generated/close times
Confirms the times are set and available inside the portfolio construction
model as well as being set and available via the InsightsGenerated event.
2018-06-01 00:51:41 -04:00
Michael Handschuh ad331118ab Add refresh to IUniverseSelectionModel to support dynamic universes
This change allows the universe selection model to select different universe
definitions as time proceeds. This enables the definition of a universe model
that, for example, could add option chains for securities selected by a different
universe model.

The BasicTemplateOptionsFrameworkAlgorithm was added to showcase and provide
regression for a universe model that selects different universes.
2018-05-31 11:48:23 -04:00
AlexCatarino e914bcf782 Make CommonAlphaModelTests.GetExpectedModelName abstract 2018-05-15 22:38:01 +01:00
AlexCatarino b15cfacff2 Insight.Group retuns the original Insight array with modified Insights
Use the new return type in PairsTradingAlphaModel.
2018-05-10 16:18:07 +01:00
AlexCatarino 62adc3a24b Changes Insight.Group return type to IEnumerable<Insight> from Guid 2018-05-09 14:49:00 +01:00
Michael 22711ad346 Merge pull request #1910 from QuantConnect/feature-1901-universe-data-on-security
Make universe data accessible via security object
Use security.Fundamentals to access coarse/fine data directly from the security object
2018-04-25 16:06:54 -04:00
AlexCatarino 9c4b85b693 Adds python version of PairsTradingAlphaModel 2018-04-25 13:45:13 +01:00
Michael Handschuh a5179bc6ab Add universe data to TimeSlice
Pipes universe data from the data feed, through TimeSlice.Create and adds
TimeSlice.UniverseData dictionary property for read access from the algo
manager, where the data will be placed onto the correct security object.
2018-04-24 18:23:00 -04:00
Michael Handschuh 2e0111b858 Handle null group-id in FromSerializedInsight
Also updates the insight serialization tests to exercse the null
group-id case to prevent future regressions.
2018-04-23 13:26:41 -04:00
Michael Handschuh c1c741f55f Remove canonical symbols from manual universe model
This happens when users pass Securities.Keys into the manual model,
causing the SecurityChanges object to have references to the canonical
securities, thereby leading to indicators and other things being
done to them unknowningly.
2018-04-20 09:32:22 -04:00
Michael Handschuh 38d749caa4 Add PairsTradingAlphaModel w/ regression test
The PairsTradingAlphaModel is a simple example of defining an insight
grouping. Insights that are grouped together are assigned a unique
group-id that can be used by the portfolio construction model.

Updates were made to the CommonAlphaModelTests to give more control to
derived types. Some changes are still needed here to give securities
unique prices. I would recommend using a psuedo-random walk approach
by using Random with a constant seed value.
2018-04-19 16:30:20 -04:00
Michael Handschuh 5f33d61220 Add Insight.GroupId and Insight.Group( insights )
Provides a means of grouping insights together.
This new value is serialized as 'group-id'.
2018-04-19 12:47:08 -04:00
Michael Handschuh 90d54da87c Add INamedModel and implement in existing alpha models
Alpha models can choose to implement the Name property, if not, the system
will use the model's type name as the Insight.SourceModel.
Existing tests were updated to also assert expected model names
2018-04-17 16:50:16 -04:00
Michael Handschuh c3c6a9aff8 Add Insight.SourceModel
This identifier is used to determine the alpha model that generated.
This is NOT ideal, since it requires users to specify the value, more
thought will be givent to how we can resolve this value automatically

Adds test for surviving roundtrip copy operation.
2018-04-17 16:36:47 -04:00
AlexCatarino 58493a2f21 Updates python version Lean AlphaModels to reflect API changes
Refactors unit tests.
2018-04-11 11:16:04 +01:00
AlexCatarino 191d92b7ea Adds python version of RsiAlphaModel 2018-04-11 11:07:51 +01:00
AlexCatarino 2bfa5dfc28 Implements a framework to perform unit tests of alpha models 2018-04-11 11:07:51 +01:00
AlexCatarino bf1aa7fa4c Implements Insight.Price helper method.
Implements `Insight.Price` method to make it easier to create new instances of `Insight` of `InsightType.Price`.
Standardize the parameter order to `Symbol`, `TimeSpan`, `InsightType`, `InsightDirection`, `Double`, `Double`.
2018-04-10 19:49:29 +01:00