Back

Can not convert QuantBook().History to Panda DataFrame

Hi there, i tried to run the following code

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Jupyter")
AddReference("QuantConnect.Indicators")
from System import *
from QuantConnect 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

import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pandas as pd
import statsmodels.api as sm
from math import floor
plt.style.use('seaborn-whitegrid')
from sklearn import linear_model

# Create an instance
qb = QuantBook()

syls = ["XOM","CVX"]
qb.AddEquity(syls[0])
qb.AddEquity(syls[1])

x = qb.History(syls[0], 100, Resolution.Daily).loc[syls[0]]['close']
y = qb.History(syls[1], 100, Resolution.Daily).loc[syls[1]]['close']

and i got the following error

5 x = qb.History(syls[0], 100, Resolution.Daily).loc[syls[0]]['close']
6 y = qb.History(syls[1], 100, Resolution.Daily).loc[syls[1]]['close']

AttributeError: '1, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'loc'

i also tried the solutions given in

https://www.quantconnect.com/forum/discussion/2641/history-method-not-returning-a-dataframe-in-python/p1/comment-8071But nothing worked for me.Thank you very much for your answers
Update Backtest







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