kieran-mackle / AutoTrader

A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
https://kieran-mackle.github.io/AutoTrader/
GNU General Public License v3.0
937 stars 216 forks source link

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

Open sc-lin opened 4 months ago

sc-lin commented 4 months ago

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!

t4vvd commented 4 months ago

Hello Kieran , I am only beginning on GitHub trying to run the Deriv API to include the epoch , expected payout, Volatility 10 index, 'basic connection ' , I,m just needing to know where the heading must begin, though I know how to make estimations on epoch settings and payouts. Just also need to know if I can start the heading as ' Volatility 10 index - $19 ' per $10 stake . and then API connect= ( API.Token ) (Login id) Once I have copied the connection do I paste it into the ' code ' under the Volatility 10 index - $19 ... header ? and thereafter all my own preferred content of copy and paste of all the API. call schemas ? Thanks Paul.