Commit Graph

396 Commits

Author SHA1 Message Date
AlexCatarino b476e22e41 Implements EmaCrossUniverseSelectionModel
Adds EmaCrossUniverseSelectionModel and EmaCrossUniverseSelectionFrameworkAlgorithm to show the new model in action
2018-05-08 18:54:17 +01:00
Jing Wu 0b7d73eeff fix if statement bug 2018-05-08 10:13:59 -04:00
Jing Wu dff04a824e fix for loop bug 2018-05-07 17:55:25 -04:00
Jing Wu 198a618303 accomodate the history request to csharp convention 2018-05-07 17:39:42 -04:00
Jing Wu cd5944faae revert change 2018-05-07 16:40:40 -04:00
Jing Wu 6b7857226e modify properties in project file 2018-05-07 16:34:49 -04:00
Jing Wu faa4e4a678 add copyright labels 2018-05-07 16:33:45 -04:00
Jing Wu 72e2b38f19 revert change 2018-05-07 16:30:48 -04:00
Jing Wu 33250b8c70 add HistoricalReturnsAlphaModel 2018-05-07 16:25:47 -04:00
Michael Handschuh d3d331f100 Make risk management models overrideable 2018-05-07 16:14:13 -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
Michael Handschuh 1e2e9cf11e Make portfolio construction models overrideable 2018-05-07 16:13:10 -04:00
Michael Handschuh 0b2344f930 Make alpha models overrideable 2018-05-07 16:13:10 -04:00
Michael Handschuh 353e62c6e9 Make universe selection models overrideable 2018-05-07 16:13:07 -04:00
AlexCatarino 6250ed900e Use UniverseManager.ActiveSecurities instead of Securities
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).
2018-05-03 22:02:08 +01:00
AlexCatarino 182e8b46ad Implements MaximumSectorExposureRiskManagementModel
Provides an implementation of `IRiskManagementModel` that limits the sector exposure to the specified percentage
2018-05-03 21:50:11 +01:00
AlexCatarino 7f2902eee2 Implements python version of EqualWeightingPortfolioConstructionModel 2018-05-03 21:50:11 +01:00
AlexCatarino 6e1d113922 Minor models fixes
- ConstantAlphaModel.py: sets default value `None` for magnitude and confidence
- BlackLittermanPortfolioConstructionModel.py: removes logging.
2018-05-03 21:50:11 +01:00
Michael Handschuh 441bd9a233 Add algorithm.framework nuspec file 2018-04-30 16:23:32 -04:00
AlexCatarino 11489b3edf Modifies BasicTemplateFrameworkAlgorithm
- Use `MaximumDrawdownPercentPerSecurity` as `RiskManagementModel`.
- Modifies regression test to reflect risk model choice
- Use SetXXX to set models in python version
2018-04-27 23:08:53 +01:00
AlexCatarino d81de45772 Implements python version of MaximumDrawdownPercentPerSecurity. 2018-04-27 22:29:10 +01:00
AlexCatarino fd461ed252 Refactors python framework models to avoid using generator
We are not using python lists instead of generator (yield) because we get better exception information in this case. The aim is to lead users to avoid using generators and/or know its limitations.
2018-04-26 19:31:11 +01:00
AlexCatarino 264da8a596 Calls python destructor to trigger exceptions
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.
2018-04-26 18:46:33 +01:00
Michael 5865535619 Merge pull request #1913 from jingwu74/master
Add Black-Litterman portfolio construction model
2018-04-25 16:04:09 -04:00
Jing Wu 63b05c9ec8 fix typo 2018-04-25 11:35:10 -04:00
Jing Wu 8b80e68283 add PreserveNewest property to project file 2018-04-25 11:06:26 -04:00
Jing Wu 7403853ff6 revert change in project file 2018-04-25 09:41:52 -04:00
Jing Wu 4d649447e7 add black litterman portfolio construction model 2018-04-25 09:34:48 -04:00
AlexCatarino 9c4b85b693 Adds python version of PairsTradingAlphaModel 2018-04-25 13:45:13 +01:00
Michael Handschuh 0ddc160028 Fix ManualUniverseSelectionModel w/ custom data present
We add entries for custom data w/ symbol references, so the generic look
up being performed here never resolves and throws an exception. With
custom data we add the entry manually and that same pattern has been
repeated here for consistency.
2018-04-20 17:37:39 -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 1b7dec7a40 Merge pull request #1891 from QuantConnect/feature-1863-grouped-insights
Add Insight.GroupId to support grouping of insights
2018-04-20 09:31:55 -04:00
AlexCatarino c3ac0392b7 Removes logging in python version of MacdAlphaModel 2018-04-19 22:09:17 +01: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 0c8119de8a Merge pull request #1889 from AlexCatarino/feature-1884-python-execution-models
Adds python version of execution model examples
2018-04-19 13:24:27 -04:00
AlexCatarino f3135b118e Adds Name attribute to python alpha models
These `Name` values match those in C# alpha models.
2018-04-19 18:04:01 +01: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
AlexCatarino 95d8bee73e Adds constructor overload to CompositeAlphaModel that accepts python objects 2018-04-19 11:29:15 +01:00
AlexCatarino 7c6cc4e1dd Refactors AlphaModelPythonWrapper.Name
The cleanest way to get a python type name, when we know it is an instance of a class, is getting the value of the  `__class__.__name__` attribute.

- Changes `CommonAlphaModelTests.ModelNameTest`:
  Since it requires some string manipulation to have the exact model name for C# and Python, we don't define `Name` in the python models and accept the default value from `AlphaModelPythonWrapper.Name`.
2018-04-19 11:28:06 +01:00
AlexCatarino dc273f3da9 Fixes RsiAlphaModel.py typo
In the static method `Insight.Price`, `.Price` was missing.
2018-04-18 20:12:52 +01:00
Michael Handschuh 1b8a5846a7 Fix risk adjusted targets debug logging
This was always logging, even when the risk model wasn't overriding
any of the targets. The new check checks to see if the risk model
created any override targets, and if so, we'll print all of the
targets as they will be submitted to the execution model.
2018-04-18 10:36:15 -04:00
Michael Handschuh f47c700746 Add CompositeAlphaModel
The composite model combines multiple alpha models into a singular model and
properly sets each insight's SourceModel property to the name of the model that
generated the insight
2018-04-17 16:50:24 -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 df698d1925 Adds constructor overloads with PyObject parameter to UniverseSelectionModel
The PyObject parameter is converted into selector function of `Func<T1,T2>` type so that the model can user universe selector methods defined in python algorithms.
2018-04-12 17:09:03 +01:00
Jared 258cb60d93 Merge pull request #1805 from AlexCatarino/feature-1798-python-alpha-models
Adds python versions of available Alpha Models
2018-04-11 14:22:53 -04:00
Jared c8ce15c749 Fix missing constructor arg 2018-04-11 14:07:26 -04:00
AlexCatarino f437db8833 Fixes C# MacdAlphaModel
MACD was created with a helper method and registered for automatic updates, where we should use the constructor.
2018-04-11 11:17:44 +01:00
AlexCatarino 58493a2f21 Updates python version Lean AlphaModels to reflect API changes
Refactors unit tests.
2018-04-11 11:16:04 +01:00