Hi!
I try to consolidate data using 1min bars and into daily bars, all within the FX market. Then I want to implement a rule, that transactions would only be executed 1 minute after midnight. Although I think I edited the code correctly, I receive this error:
'dict' object has no attribute 'Add'
at CustomBarHandler
self.prevPrices.Add(bar)
Do you know what might be the reason of it?
The code looks as follows:
# region imports
from AlgorithmImports import *
# endregion
class CustomIndexStrategy(QCAlgorithm):
def Initialize(self):
self.EURSEK = self.AddForex(self.Pair_1, Resolution.Minute, Market.Oanda).Symbol
self.Consolidate(self.EURSEK, Resolution.Daily, self.CustomBarHandler)
self.prevPrices = { symbol : RollingWindow[QuoteBar](7) for symbol in self.symbols }
def OnData(self,data):
if not (self.Time.hour == 0 and self.Time.minute == 1):
return
def CustomBarHandler(self, bar ):
self.prevPrices.Add(bar)
Sebul
Just realised that in the last line there should “QuoteBar” instead of “Bar" as im using FX data, however the error is still the same unfortunately..
I attach the edited version of code.
Nico Xenox
Hey @sebul
I made a small code that saves two values in a rolling window and enters a trade if the first value is bigger than the second. You can change the code to your preferences.
Sebul
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!