我对tda-api有以下 api 调用
orders = client.get_account(config.account_id,fields=['positions'])
给出错误:
文件“/opt/anaconda3/lib/python3.7/site-packages/tda/client/base.py”,第 361 行,在 get_account 字段 = self.convert_enum_iterable(fields, self.Account.Fields) 文件“/opt/ anaconda3/lib/python3.7/site-packages/tda/utils.py”,第 66 行,在 convert_enum_iterable self.type_error(value, required_enum_type) 文件“/opt/anaconda3/lib/python3.7/site-packages/tda /utils.py",第 41 行,在 type_error possible_members_message)) ValueError:预期类型“字段”,得到类型“str”。(使用 enforce_enums=False 初始化以禁用此检查)
文档如下:
Client.get_account(account_id, *, fields=None)
如果我替换为:client.get_account(config.account_id,fields=positions)
“职位”未定义
如果我查看 api,get_account() 函数的代码如下所示:
class Fields(Enum):
'''Account fields passed to :meth:`get_account` and
:meth:`get_accounts`'''
POSITIONS = 'positions'
ORDERS = 'orders'
def get_account(self, account_id, *, fields=None):
fields = self.convert_enum_iterable(fields, self.Account.Fields)
params = {}
if fields:
params['fields'] = ','.join(fields)