history_bar 取日线的open就是当天开盘价了
def init(context):
# 在context中保存全局变量
context.qh1 = "SQRB00"
context.open_price = 0
def handle_bar(context):
# 开始编写你的主要的算法逻辑。
context.open_price = history_bars(context.qh1, 1, '1d', 'open', includ_now=True)[0]
使用1分钟周期K线时,开仓价格代码运行一次就可以了,如何避免在handle_bar()中一直重复执行。