一、代码部分
isOpen = False; # 是否 开仓 price = 0; # 全局变量 价格 amount = 0; # 全局变量 下单量 def exec_command(command): global isOpen, price, amount cmdlist = command.split(":") key = cmdlist[0] value = cmdlist[1] if len(cmdlist) == 2 else None if key == 'isButton1': Log(key, ' ') elif key == 'isOpen': Log("buy ", amount, "个BTC", "按价格:", price, "下单。"); # 模拟下单 elif key == 'UpdatePrice': price = value elif key == 'UpdateAmount': amount = value elif key == 'isStr': Log(key, value) elif key == 'isBool': Log(key, value) elif key == 'isNumber': Log(key, value) elif key == 'isSelect': Log(key, value) else: Log('unknow command') def main(): while(true): cmd = GetCommand(); #获取 交互命令API if cmd: Log("按下了按钮:",cmd); #日志显示 exec_command(cmd) #打印当前命令 Sleep(1000);
二、配置交互策略
三、创建机器人
用于运行策略
四、实盘回测