Back

AddForex(..., Market.Oanda)

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)
Update Backtest







Additional Question: 

What is the default data vendor when we don't state the 'Market', using AddForex()?

0

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

https://www.quantconnect.com/docs/data-library/forex

self. eurusd = self.AddForex("EURUSD", Resolution.Daily, Market.Oanda) should work in the initialize().

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.


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)
0

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)
0

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 *
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.


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