hikyuu2/hikyuu/strategy/strategy_demo3.py
2024-08-25 22:58:17 +08:00

25 lines
1014 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/python
# -*- coding: utf8 -*-
#
# 警告Hikyuu 为量化研究工具,本身不包含程序化交易接口。此部分仅为策略调度运行时示例,
# 供自行实现程序化交易时参考,请自行负责程序化交易可能造成的损失。
#
if __name__ == '__main__':
import easytrader
from hikyuu import *
# 创建 easytrade 订单代理(示例仅支持华泰)可自行参照 EasyTraderOrderBroker 修改
user = easytrader.use('ht_client')
user.connect(r'D:\htwt\xiadan.exe')
easy_ob = EasyTraderOrderBroker(user)
broker = crtOB(easy_ob)
sys = get_part("default.sys.趋势双均线")
# 直接使用 sys 创建 strategy 示例,如果为日线,则自动每日 14点55分 执行
# 如果 query 为日线以下分钟线、5分钟线则自动按对应间隔分钟、5分钟循环执行
stg = crt_sys_strategy(sys, "sz000001", Query(Datetime(20240101), ktype=Query.DAY), broker, TC_Zero(), "demo3")
stg.start()