Hi,
I am using custom data in Python. It loads fine and I get it in my algo's OnData.
However, what OnData gets in the slice is of type “class converter.Data”. When I feed that to the existing Heikin Ashi indicator's Update method in QC (class "HeikinAshi"), I get a runtime TypeError because no Update method on HeikinAshi can get converter.Data as a param. HeikinAshi takes its Update methods from IndicatorBase. And it simply needs an IBaseData. So, converter.Data is not an IBaseData? But my custom data class inherits from PythonData, which is an IBaseData. So I am confused…
How can I use/convert custom data bars as/to IBaseData?
Thanks!
Fred
Fred Painchaud
Ok, another one I finally find the answer…
The problem was that custom data is not TradeBar because custom data (PythonData) is not IBaseDataBar, it is “only” IBaseData, which makes a lot of sense (custom data can be anything, it does not HAVE to be OHLCV). So I first tried to make my custom data class inherit from IBaseDataBar and PythonData but multiple inheritance is not supported by Python.NET from managed (C#) classes. The solution is simple:
Make a standard custom data class (inherit from PythonData) and then in OnData, when you get your custom data slice, use the OHLCV data you have in there to simply create a TradeBar(…) from it and pass it to indicators that need TradeBar data and not just any data (like HeikinAshi).
Cheers,
Fred
Fred Painchaud
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!