Can LEAN interpret my own OHLCV crypto data (implemented as custom PythonData) as currencies instead of normal shares?
As things stand now, the cashbook does not accurately reflect currency balances. I.e. if I buy BTC/USD, I should have BTC to buy X/BTC, but LEAN treats BTC/USD as a virtual asset, not a currency. Put another way, instead of owning the asset BTC/USD, I need BTC to show up as a currency in my portfolio cashbook.
My first bet was on changing the ‘type’ of the data in the symbol properties database, but that didn't work out. Any workarounds?
Alexandre Catarino
Hi tdrxy ,
Thank you for your patience.
The Crypto (and Forex) security type is modeled differently from Equity because of the cashbook component. This security type implements the concept of base currency (the base currency of BTCUSD is BTC while USD is the quote currency) that a custom data type does not have. The Lean engine will check the SecutityType (SecurityType.Base for custom data) for operations that involve the base currency.
QuantConnect provides cryptocurrency data, free of charge, in QuantConnect Cloud, so why do you want to create custom data for it?
Best regards,
Alex
Tdrxy
Hi,
Thanks for getting back Alexandre Catarino. We have a specific use case where we deal with very niche pairs not available in the sources QC provides sadly.
Is there any way to trick the engine to use our data as a crypto/fx sec type?
Cheers!
Louis Szeto
Hi Tdrxy
One hack would be using a SymbolObject to reference the “currency in hand”:
Best
Louis
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.
Tdrxy
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!