Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最新价格监控 #68

Closed
4ever911 opened this issue Jul 1, 2019 · 3 comments
Closed

最新价格监控 #68

4ever911 opened this issue Jul 1, 2019 · 3 comments

Comments

@4ever911
Copy link

4ever911 commented Jul 1, 2019

quote和kline 里面都包含最新的价格, 如果只监控 最新价格的变化, 他们更新的频率是一样的吗?

有这个需求是,如果频率一样,我就只需要关注kline里面价格的最新变化,kline结构数据比quote少很多,可能新的数据就更少了, 可以大大节约网络传输。

但是不确定如果只关心最新价格,更新频率是否一样?

@4ever911
Copy link
Author

4ever911 commented Jul 1, 2019

刚才写了个小测试程序,好像是同时都更新了,每次都是同时都能监测到。

from tqsdk import *

api = TqApi(TqSim())

q = api.get_quote('CFFEX.IC1907')
k = api.get_kline_serial('CFFEX.IC1907', 86400)

while True:
api.wait_update()

if api.is_changing(k.iloc[-1], "close"):
    print("kline:",  k.close.iloc[-1])

if api.is_changing(q, "last_price"):
    print("quote:", q["last_price"])

print('----------------------------------')

@4ever911
Copy link
Author

4ever911 commented Jul 1, 2019

如果够用,那我只跟踪kline是没问题对吗? 最新价格我就用 k.close.iloc[-1],可行吗

@shinny-tianqin
Copy link
Contributor

quote和kline最后一根的close是同时更新的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants