Hi all,
the following notebook fails:
%matplotlib inline
# Imports
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Jupyter")
AddReference("QuantConnect.Indicators")
from System import *
from QuantConnect import *
from QuantConnect.Data.Custom import *
from QuantConnect.Data.Market import TradeBar, QuoteBar
from QuantConnect.Jupyter import *
from QuantConnect.Indicators import *
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
import pandas as pd
# Create an instance
qb = QuantBook()
# Select asset data
assets = ["SPY", "EURUSD", "BTCUSD", "GOOG", "ES", "XAUUSD"]
spy = qb.AddEquity("SPY") # add equity data
eur = qb.AddForex("EURUSD") # add forex data
btc = qb.AddCrypto("BTCUSD") # add crypto data
goog = qb.AddOption("GOOG") # add goog options
es = qb.AddFuture("ES") # add SP 500 futures
xau = qb.AddCfd("XAUUSD", Resolution.Minute, Market.Oanda)
# Gets historical data from the subscribed assets, the last 360 datapoints with daily resolution
h1 = qb.History(qb.Securities.Keys, 360, Resolution.Daily)
# Plot closing prices from "SPY"
for s in assets:
h1.loc[s]["close"].plot()
fails with error:
the label [GOOG] is not in the [index]
but this seems to be accordingly the documentation:
https://www.quantconnect.com/docs/research/historical-dataWhy is this failing?
Jared Broad
To use options data you need to set a filter on the contracts to tell LEAN which ones you are interested in loading. Check out the example algorithms here.
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.
Islander
Hi Jared,
thanks for your reply.
I am not interested in Options but in ETF and CFD only.
So I commented out some lines in my code:
https://www.quantconnect.com/research/61ad564b209d64a1408c8ca0fe9a48e3It works only if use 100 days in history length.
But if I use 500 days, it crashes the kernel.
Why is this happening?
I don't think 500 samples for 2 asstes only is too much data.
Hao Bin Zhang
I think there is an out of memory issue as addressed here:
https://github.com/QuantConnect/Research/issues/9Islander
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!