Commit Graph

309 Commits

Author SHA1 Message Date
Martin Molinero c73b7bb62f Adding smarter methods for PortfolioTargetCollection 2018-07-27 10:48:55 -03: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 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
AlexCatarino b0d1606118 Refactors portfolio construction models with portfolio optimization
- Creates `MinimumVariancePortfolioOptimizer` and `MaximumSharpeRatioPortfolioOptimizer` portfolio optimizer. They implement `Optimize` method that returns a array of float representing the portfolio weights.
- Refactors `BlackLittermanOptimizationPortfolioConstructionModel` and `MeanVarianceOptimizationPortfolioConstructionModel` to use the portfolio optimizers. Part of the logic in BLOPC was changed to match the MVOPC one.
- Adds `BlackLittermanPortfolioOptimizationFrameworkAlgorithm` similar to `MeanVarianceOptimizationFrameworkAlgorithm` that uses BLOPC.
2018-07-20 23:09:48 +01:00
AlexCatarino ada48acfde Implements IPortfolioOptimizer interface
Provides an interface to portfolio optimization algorithms that can be used in portfolio construction models.
2018-07-20 22:28:42 +01:00
AlexCatarino 3252b60b39 Fixs typo in EqualWeightingPortfolioConstructionModel.py 2018-07-19 16:38:26 +01:00
AlexCatarino cfcc387f7f Fixes Div by Zero exceptions in framework models 2018-07-19 15:05:05 +01:00
David d7fc6ead84 Fixed missing override from HistoricalReturnsAlphaModel 2018-07-18 22:20:37 +01:00
AlexCatarino 8e3b7153b2 Rebase with pythonnet/master and fix datetime UTC bug
Updates pythonnet with pythonnet/master and fix datetime issue ([65ac279](https://github.com/QuantConnect/pythonnet/commit/65ac279a03dbded39fe3e28bb79c233f0c970f6f)).
2018-07-16 11:52:54 +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
AlexCatarino 049fba334e Implements python version of OptionUniverseSelectionModel
Since `OptionUniverseSelectionModel` derives from `UniverseSelectionModel`, a python version of this class was also implemented.
2018-07-05 20:59:08 +01:00
AlexCatarino ac6564d4c5 Fixes UniverseSelectionModelPythonWrapper
- Typo in `GetNextRefreshTimeUtc` method.
- Logics bug in constructor.
2018-07-05 20:59:08 +01:00
Stefano Raggi 7a9fc44ccd Update Python regression tests to match C# equivalents 2018-07-02 23:50:51 +02:00
Stefano Raggi 7bc991a621 Update execution models to execute trades ordered by margin impact 2018-06-22 18:07:13 +02:00
Stefano Raggi aa989ceab7 Set the XML documentation setting in Algorithm.Framework project 2018-06-21 20:48:25 +02:00
Jing Wu f94710df6d Fix the bug of empty views from alpha models thorw the error 2018-06-19 16:59:39 -04:00
Stefano Raggi 2ff5650b4a Add price and split factors to CoarseFundamental class 2018-06-01 12:19:06 +02:00
Michael 04b99aa035 Merge pull request #2050 from QuantConnect/bug-ema-cross-resolution
Use EMA cross alpha model's resolution when creating the EMA indicators
2018-06-01 02:01:01 -04: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 65393d4e54 Replace config security with an option chain filter function
The ConfigureOptionChainSecurity method somewhat was overshadowing the security
initializer's responsibilities. This method has been trimmed down into a contract
filter function sub classes can use to define what option contracts they want to
select.
2018-06-01 00:36:17 -04:00
Michael Handschuh 398e4d5856 Refactor IUniverseSelectionModel.NextRefreshTime into method
Methods are much easier to manage in python that implementing properties.
2018-05-31 14:58:39 -04:00
Michael Handschuh 42032ec328 Refactor setting of insight close/generated times
These times were being set AFTER they were copied, so the insights sent into
the portfolio construction model were the originals (uncopied) and then copies
that are sent into the event are then piped to the insight manager/alpha handler
for scoring, so interestingly, the scoring remained the same so regression tests
continued to pass because no types were written with a dependency on that data
other than the scoring, which as mentioned, got the copies with the correct times.
A recent change made use of this time and showcases this heinous bug in all its
glory.

This refactoring overrides the event invocator and seals the method to force
derived types to use the event handler, thereby guaranteeing that the event is
always invoked AFTER the generated/close times are properly set, also ensuring
that the copy is performed after the times are set as well.
2018-05-31 14:25:16 -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 16a80ecbec Fixes CreateUniverses method modifier
`UniverseSelectionModelPythonWrapper.CreateUniverses` method modifier should be `override` instead of `virtual`, since that class inherit from `UniverseSelectionModel`.
2018-05-30 22:29:29 +01:00
Michael Handschuh d90dcc80c9 Use resolution in EmaCrossAlphaModel 2018-05-30 16:24:20 -04:00
Jared b808e57765 Merge pull request #2024 from AlexCatarino/bug-2023-fixes-equalweightingportfolioconstructionmodel
Fixes EqualWeightingPortfolioConstructionModel logic
2018-05-30 14:14:38 -04:00
AlexCatarino 5a648aea19 Adds single Insight overload to EmitInsights
This overload is necessary since pythonnnet doesn't handles well `params`.
2018-05-29 22:42:16 +01:00
AlexCatarino 31c32be7d4 Add python version of NullAlphaModel 2018-05-29 22:42:16 +01:00
Michael Handschuh e95157b097 Add QCAlgorithmFrameworkBridge for easier porting of QCAlgorithm
Provides demonstration algorithm showing the steps required to convert a
QCAlgorithm into the framework with minimal code changes.

1. Subclass QCAlgorithmFrameworkBridge
2. Add EmitInsights calls to where orders are placed
3. Profit :)
2018-05-29 22:42:16 +01:00
Michael Handschuh 73e7685e3a Move insight time stamping to event handler
This is to enable proper scoring of ported algorithms to framework
2018-05-29 22:41:06 +01:00
Michael Handschuh af80420afa Add NullAlphaModel 2018-05-29 22:41:06 +01:00
AlexCatarino 617341b01f Do not consider expired insights 2018-05-28 12:47:06 +01:00
AlexCatarino 595700e340 Fixes EqualWeightingPortfolioConstructionModel logic
`EqualEeightingPortfolioConstructionModel` (C# and Python) allocates all cash to the stocks who have insights in universe.
- Fixes regression tests to reflect the model logic change
- Fixes imports in python algorithms to use python models when available
2018-05-28 12:47:06 +01:00
AlexCatarino 7bffd60c2d Minor framework fixes
- `NullExecutionModel.py`: return array instead of void
- `NullRiskManagementModel.cs`: inherit from base class instead of interface
2018-05-16 13:37:38 +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
AlexCatarino ab59c6970a Python portfolio construction models subclass C# PortfolioConstructionModel 2018-05-15 20:53:12 +01:00
AlexCatarino 97d6420e2a Python risk management models subclass C# RiskManagementModel
- Adds python version of `NullRiskManagementModel`
2018-05-15 20:52:13 +01:00
AlexCatarino 4ad1b5bd8a Python execution models subclass C# ExecutionModel
- Adds python version of `NullExecutionModel`
2018-05-15 20:48:13 +01:00
AlexCatarino efb75a9e30 Implements python version of NullPortfolioConstructionModel 2018-05-15 12:13:41 +01:00
Michael 8534df4e20 Merge pull request #1979 from AlexCatarino/feature-1961-python-qc500
Implements python version of QC500UniverseSelectionModel
2018-05-11 14:47:09 -04:00
Michael Handschuh 2bb99a595b Add base class for risk management models
Update existing models to derive from new base class
2018-05-11 01:55:16 -04:00
Michael Handschuh fc9380bcd8 Add base class for execution models
Update existing models to derive from new base class
2018-05-11 01:50:45 -04:00
Michael Handschuh 2c0f9a580a Add base class for portoflio construction models
Update existing models to derive from new base class
2018-05-11 01:50:45 -04:00