有人能帮我解决这个错误吗?我的pyalgo文件中有错误吗?我必须在tpqoa调用中输入什么类型的其他地址?
代码
pyalgo.cfg
[oanda]
account_id = "101-012-21240417-001"
access_token = 'hidden'
account_type = practice
字符串
代码
import oandapyV20
import pandas as pd
import tpqoa
api = tpqoa.tpqoa('../pyalgo.cfg')
api.get.instruments()[:15]
型
输出
KeyError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5064/836215391.py in <module>
2 import pandas as pd
3 import tpqoa
----> 4 api = tpqoa.tpqoa('../pyalgo.cfg')
5 from oandapyV20 import API
6 import oandapyV20.endpoints.pricing as pricing
~\anaconda3\envs\PythonPC\lib\site-packages\tpqoa\tpqoa.py in __init__(self, conf_file)
111 self.config = configparser.ConfigParser()
112 self.config.read(conf_file)
--> 113 self.access_token = self.config['oanda']['access_token']
114 self.account_id = self.config['oanda']['account_id']
115 self.account_type = self.config['oanda']['account_type']
~\anaconda3\envs\PythonPC\lib\configparser.py in __getitem__(self, key)
958 def __getitem__(self, key):
959 if key != self.default_section and not self.has_section(key):
--> 960 raise KeyError(key)
961 return self._proxies[key]
962
KeyError: 'oanda'
型
1条答案
按热度按时间woobm2wo1#
你已经缩进了account_id,access_token和account_type。
把它们解开,然后运行它。