【问题标题】:Can't call with tpqoa不能用 tpqoa 打电话
【发布时间】:2022-01-21 01:05:59
【问题描述】:

有人可以帮我解决这个错误吗? 我的 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'

【问题讨论】:

    标签: python-3.x api rest call wrapper


    【解决方案1】:

    您已经缩进了 account_id、access_token 和 account_type。

    取消缩进然后运行它。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center。
    猜你喜欢
    • 2016-01-18
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    • 2020-05-25
    • 1970-01-01
    相关资源
    最近更新 更多