Skip to content

config["API"] using Oanda not found #104

Open
@sc-lin

Description

Hi, I was trying to use autotrader with oanda as the data source for both backtesting and paper trading at the moment. I found that in the autotrader/brokers/oanda.py the broker setup is misaligned with the keys.yaml. The config in that I print out in `

{'feed': 'oanda', 'environment': 'paper', 'global_config': {'OANDA': {'LIVE_API': 'api-fxtrade.oanda.com', 'LIVE_ACCESS_TOKEN': '123123asdasd', 'PRACTICE_API': 'api-fxpractice.oanda.com', 'PRACTICE_ACCESS_TOKEN': '123123asdasd', 'DEFAULT_ACCOUNT_ID': '123123', 'PORT': 443}, 'CCXT:EXCHANGE': {'api_key': 'xxxx', 'secret': 'xxxx', 'base_currency': 'USDT'}, 'dYdX': {'ETH_ADDRESS': '0xxxxx', 'ETH_PRIV_KEY': 'xxxxx'}}, 'base_currency': 'USD', 'exchange': 'oanda', 'datastreamer': <class 'autotrader.utilities.LocalDataStream'>, 'backtest_mode': True, 'data_start': datetime.datetime(2024, 1, 1, 0, 0, tzinfo=<UTC>), 'data_end': datetime.datetime(2024, 1, 4, 0, 0, tzinfo=<UTC>), 'data_dict': None, 'data_path_mapper': None, 'directory': None, 'dynamic_data': False, 'logging_options': {'stdout_level': 30, 'stdout': False}}

Yet in line 20 to 23 in autotrader/brokers/oanda.py: it is looking for
self.API = config["API"] self.ACCESS_TOKEN = config["ACCESS_TOKEN"] self.port = config["PORT"] self.ACCOUNT_ID = config["ACCOUNT_ID"] self.api = v20.Context( hostname=self.API, token=self.ACCESS_TOKEN, port=self.port )

this is my runfile.py

`
from autotrader.autotrader import AutoTrader

at = AutoTrader()
at.configure(verbosity=1, home_currency='USD', broker='oanda', feed='oanda')
at.add_strategy("macd")

at.backtest(start="1/1/2024", end="4/1/2024", localize_to_utc=True)
at.virtual_account_config(initial_balance=1000, leverage=30, exchange='oanda')
at.run()
`

I am using autotrader[oanda]==1.1.2, not sure if it is a known issue or do I set anything wrong here? Thank you!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions