import matplotlib.pyplot as plt
import statsmodels.api as sm
qb = QuantBook()
# spy = qb.AddEquity("gs")
# h1 = qb.History(qb.Securities.Keys, timedelta(days=4000), Resolution.Daily)
# h1
ES = qb.AddFuture('ES')
ES.SetFilter(timedelta(0), timedelta(60))
# history = qb.History(qb.Securities.Keys, 360, Resolution.Daily)
future_history = qb.GetFutureHistory(ES.Symbol, datetime(2020, 1,22),datetime(2020,1,23))
sp500 = future_history.GetAllData()
future_history.GetExpiryDates()
# sp500.dropna(inplace = True)
# Indicator Analysis
# bbdf = qb.Indicator(BollingerBands(30, 2), spy.Symbol, 360, Resolution.Daily)
# bbdf.drop('standarddeviation', 1).plot(figsize= (16,10))
[datetime.datetime(2020, 3, 20, 0, 0),
datetime.datetime(2020, 6, 19, 0, 0),
datetime.datetime(2020, 9, 18, 0, 0),
datetime.datetime(2020, 12, 18, 0, 0),
datetime.datetime(2021, 3, 19, 0, 0)]
Rahul Chowdhury
Hey Kaman,
Thanks for pointing that out. We have opened a Github issue and we are going to address it ASAP. Meanwhile, you can manipulate your sp500 dataframe to extract only the front month contract history. Because the front contract expiration is listed first in the list of expirations, you can retrieve the front month contract history by doing something like this.
sp500.loc[[future_history.GetExpiryDates()[0]]]
Kaman chau
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!