算法模块示例

Twap

#!/usr/bin/env python
#  -*- coding: utf-8 -*-
__author__ = 'yanqiong'

from tqsdk import TqApi
from tqsdk.algorithm import Twap

"""
在 300s 时间内完成下单 30手,每次下单手数在 5~10 手之间
"""

api = TqApi(auth="信易账号,用户密码")
quote = api.get_quote("CFFEX.T2012")
twap = Twap(api, "CFFEX.T2012", "BUY", "OPEN", 50, 60, 5, 10)
while True:
    api.wait_update()
    if twap and twap.is_finished():
        break
api.close()