资源加载中... loading...

唐奇安通道

Author: yuzy, Date: 2022-11-14 14:49:49
Tags:


'''backtest
start: 2021-11-16 09:00:00
end: 2022-11-15 15:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
'''


p = ext.NewPositionManager()
mp = 0 
def onTick():
    _C(exchange.SetContractType,symbol)
    bar = _C(exchange.GetRecords)
    if len(bar) < 100 :
        return
    close_last = bar[-2]["Close"]
    bar.pop()
    on_line = TA.Highest(bar,55,"High")*a 
    under_line = TA.Lowest(bar,55,"Low")*b 
    mid_line = (on_line + under_line)/2 
    global mp 
    if mp == 1 and close_last < mid_line :
        p.Cover(symbol)
        mp = 0 
    if mp == -1 and close_last > mid_line :
        p.Cover(symbol)
        mp = 0 
    if mp == 0 :
        if close_last > mid_line :
            p.OpenLong(symbol, 1)
            mp = 1 
        elif close_last < mid_line :
            p.OpenShort(symbol, 1)
            mp = -1
    




def main():
    while True:
        if exchange.IO("status"):
            onTick()
            LogStatus(_D(),"已连接")
        else:
            LogStatus(_D(),"未连接")
        Sleep(1000)
        
    
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6