I worte a Custom Alpha Model which takes a Minute Resolution data for BTCUSD. I am consolidating the data to 30 minutes in the Alpha Model as per the documentation and the various discussion threads. But the orders and insights are being generated at Minute Resolution instead of 30 minutes. I tried various things, but to no avail since three weeks. Can you please help and debug this? I am at a loss to explain what is happening and is stopping me from progressing further using the QC Algorithmic Framework
Shile Wen
Hi Sai,
This reason the algorithm trades every minute is because Update is on minute resolution, because only the specified consolidation function is executed on the consolidated time period.To fix this, we can choose to only emit insights if our desired direction changes (which will only occur if our indicator values change) from the previous direction (.PreviousDirection of SymbolData). I've shown how to do this in the attached backtest.
Best,
Shile Wen
Sai Panyam
Hi Shile,
Thanks for this. I still have an issue where i want my indicator values to be calculated for every 30 mins. Also i tried using previousdirection. But i get only 4 indight counts. Which is not correct. It cannot be that after only 8 trades in 2017, there are no other trades.Â
Is it possible to fire update every 30 mins instead? Also can i trade irrespective of previous direction. For e..g. for every 30mins, my alpha model should emit a Insight: Up, Down or Flat.Â
Shile Wen
Hi Sai,The indicator values are using 30-minute bars for the calculations already with these following lines of code (106-109):
self.thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=30)) self.thirtyMinuteConsolidator.DataConsolidated += self.OnThirtyMinuteBarHandler algorithm.SubscriptionManager.AddConsolidator(security.Symbol, self.thirtyMinuteConsolidator) algorithm.RegisterIndicator(security.Symbol, self.ichimoku, self.thirtyMinuteConsolidator)
As for how to make it emit insights every 30 minutes, including the flat direction, we first need to remove this line: if direction != InsightDirection.Flat:. Then, we can choose to emit insights every 30 minutes with the following if statement: if algorithm.Time.minute % 30 == 0:. I’ve shown the necessary changes in the attached backtest.
Best,
Shile Wen
Sai Panyam
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!