
等级: 新手上路
- 注册:
- 2022-6-20
- 曾用名:
|
请问如何遍历所有的期货品种标的,这个run_info.base_book_id 只是基准合约代码,我想要所有的主力和非主力合约都作为交易对象。我在api接口网页,找不到所有的标的接口。
def init(context):
# 在context中保存全局变量
context.symbol = context.run_info.base_book_id
context.symbol[0] = ['SQAG10']
假设我们找到了遍历的接口,如何将遍历的代码写入交易程序,是不是如下:
***未遍历前,提取标的
def handle_bar(context):
# 开始编写你的主要的算法逻辑。
columns=['datetime','open','high','low','close','volume']
data = history_bars( context.symbol,100,'5m',columns ,include_now=True)
df = get_df(data,columns)
***遍历之后,提取标的,
如果交易起来,请问这个context.symbol 这个位置应该如何写。 是不是类似
def handle_bar(context):
H=[1,2,3]
columns=['datetime','open','high','low','close','volume']
for in in H:
data = history_bars( i ,100,'5m',columns ,include_now=True)
|
|