1、在一个量化交易的策略中看到这样一段代码:
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。--(必须实现)
def init(context):
# 在context中保存全局变量
context.s1 = "ZQZC05" #动力煤
context.lastbuy=0 #末次买入开仓单号
context.lastsell=0 #末次卖出开仓单号
context.lastbuyping=0 #末次平多单单号
context.lastsellping=0 #末次平空单单号
def setorderid(context):
#检查未成交订单,将单号赋值给全局变量,避免启动策略时变量的值为0
#print("获取未成交订单编号")
Orders=get_orders(context.s1,0) #取未成交单
context.lastbuy=0
context.lastbuyping=0
context.lastsell=0
context.lastsellping=0
请教大神,这个参数context,为什么能在不同的函数公用,它是什么类型的对象?
搞懂了context是一个类似字典的context类,https://www.joinquant.com/hel...