Lean
$LEAN_TAG$
|
Provides an implementation of IPortfolioConstructionModel that allocates percent of account to each insight, defaulting to 3%. For insights of direction InsightDirection.Up, long targets are returned and for insights of direction InsightDirection.Down, short targets are returned. By default, no rebalancing shall be done. Rules: More...
Protected Member Functions | |
override List< Insight > | GetTargetInsights () |
Gets the target insights to calculate a portfolio target percent for More... | |
override Dictionary< Insight, double > | DetermineTargetPercent (List< Insight > activeInsights) |
Determines the target percent for each insight More... | |
Protected Member Functions inherited from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel | |
void | SetPythonWrapper (PortfolioConstructionModelPythonWrapper pythonWrapper) |
Used to set the PortfolioConstructionModelPythonWrapper instance if any More... | |
virtual bool | ShouldCreateTargetForInsight (Insight insight) |
Method that will determine if the portfolio construction model should create a target for this 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... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel | |
static Insight[] | FilterInvalidInsightMagnitude (IAlgorithm algorithm, Insight[] insights) |
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 More... | |
Properties inherited from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel | |
virtual bool | RebalanceOnSecurityChanges = true [get, set] |
True if should rebalance portfolio on security changes. True by default More... | |
virtual bool | RebalanceOnInsightChanges = true [get, set] |
True if should rebalance portfolio on new insights or expiration of insights. True by default More... | |
IAlgorithm | Algorithm [get] |
The algorithm instance More... | |
PortfolioConstructionModelPythonWrapper | PythonWrapper [get, set] |
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 an implementation of IPortfolioConstructionModel that allocates percent of account to each insight, defaulting to 3%. For insights of direction InsightDirection.Up, long targets are returned and for insights of direction InsightDirection.Down, short targets are returned. By default, no rebalancing shall be done. Rules:
Definition at line 37 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | IDateRule | rebalancingDateRules, |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
rebalancingDateRules | The date rules used to define the next expected rebalance time in UTC |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 51 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | Func< DateTime, DateTime?> | rebalancingFunc = null , |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
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 |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 68 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | Func< DateTime, DateTime > | rebalancingFunc, |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
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 |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 86 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | PyObject | rebalance, |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
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 |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
This is required since python net can not convert python methods into func nor resolve the correct constructor for the date rules parameter. For performance we prefer python algorithms using the C# implementation
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 109 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | TimeSpan | timeSpan, |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
timeSpan | Rebalancing frequency |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 127 of file AccumulativeInsightPortfolioConstructionModel.cs.
QuantConnect.Algorithm.Framework.Portfolio.AccumulativeInsightPortfolioConstructionModel.AccumulativeInsightPortfolioConstructionModel | ( | Resolution | resolution, |
PortfolioBias | portfolioBias = PortfolioBias.LongShort , |
||
double | percent = 0.03 |
||
) |
Initialize a new instance of AccumulativeInsightPortfolioConstructionModel
resolution | Rebalancing frequency |
portfolioBias | Specifies the bias of the portfolio (Short, Long/Short, Long) |
percent | The percentage amount of the portfolio value to allocate to a single insight. The value of percent should be in the range [0,1]. The default value is 0.03. |
Definition at line 142 of file AccumulativeInsightPortfolioConstructionModel.cs.
|
protectedvirtual |
Gets the target insights to calculate a portfolio target percent for
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 153 of file AccumulativeInsightPortfolioConstructionModel.cs.
|
protectedvirtual |
Determines the target percent for each insight
activeInsights | The active insights to generate a target for |
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 165 of file AccumulativeInsightPortfolioConstructionModel.cs.