list=[] def doTicker(): #Log(exchange.GetAccount()) #Log(list) ticker = exchange.GetTicker() last = ticker.Last if len(list) < LENGTH: list.append(last) else: pMax = max(list) pMin = min(list) if last > pMax: Log("buy " + str(exchange.GetAccount())) account = exchange.GetAccount() if account.Balance > last: #id = exchange.Buy(last, 1) id = exchange.Buy(-1, 1) Log("buy id --> " + str(id)) elif last < pMin: Log("sell " + str(exchange.GetAccount())) account = exchange.GetAccount() if account.Stocks > 0: #id = exchange.Sell(last, 1) id = exchange.Sell(-1, 1) Log("sell id --> " + str(id)) list.pop(0) list.append(last) def main(): while(true): doTicker() #执行策略 Sleep(PERIOD * 1000) #休息一段时间
恒茂煊 if len(list) < LENGTH,这个LENGTH是什么?
bb 感谢ChildeTang,觉得您挺努力的,可以留个联系方式吗?一块儿交流成长。 另外新手写了个注释给自己看,如果哪里有问题请大家指出来。 https://dn-filebox.qbox.me/0dfac0b5f5087f1af7760f657e934101c764116b.png
sltrain 能通过前1440个成交价的极值,来判断趋势吗?
ChildeTang https://dn-filebox.qbox.me/6eea75a00f671795038b8844f7e32a770f0a68c8.png
Flyingon 这个策略,岂不是一只赔钱,有什么用呢
ChildeTang 还加了注释,厉害了
小黑 作者在吗
amazingrieky 这个策略有问题啊,没有止盈止损的吗?
ChildeTang 这个没法说,有时候测试是赚的,谁知道呢?