Provides a base class for portfolio construction models
More...
|
void | SetPythonWrapper (PortfolioConstructionModelPythonWrapper pythonWrapper) |
| Used to set the PortfolioConstructionModelPythonWrapper instance if any More...
|
|
virtual List< Insight > | GetTargetInsights () |
| Gets the target insights to calculate a portfolio target percent for More...
|
|
virtual bool | ShouldCreateTargetForInsight (Insight insight) |
| Method that will determine if the portfolio construction model should create a target for this insight More...
|
|
virtual Dictionary< Insight, double > | DetermineTargetPercent (List< Insight > activeInsights) |
| Will determine the target percent for each insight More...
|
|
void | SetRebalancingFunc (PyObject rebalance) |
| Python helper method to set the rebalancing function. This is required due to a python net limitation not being able to use the base type constructor, and also because when python algorithms use C# portfolio construction models, it can't convert python methods into func nor resolve the correct constructor for the date rules, timespan parameter. For performance we prefer python algorithms using the C# implementation More...
|
|
virtual bool | IsRebalanceDue (Insight[] insights, DateTime algorithmUtc) |
| Determines if the portfolio should be rebalanced base on the provided rebalancing func, if any security change have been taken place or if an insight has expired or a new insight arrived If the rebalancing function has not been provided will return true. More...
|
|
void | RefreshRebalance (DateTime algorithmUtc) |
| Refresh the next rebalance time and clears the security changes flag More...
|
|
|
PortfolioConstructionModelPythonWrapper | PythonWrapper |
| This is required due to a limitation in PythonNet to resolved overriden methods. When Python calls a C# method that calls a method that's overriden in python it won't run the python implementation unless the call is performed through python too. More...
|
|
Provides a base class for portfolio construction models
Definition at line 30 of file PortfolioConstructionModel.cs.
◆ PortfolioConstructionModel() [1/2]
QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.PortfolioConstructionModel |
( |
Func< DateTime, DateTime?> |
rebalancingFunc | ) |
|
Initialize a new instance of PortfolioConstructionModel
- Parameters
-
rebalancingFunc | For a given algorithm UTC DateTime returns the next expected rebalance time or null if unknown, in which case the function will be called again in the next loop. Returning current time will trigger rebalance. If null will be ignored |
Definition at line 64 of file PortfolioConstructionModel.cs.
◆ PortfolioConstructionModel() [2/2]
QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.PortfolioConstructionModel |
( |
Func< DateTime, DateTime > |
rebalancingFunc = null | ) |
|
Initialize a new instance of PortfolioConstructionModel
- Parameters
-
rebalancingFunc | For a given algorithm UTC DateTime returns the next expected rebalance UTC time. Returning current time will trigger rebalance. If null will be ignored |
Definition at line 74 of file PortfolioConstructionModel.cs.
◆ SetPythonWrapper()
◆ CreateTargets()
◆ OnSecuritiesChanged()
virtual void QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.OnSecuritiesChanged |
( |
QCAlgorithm |
algorithm, |
|
|
SecurityChanges |
changes |
|
) |
| |
|
virtual |
◆ GetTargetInsights()
virtual List<Insight> QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.GetTargetInsights |
( |
| ) |
|
|
protectedvirtual |
◆ ShouldCreateTargetForInsight()
virtual bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.ShouldCreateTargetForInsight |
( |
Insight |
insight | ) |
|
|
protectedvirtual |
◆ DetermineTargetPercent()
virtual Dictionary<Insight, double> QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.DetermineTargetPercent |
( |
List< Insight > |
activeInsights | ) |
|
|
protectedvirtual |
◆ SetRebalancingFunc()
void QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.SetRebalancingFunc |
( |
PyObject |
rebalance | ) |
|
|
protected |
Python helper method to set the rebalancing function. This is required due to a python net limitation not being able to use the base type constructor, and also because when python algorithms use C# portfolio construction models, it can't convert python methods into func nor resolve the correct constructor for the date rules, timespan parameter. For performance we prefer python algorithms using the C# implementation
- Parameters
-
rebalance | Rebalancing func or if a date rule, timedelta will be converted into func. For a given algorithm UTC DateTime the func returns the next expected rebalance time or null if unknown, in which case the function will be called again in the next loop. Returning current time will trigger rebalance. If null will be ignored |
Definition at line 211 of file PortfolioConstructionModel.cs.
◆ IsRebalanceDue()
virtual bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.IsRebalanceDue |
( |
Insight[] |
insights, |
|
|
DateTime |
algorithmUtc |
|
) |
| |
|
protectedvirtual |
◆ RefreshRebalance()
void QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.RefreshRebalance |
( |
DateTime |
algorithmUtc | ) |
|
|
protected |
◆ FilterInvalidInsightMagnitude()
static Insight [] QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.FilterInvalidInsightMagnitude |
( |
IAlgorithm |
algorithm, |
|
|
Insight[] |
insights |
|
) |
| |
|
staticprotected |
Helper class that can be used by the different IPortfolioConstructionModel implementations to filter Insight instances with an invalid Insight.Magnitude value based on the IAlgorithmSettings
- Parameters
-
algorithm | The algorithm instance |
insights | The insight collection to filter |
- Returns
- Returns a new array of insights removing invalid ones
Definition at line 311 of file PortfolioConstructionModel.cs.
◆ PythonWrapper
This is required due to a limitation in PythonNet to resolved overriden methods. When Python calls a C# method that calls a method that's overriden in python it won't run the python implementation unless the call is performed through python too.
Definition at line 56 of file PortfolioConstructionModel.cs.
◆ RebalanceOnSecurityChanges
virtual bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.RebalanceOnSecurityChanges = true |
|
getset |
◆ RebalanceOnInsightChanges
virtual bool QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.RebalanceOnInsightChanges = true |
|
getset |
◆ Algorithm
IAlgorithm QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.Algorithm |
|
getprotected |
The documentation for this class was generated from the following file: