119 浏览
0

klines = api.get_kline_serial("CZCE.TA109",  60)
while True:
    api.wait_update()
    if api.is_changing(klines.iloc[-1], "datetime"):    # 判定最后一根K线的时间是否有变化
        print(klines.iloc[-1])                          # 当最后一根K线的时间有变(新K线生成)时才会执行到这里

2021-07-14 10:53:22 – INFO – 通知: 与 wss://otg-sim.shinnytech.com/trade 的网络连接已建立
2021-07-14 10:53:22 – INFO – 通知: 与 wss://free-api.shinnytech.com/t/nfmd/front/mobile 的网络连接已建立
2021-07-14 10:53:22 – INFO – 通知: 登录成功
datetime 1626231240000000000.0
id 68154.0
open 5170.0
high 5170.0
low 5170.0
close 5170.0
volume 0.0
open_oi 1370623.0
close_oi 1370623.0
symbol CZCE.TA109
duration 60
Name: 199, dtype: object
datetime 1626231300000000000.0
id 68155.0
open 5168.0
high 5168.0
low 5168.0
close 5168.0
volume 0.0
open_oi 1370262.0
close_oi 1370262.0
symbol CZCE.TA109
duration 60
Name: 199, dtype: object
datetime 1626231360000000000.0
id 68156.0
open 5172.0
high 5172.0
low 5172.0
close 5172.0
volume 0.0
open_oi 1370132.0
close_oi 1370132.0
symbol CZCE.TA109
duration 60
Name: 199, dtype: object
datetime 1626231420000000000.0
id 68157.0
open 5170.0
high 5170.0
low 5170.0
close 5170.0
volume 0.0
open_oi 1370843.0
close_oi 1370843.0
symbol CZCE.TA109
duration 60
Name: 199, dtype: object
datetime 1626231480000000000.0
id 68158.0
open 5172.0
high 5172.0
low 5172.0
close 5172.0
volume 0.0
open_oi 1370798.0
close_oi 1370798.0
symbol CZCE.TA109
duration 60
Name: 199, dtype: object
datetime 1626231540000000000.0
id 68159.0
open 5174.0
high 5174.0
low 5174.0
close 5174.0
volume 0.0
open_oi 1370414.0
close_oi 1370414.0
symbol CZCE.TA109

未选择答案
0

KLINE在刚刚刷新的时候,他的高开低收均为上一根的收盘价

所以你要取已经结束的kline的close 应该是 kline.iloc[-2].close

未选择答案