from tick_trade_api import MindgoHqGenerator
import pandas as pd
#初始化账户
def init(context):
context.s1 = "300033.SZ"
subscribe([context.s1])
set_holding_stocks({'300033.SZ': 1000})
reg_signal('big', get_big)
# 开盘前运行函数
def before_trading(context):
print('before_trading')
# 收盘后运行函数
def after_trading(context):
print('after_trading')
# 信号定义函数
def get_big(data):
return data['current'] > data['open']
# 设置买卖条件,每个交易频率(tick)调用一次
def handle_tick(context, tick):
# 获取时间
time = tick.datetime.strftime('%H%M')
for bar in MindgoHqGenerator(['600000.SZ'], is_standard=False):
print(bar.all_values())
print('\n')
print('通过属性获取主动买入特大单量:%s' % bar.BIGBUYCOUNT1)
print('通过属性获取主动买入特大单量:%s' % bar['BIGBUYCOUNT1'])
break
# 获取信号
big_single = get_signal(tick.order_book_id, "big")
if (big_single) and (time == '0930'):
order_shares(tick.order_book_id, 100)
if (not big_single) and (time == '0930'):
order_shares(tick.order_book_id, -100)