Back

Live Crypto History Data

When attempting to go live with my simple algorithm, I'm getting errors - how can I load history from a specific time period only than and to avoid this error? My indicators only really need a few weeks of back data to work.

Here was the initial error that I had received from the history command

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  ...etc etc

Here is the code that is attempting to call the history

history = self.History(dataset, 19, Resolution.Minute)

        # Populate warmup data
        for index, row in history.loc["BTCUSD"].iterrows():
           self.fast_btc.Update(index, row["close"])
           self.slow_btc.Update(index, row["close"])

How can I set the StartDate for the History command to 2017 and not have empty history dataframes?

Update Backtest








"How can I set the StartDate for the History command to 2017 and not have empty history dataframes?"

If you click the 'API' tab in the Algorithm Lab and search 'History' you'll see the following entry included in the results:

self.History(tickers, start, end, resolution)

With the description: "Gets the historical data for the specified symbol between the specified dates. *The symbol must exist in the Securities collection.*" 

There are several different ways to call history - this one will let you specify a specific start and end date.

0

Andrew Hart  Thanks so much! I had no idea about the API tab, wow that opens up a whole new world to me :) That will answer a lot of questions for me, I had been trying to look at the "documentation" and it was incredibly limited but the API tab is amazing.

0

Update Backtest





0

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.


Loading...

This discussion is closed