I want to use a history request to fill my RollingWindow [Tradebar] so it needs open high low close.
history = algo.History(symbol,1,Resolution.Daily)
if not history.empty:
for time, row in history.loc[symbol].iterrows():
self.roc.Update(time,row['close'])
The above code works fine because it just needs a closing value, I want to use the above history request to get a tradebar and add it to my rolling window. Below is what I've tried but it doesn't work. I think I need to make a dictionary to store the tradebar but I tried that and it didn't work so I'm not sure how to do it.
history1 = algo.History(symbol, 3,Resolution.Daily)
if not history1.empty:
for time, row in history.loc[symbol].iterrows():
self.Bars.Add(time, row['open'],['high'],['low'],['close'])
self.Bars is my rolling window and when I add that it doesn't work because it isn't a tradebar but I have no idea how to get that data as a tradebar.
Any help will be appreciated thank you!
Vladimir
Emil Visser
Try this way
Emil Visser
Hi Vladimir,
Thank you for that, I get the values I need doing that however it still gives me a TypeError as that data isn't in a tradebar format. Any idea how I can save those for data points into 1 tradebar?
I pasted the error message below.
Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'numpy.float64'>) method. Please checkout the API documentation. at __init__ self.Bars.Add(time in main.py: line 110
Adam W
Do you need fine-grained control over it or just to fill in the RollingWindow? If the latter, an alternative way is to use `self.SetWarmUp()` which should populate the rolling window/indicators/etc for you.
Vladimir
Emil Visser
Can you share the complete code.?
Yuri Lopukhov
Hi, Emil, perhaps you want to change last line to
Emil Visser
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!