Lean
$LEAN_TAG$
|
Provides an implementation of IPortfolioConstructionModel that wraps a PyObject object More...
Public Member Functions | |
PortfolioConstructionModelPythonWrapper (PyObject model) | |
Constructor for initialising the IPortfolioConstructionModel class with wrapped PyObject object More... | |
override IEnumerable< IPortfolioTarget > | CreateTargets (QCAlgorithm algorithm, Insight[] insights) |
Create portfolio targets from the specified insights More... | |
override void | OnSecuritiesChanged (QCAlgorithm algorithm, SecurityChanges changes) |
Event fired each time the we add/remove securities from the data feed More... | |
Public Member Functions inherited from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel | |
PortfolioConstructionModel (Func< DateTime, DateTime?> rebalancingFunc) | |
Initialize a new instance of PortfolioConstructionModel More... | |
PortfolioConstructionModel (Func< DateTime, DateTime > rebalancingFunc=null) | |
Initialize a new instance of PortfolioConstructionModel More... | |
Protected Member Functions | |
override bool | ShouldCreateTargetForInsight (Insight insight) |
Method that will determine if the portfolio construction model should create a target for this insight More... | |
override 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... | |
override List< Insight > | GetTargetInsights () |
Gets the target insights to calculate a portfolio target percent for More... | |
override Dictionary< Insight, double > | DetermineTargetPercent (List< Insight > activeInsights) |
Will determine 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... | |
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... | |
void | RefreshRebalance (DateTime algorithmUtc) |
Refresh the next rebalance time and clears the security changes flag More... | |
Properties | |
override bool | RebalanceOnSecurityChanges [get, set] |
True if should rebalance portfolio on security changes. True by default More... | |
override bool | RebalanceOnInsightChanges [get, set] |
True if should rebalance portfolio on new insights or expiration of insights. True by default 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... | |
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... | |
Protected Attributes inherited from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel | |
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 an implementation of IPortfolioConstructionModel that wraps a PyObject object
Definition at line 28 of file PortfolioConstructionModelPythonWrapper.cs.
QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModelPythonWrapper.PortfolioConstructionModelPythonWrapper | ( | PyObject | model | ) |
Constructor for initialising the IPortfolioConstructionModel class with wrapped PyObject object
model | Model defining how to build a portfolio from alphas |
Definition at line 67 of file PortfolioConstructionModelPythonWrapper.cs.
|
virtual |
Create portfolio targets from the specified insights
algorithm | The algorithm instance |
insights | The insights to create portfolio targets from |
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 92 of file PortfolioConstructionModelPythonWrapper.cs.
|
virtual |
Event fired each time the we add/remove securities from the data feed
algorithm | The algorithm instance that experienced the change in securities |
changes | The security additions and removals from the algorithm |
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 102 of file PortfolioConstructionModelPythonWrapper.cs.
|
protectedvirtual |
Method that will determine if the portfolio construction model should create a target for this insight
insight | The insight to create a target for |
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 113 of file PortfolioConstructionModelPythonWrapper.cs.
|
protectedvirtual |
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.
insights | The insights to create portfolio targets from |
algorithmUtc | The current algorithm UTC time |
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 126 of file PortfolioConstructionModelPythonWrapper.cs.
|
protectedvirtual |
Gets the target insights to calculate a portfolio target percent for
Reimplemented from QuantConnect.Algorithm.Framework.Portfolio.PortfolioConstructionModel.
Definition at line 135 of file PortfolioConstructionModelPythonWrapper.cs.
|
protectedvirtual |
Will determine 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 145 of file PortfolioConstructionModelPythonWrapper.cs.
|
getset |
True if should rebalance portfolio on security changes. True by default
Definition at line 37 of file PortfolioConstructionModelPythonWrapper.cs.
|
getset |
True if should rebalance portfolio on new insights or expiration of insights. True by default
Definition at line 52 of file PortfolioConstructionModelPythonWrapper.cs.