from tqsdk import TqApi, TqAccount, TqSim
api = TqApi(TqSim())
position=api.get_position()
print(“多开均价: %.2f” % (account.open_price_long))
AttributeError: ‘Account’ object has no attribute ‘open_price_long’
print(“空开均价: %.2f” % (account.open_price_short))
print(“多开成本: %.2f” % (account.open_cost_long))
AttributeError: ‘Account’ object has no attribute ‘open_cost_long’
print(“空开成本: %.2f” % (account.open_cost_short))
AttributeError: ‘Account’ object has no attribute ‘open_cost_short’
print(“多持仓量: %.2f” % (account.property_pos_long))
AttributeError: ‘Account’ object has no attribute ‘property_pos_long’
print(“空持仓量: %.2f” % (account.property_pos_short))
AttributeError: ‘Account’ object has no attribute ‘property_pos_short’
错误原因,这些字段是position对象里面的,不是account,应该用position调取
具体文档参考https://doc.shinnytech.com/pysdk/latest/reference/tqsdk.objs.html