Hi All,
I've been attempting to test a basic EMA crossover strategy for Crypto, but having had some strange backtests I dug into the results and it seems the crossover event occurs at UTC time but the orders are processed at Eastern. In effect it's as if the order is being placed four hours after the crossover occurred.
For example, the price for a Buy Order executed at the time of the crossover (07:57) actually matches the ask close price in the Historical Data at 11:57:
Market Order
Bitfinex XRP Data
I tried changing the Brokerage to GDAX, the Account Type to Cash and the Asset to ETHUSD but found the same issue. I also checked the algo using FX (specifically EURUSD through FXCM) and found no such issue, so it seems to be specifically related to Crypto. I limited the date range to a few days just to identify the cause of the unexpected results I had been seeing.
I'm fairly new to coding so please forgive the simplistic nature of the algorithm. I'm sure it's simply a case of something I haven't included or configured correctly so any guidance would be much appreciated.
Thanks
Varad Kabade
Hi Jason Gaituah,
The above algorithm places orders immediately, and they are filled immediately too. The difference occurs due to the difference in the time zone. The orders in the orders table are time stamped in est. When we make a History call with crypto, the DataFrame that's returned is timestamped in UTC (which is 4 hours ahead of EST).
Best,
Varad
Jason
Thanks Varad.
I guess the thing I'm struggling with is that not only is the order timestamp EST but the actual price used is EST rather than UTC.
So in the above example, the price as at crossover is about 1.295, which is the price I would expect on the order. But instead the price used for the order is 1.325 (I.e. the price four hours later). Any ideas how I can have orders executed at the price as at UTC time so as to be aligned with the crossover event which occurs at UTC.
Varad Kabade
Hi Jason Gaituah,
The orders are time stamped in EST in the Orders Tab. We have notified the UX Team since it should be timestamped in the algorithm time zone (UTC in this case). If we modify the OnOrder event handler to log when an order gets filled, we observe that the orders are filled as expected. Refer to the attached backtest for reference.
Best,
Varad Kabade
Jason
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!