4.05K 浏览
0

报错:

print(quote.last_price)
AttributeError: ‘dict’ object has no attribute ‘last_price’

照着下面示例写的.只改了当月品种.但如果把last_price去掉会读出整个所有字段的数据.但单独打某一个不成功

from tqsdk import TqApi, TqSim
import datetime
api = TqApi(TqSim())

quote = api.get_quote(“SHFE.ag2006”)
while True:
api.wait_update()
if api.is_changing(quote, “last_price”):
print(quote.last_price)

trading i 已回答的问题 2020年3月6日
0

代码本身没问题,我猜测可能是这样:我从楼主上穿的代码直接复制过来,有以下问题:1是符号的问题,该用英文的,你用了中文,第二可能就是缩进的问题,没按规定缩进。

trading i 已回答的问题 2020年3月6日
0

用同样的代码并不会报错

oct xk 发表新评论 2020年3月6日

谢谢.已经解决