I am trying to get the optional Insight values (Confidence, Magnitude, Weight) in the PortfolioConstructionModel. The values don't seem to be in the activeInsights objects that are passed to DetermineTargetPercent. The Direction and SourceModel values are correct but the others are all None.
I created a new PCM inherited from the main PCM:
class ETFPortfolioConstructionModel(PortfolioConstructionModel)
def DetermineTargetPercent(self, activeInsights):
for x in activeInsights:
The Confidence value was passed in the Insight created in an Alpha:
insights.append(Insight.Price(
firing.symbolData.symbol, parent.predictionInterval,
firing.direction,
confidence=firing.confidence,
magnitude=firing.magnitude,
sourceModel="Sentiment"))
The x.Direction and x.SourceModel are correct but x.Confidence, x.Magnitude, x.Weight = None
The Insight data doesn't seem to get to the PCM. Is there some other way I should be setting or accessing those values?
Steve Baunach
Solution is to use positional function parameters instead of named parameters. It seems that named function parameters might not have been implemented in the python wrapper?
It works properly when I replaced named parameter Insight creation with:
insights.append(Insight(
firing.symbolData.symbol, parent.predictionInterval,
InsightType.Price,
firing.direction,
firing.magnitude,
firing.confidence,
"Sentiment", # Source Model
firing.weight))
Shile Wen
Hi Steve,
You are correct in that it needs to use positional args for it to work. The reason for this is because Lean does not support named args at the moment.
Best,
Shile Wen
Steve Baunach
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!