Hello,
I get the below error when I initialize
self.eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda)
During the algorithm initialization, the following exception has occurred: AttributeError : Oanda
at Initialize in main.py:line 26
AttributeError : Oanda
If I exclude
, Market.Oanda
it works. Has there been a change in usage. I followed the docs.
My whole Initialize() function:
def Initialize(self):
self.SetStartDate(2018,10, 14) #Set Start Date
self.SetEndDate(2018,10,16) #Set End Date
self.SetCash(1000) #Set Strategy Cash
# self.SetBrokerageModel(BrokerageName.OandaBrokerage,AccountType.Cash)
self.eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda)
self.quoteBarWindow = RollingWindow[QuoteBar](2)
Additional Question:
What is the default data vendor when we don't state the 'Market', using AddForex()?
Jing Wu
We have historical data for FXCM and OANDA Brokerages. You could use Market.Oanda or Market.FXCM. However, if you don’t specify the market, the default value would be Market.FXCM. FXCM provides 13 currency pairs since April 2007 and OANDA has 71 pairs since April 2004. Please find those pairs in the documentation
self. eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda) should work in the initialize().
Hello Jing Wu ,
thank you but I still receive the same error
During the algorithm initialization, the following exception has occurred: AttributeError : Oanda at Initialize in main.py:line 27 AttributeError : Oanda
class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' 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(2018,1, 1) #Set Start Date self.SetEndDate(2018,10,16) #Set End Date self.SetCash(1000) #Set Strategy Cash # self.SetBrokerageModel(BrokerageName.OandaBrokerage,AccountType.Cash) # self.eurusd = self.AddForex("EURUSD", Resolution.Daily) self.eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda) self.quoteBarWindow = RollingWindow[QuoteBar](2)
from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Data.Market import * from datetime import timedelta import numpy as np from decimal import Decimal ### <summary> ### Basic template algorithm simply initializes the date range and cash. This is a skeleton ### framework you can use for designing an algorithm. ### </summary> class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' 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(2018,1, 1) #Set Start Date self.SetEndDate(2018,10,16) #Set End Date self.SetCash(1000) #Set Strategy Cash # self.SetBrokerageModel(BrokerageName.OandaBrokerage,AccountType.Cash) # self.eurusd = self.AddForex("EURUSD", Resolution.Daily) self.eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda) self.quoteBarWindow = RollingWindow[QuoteBar](2)
Jing Wu
Please remove those import statements.
from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Data.Market import *
Tony Shacklock
Hi
I am also struggling with this error. I want to use Oanda data and set fillDataForward=False, but it gives this error:
AttributeError : Oanda
I can prevent the error by not using any import statements, but I would like to use a class in a separate file.
How can I use AddForex() with the market and fillDataForward specified AND import my class?
Here is a simple code and backtest to illustrate the problem.
Â
Shile Wen
Hi Tony,
We can add this at the end of imports: from QuantConnect import Market to resolve this issue. Please see the attached backtest for reference.
Best Regards,
Shile Wen
Tony Shacklock
Many thanks!
Tony
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!