#coding:gbk
import datetime
import pandas as pd
def init(ContextInfo):
ContextInfo.order_count = 0
ContextInfo.max_count = 5 # 委托风控参数
ContextInfo.order_time_span = 30
ContextInfo.BUY_OPEN = 50
ContextInfo.SELL_OPEN = 50
ContextInfo.BUY_OPEN = 50
ContextInfo.SELL_OPEN = 52
ContextInfo.SELL_CLOSE = 51
ContextInfo.BUY_CLOSE = 53
ContextInfo.ASK_1 = 4
ContextInfo.BID_1 = 6
ContextInfo.account = 'xxxx'
ContextInfo.start = '2024-04-01 09:25:00'
ContextInfo.end = '2200-12-31 15:30:00'
ContextInfo.set_commission(1, [1,0, 0, 2, 2, 2])
ContextInfo.userparam = {"OrderType":1,"SingleNumMin":1,"SingleNumMax":1,"MaxOrderCount":3, 'PlaceOrderInterval':10,'SuperPriceType':1,'SuperPriceValue':20}
def handlebar(ContextInfo):
if not ContextInfo.is_last_bar():
pass
else:
algo_passorder(ContextInfo.BUY_OPEN, 1101, ContextInfo.account, '10006966.SHO', ContextInfo.BID_1, -1, 3, 'OPT_MM', 1, 'algo_order', ContextInfo.userparam, ContextInfo)
ContextInfo.order_count += 1
if ContextInfo.order_count > ContextInfo.max_count:
stop(ContextInfo)
def stop(ContextInfo):
print( '策略已经退出!')
为了省时间,大佬们可以拿这段代码去做测试。ContextInfo.account = 'xxxx'需要改一下。 |