LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
So I am new to quantconnect and python and have been going through some samples to load historical data. I am running into issue while reading the time column from dataframe. Here is my code
df = qb.History(5) print df
print df["close"] # This works
print df["time] # This does not work
Based on the output from printing the df it seems 'symbol' and 'time' column are not on the first line but second while the rest of the columns close, high, low, open, volume are on first line. How can I resolve this issue?
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.
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.
Jing Wu
242.2k
,
Hi Gurdeep,
There are a few time series like open, close, high, low associated with each symbol. Therefore, we use multi-index in history data request. When you use qb.History(5), the return will be a multi-indexed python dataframe. The first level of the index is the symbol. The second level is the timestamp. While the column of the dataframe is only one level (open, high, low and so on).
You could use the symbol to get a dataframe
qb.AddEquity("AAPL")
qb.AddEquity("IBM")
df = qb.History(5)
df1 = df.loc["AAPL"] # dataframe indexed by timestamp
df1.index # print the time index
0
Gurdeep S
99
,
Very helpful. However I am still unable to access data
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...
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!