Commit Graph

79 Commits

Author SHA1 Message Date
Stefano Raggi d3f5e115e0 Add missing Invariant usages in alpha models and unit tests 2019-10-01 11:00:04 +02:00
Martin Molinero 1983f36792 Allow Python selection to return unchanged
- We will now check if python selection method returned `Universe.Unchanged`
- Removing `ToList()` call on fine and coarse data before sending it to
the python algorithm
- Adding regression algorithms
2019-07-31 15:36:07 -03:00
Martin Molinero e322381dfa ConstantAlphaModel check Security.Price 2019-07-29 22:41:14 -03:00
Martin Molinero 968adcea32 Adding InsightWeightingPortfolioConstructionModel
- Adding new `InsightWeightingPortfolioConstructionModel` that will
generate percent `Targets` based on the latest active `Insight` `Weight` per
`Symbol`.
   - Will ignore `Insights` that have no `Weight`.
   - If the sum of all the last active `Insight` per `Symbol` is bigger than 1, it
will factor down each target percent holdings proportionally so the sum is 1.
- Adding unit tests
- Adding a new regression test framework algorithm
- Note most of the code, including tests, are reused from the
`EqualWeightingPortfolioConstructionModel`
2019-04-24 11:05:14 -03:00
Martin Molinero 9cabd32d19 Add AddAlphaModel method 2019-04-04 13:36:07 -03:00
Martin Molinero cfa08a11fb Address reviews
- 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.
2019-04-03 21:55:44 -03:00
Martin Molinero 19f1806ddc Address review: readd Framework project 2019-04-03 21:55:43 -03:00
Martin Molinero 32ac3146b4 Merge Framework and Classic Algorithms
- Merging Framework and Bridge algorithms into classic QCAlgorithm
class.
- Removing Framework project, VS17 and VS15
2019-04-03 21:54:32 -03:00
Martin Molinero d9195317e3 C# decimal to Python conversion
- This commit is related to PR 19 in QC/pythonnet
   - C# decimal will be cast to C# double and converted into python
   float
- Adding new `decimal.py` into the python algorithm project. This is
required for backwards compatibility with users performing operations
over expected decimal types (like `Price`)
- Updating two python regression test algorithms using custom python
execution models to be aware and ignore floating point precision errors
when handling order sizing.
2019-01-15 12:13:42 -03:00
AlexCatarino 8c853543c0 Adds ContainsKey check in MacdAlphaModel
In `MacdAlphaModel.OnSecuritiesChanged`, a missing `ContainsKey` is not preventing a second key addition to a dictionary.

Closes #2656
2018-11-08 15:03:36 +00:00
Stefano Raggi 5c9b81cef1 Fix Python initialization and imports for multiple tests 2018-10-02 20:28:13 +02:00
AlexCatarino 340d1d81ff Adds key check after History requests in framework models …
`RsiAlphaModel` and `BlackLittermanOptimizationPortfolioConstructionModel` didn't have a key check after a history request. If a history request retuns no data for a given symbol, trying to access the pandas dataframe results in a `KeyError`.
2018-09-19 17:39:31 +01:00
AlexCatarino 8b8d2d2d6f Adds key check after History requests in framework models
`RsiAlphaModel` and `BlackLittermanOptimizationPortfolioConstructionModel` didn't have a key check after a history request. If a history request retuns no data for a given symbol, trying to access the pandas dataframe results in a `KeyError`.
2018-09-19 16:11:50 +01:00
AlexCatarino d4f67b212d Refactors RsiAlphaModel
The model was assuming that we could only add elements to the dictionary field if there was data in the history request which is not required.
2018-08-08 12:10:22 +01:00
AlexCatarino 48c87ffb93 Refactors RsiAlphaModel logic in OnSecuritiesChanged
The history request to warm up the RSI indicator is performed before it is created.
2018-08-07 20:53:17 +01:00
Stefano Raggi 089199dadf Fix Python version of RsiAlphaModel to be same as C# version 2018-08-03 20:37:50 +02:00
David d7fc6ead84 Fixed missing override from HistoricalReturnsAlphaModel 2018-07-18 22:20:37 +01:00
AlexCatarino 19502cc40b Adds support to multi asset type pairs
Securities from different types may have different timezones. In this case, daily resolution data is split in two slices in a history request, so these slices are grouped together to determined whether we have data from all the symbols in the same date.
2018-07-12 15:17:21 +01:00
AlexCatarino 009a136be3 Adds minimum correlation requiment to accept a candidate pair 2018-07-11 23:40:30 +01: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
Jing Wu 084cd294b0 Remove semicolon in python algrotihms 2018-07-06 11:05:16 -04:00
Stefano Raggi 7a9fc44ccd Update Python regression tests to match C# equivalents 2018-07-02 23:50:51 +02:00
Michael Handschuh d90dcc80c9 Use resolution in EmaCrossAlphaModel 2018-05-30 16:24:20 -04:00
AlexCatarino 31c32be7d4 Add python version of NullAlphaModel 2018-05-29 22:42:16 +01:00
Michael Handschuh af80420afa Add NullAlphaModel 2018-05-29 22:41:06 +01:00
AlexCatarino 86e85163d8 Python alpha models subclass C# AlphaModel 2018-05-15 22:29:34 +01:00
AlexCatarino 32b92a9738 Remove readonly property from AlphaModel.Name
If `AlphaModel.Name` is `readonly` python classes cannot inherit from `AlphaModel` and set `Name` is its constructor (`__init__`).
2018-05-15 22:29:17 +01:00
Michael Handschuh df41ec2a80 Add AlphaModel base class
Update existing models to derive from new base class
2018-05-11 01:50:45 -04:00
Michael Handschuh beb136062a Rename and move AlphaModel->AlphaModelExtensions
In preparation for AlphaModel default base class impl
2018-05-11 01:50:45 -04:00
Michael d5c89ab781 Merge pull request #1982 from AlexCatarino/feature-1981-changes-insight-group-method-return-type
Changes Insight.Group return type to IEnumerable<Insight> from Guid
2018-05-10 14:23:35 -04:00
Michael bb8c8e15a2 Merge pull request #1989 from AlexCatarino/feature-1988-standardize-compositealphamodel
Refactors CompositeAlphaModel constructors
2018-05-10 11:23:30 -04: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
Michael 0c7fc8c9b9 Merge pull request #1976 from jingwu74/master
Implements CSharp version of HistoricalReturnsAlphaModel
2018-05-10 10:39:28 -04:00
AlexCatarino 042028096b Refactors CompositeAlphaModel constructors
Changes the constructor that accepted an array to accept params array and adds a new constructor to deal with a single model addition.
2018-05-09 22:36:33 +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 faa4e4a678 add copyright labels 2018-05-07 16:33:45 -04:00
Jing Wu 33250b8c70 add HistoricalReturnsAlphaModel 2018-05-07 16:25:47 -04:00
Michael Handschuh 0b2344f930 Make alpha models overrideable 2018-05-07 16:13:10 -04: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
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
AlexCatarino 9c4b85b693 Adds python version of PairsTradingAlphaModel 2018-04-25 13:45:13 +01: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
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