Quant League is evolving into Strategies, our new home for sharing, discovering, and exploring trading strategies, with improved organization and a better overall experience. Q4-2025 will be the final Quant League.
LEAN is the open-source algorithmic trading engine powering QuantConnect.
Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join Our Discord Channel
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
This research is under review. To publish this research attract three community upvotes.
This research is under review. To publish this research attract three community upvotes.
This discussion is a draft. Click here to publish this discusison.
I am getting an error while running RollingWindow(QuoteBar) but i don't understand why, this is the error: TypeError : type(s) expected
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2017, 1, 1) #Set Start Date
self.SetEndDate(2020, 10, 1) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.AddForex("EURUSD", Resolution.Minute, Market.Oanda)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
# create a 12 day exponential moving average
self.fast = self.EMA("EURUSD", 5, Resolution.Daily)
# create a 48 hour exponential moving average
self.slow = self.EMA("EURUSD", 25, Resolution.Daily)
self.SetLeverage = 1.0
self.SetWarmUp(timedelta(days=20))
self.SMA("EURUSD", 225).Updated += self.SmaUpdated
self.smaWin = RollingWindow[IndicatorDataPoint](225)
def SmaUpdated(self, sender, updated):
'''Adds updated values to rolling window'''
self.smaWin.Add(updated)
def OnData(self, data):
# wait for our slow ema to fully initialize
if self.IsWarmingUp:
return
fxQuoteBars = data.QuoteBars
QuoteBar = fxQuoteBars['EURUSD']
self.window = RollingWindow[QuoteBar](2)
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.
Derek Melchin
STAFF
,
Hi Wouter,
The issue is raised because the algorithm above declares a variable called `QuoteBar`, which overrides the QuoteBar class.
Best, Derek Melchin
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.
Wouter vH
267
,
Dear Derek,
I don't get why this is the case since this is how it is noted in the documentation, so did i misunderstand the documentation? Thanks for the answer anyhow!
Derek Melchin
STAFF
,
Hi Wouter,
The issue is specifically with this line:
QuoteBar = fxQuoteBars['EURUSD']
Please share a link to the section of docs which have this so we can correct it.
Best, Derek Melchin
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.
Wouter vH
267
,
Dear Derek,
See below the link, it is under the header QuoteBars, thank you for your help!
Thanks for providing the reference. Note that the documentation declares the variable as eurusdQuoteBar instead of QuoteBar.
eurusdQuoteBar = fxQuoteBars['EURUSD']
Hope this clears things up. We recommend that variable names don't start with a capital later, since Lean follows the UpperCamelCase naming convention.
Best, Derek Melchin
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.
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!
Allocate to this Strategy
Institutional clients can contact the author and allocate capital to this strategy.
Derek Melchin
Hi Wouter,
The issue is raised because the algorithm above declares a variable called `QuoteBar`, which overrides the QuoteBar class.
Best,
Derek Melchin
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.
Wouter vH
Dear Derek,
I don't get why this is the case since this is how it is noted in the documentation, so did i misunderstand the documentation? Thanks for the answer anyhow!
Derek Melchin
Hi Wouter,
The issue is specifically with this line:
QuoteBar = fxQuoteBars['EURUSD']Please share a link to the section of docs which have this so we can correct it.
Best,
Derek Melchin
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.
Wouter vH
Dear Derek,
https://www.quantconnect.com/docs/algorithm-reference/handling-dataSee below the link, it is under the header QuoteBars, thank you for your help!
Derek Melchin
Hi Wouter,
Thanks for providing the reference. Note that the documentation declares the variable as eurusdQuoteBar instead of QuoteBar.
eurusdQuoteBar = fxQuoteBars['EURUSD']Hope this clears things up. We recommend that variable names don't start with a capital later, since Lean follows the UpperCamelCase naming convention.
Best,
Derek Melchin
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.
Wouter vH
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!