Quick question in regards to best practices...I see a lot of examples on creating Alphas using data (EMA Cross, other indicators, etc.). Is it possible to do a Risk Management Model based on a EMA cross strategy (say an index)?
Or would this not be possible because we need access to the "data" property in the Update() method of the Alpha vs the "targets" property in ManageRisk() method of the RiskManagementModel?
Rahul Chowdhury
Hey John,
The data in Update represents the latest slice data available to the algorithm. We can access the latest slice object anywhere we have a reference to the algorithm.
data = algorithm.CurrentSlice
Within the risk management model, the ManageRisk method provides the algorithm and the portfolio targets as parameters. This means we can use the slice data as a part of our risk management calculations. To use an EMA, we can declare a "blank" ExponentialMovingAverage indicator and then update it with data from the algorithm.
class MyRiskManagementClass: def __init__(self): self.ema = ExponentialMovingAverage(10) def ManageRisk(self, algorithm, targets): if algorithm.CurrentSlice.ContainsKey("SPY"): spy_close = algorithm.CurrentSlice["SPY"].Close self.ema.Update(algorithm.Time, spy_close)
I suggest checking out some of the built-in risk management models as examples. Here is MaximumSectorExposureRiskManagementModel.
Best
Rahul
John Radosta
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!