#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = \’spring\’
from tqsdk import TqApi, TqSim
api = TqApi()
klines1 = api.get_kline_serial(\”SHFE.ni1910\”, 60)
quote_near = api.get_quote(\”SHFE.ni1910\”)
while True:
api.wait_update()
if api.is_changing(quote_near) :
ma1 = sum(klines1.close.iloc[-15:]) / 15
spread = quote_near.last_price – ma1
print(\”当前价差:\”, spread)
# 关闭api,释放相应资源
api.close()