In honor of cryptos now available through GDAX I have been working on pulling together some examples to work with BTCUSD. I've incorporated data warmup with an EMA crossover to enable trading from day 2. I am running into an error when I launch as a paper trade live algo. Any advice or collaboration would be helpful, thank you.
Liquidgenius
Stack Trace:
Failed to initialize algorithm: Python.Runtime.PythonException: KeyError : 'the label [BTCUSD] is not in the [index]' at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00033] in <69d4fd635645431aa1e955e701040fd1>:0 at Python.Runtime.PyObject.InvokeMethod (System.String name, Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00007] in <69d4fd635645431aa1e955e701040fd1>:0 at Python.Runtime.PyObject.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x0003e] in <69d4fd635645431aa1e955e701040fd1>:0 at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0] (System.Runtime.CompilerServices.CallSite site, T0 arg0) [0x000fa] in <7c7d16af841f44d5a362340966c7fd69>:0 at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Initialize () [0x00045] in <7101905a108e4b428867436ae928d145>:0 at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler+<>c__DisplayClass24_0.b__1 () [0x000e5] in <31cdedea27904959b7e4bb9b6a9b9aae>:0 (Open Stacktrace)
Also, it appears that the line numbers are all set to 0, is this an error?
Andrew Hart
Hey liquidgenius - The problem is not your code but rather a bug in the way we handled crypto history requests. We have corrected the bug. I cloned your algo and it's running as expected in Backtesting and Live. Thanks for posting!
Todd Blacksher
Hey @Andrew Hart, I was using a variation of what @Liquidgenius created in this thread. It was working fine yesterday but today, it results in the error that he initially reported. Has there been a change that would cause this?
Todd Blacksher
My change used Resolution.Hour vs. Liquidgenius's Resolution.Daily. Could this be causing it?
Alexandre Catarino
Todd Blacksher , please checkout attached backtest. I have only made the following change:
self.AddCrypto("BTCUSD", Resolution.Hour) # self.AddCrypto("BTCUSD", Resolution.Daily)
and coundn't reproduce the issue.
This runtime error is due to a history request that has returned an empty dataframe:
history = self.History(["BTCUSD"], slow_period + 1) if history.empty: self.Log("EMPTY dataframe!")
Todd Blacksher
That is what is weird Alexandre Catarino, I cant reproduce the issue either until I attempt to take live. I have submitted a support ticket, so you should be able to now view the full algorithm.
Liquidgenius
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!