集合竞价获取snapshot时间序列

量化交流搬运工
量化交流搬运工 90后,坚持量化学习

0 People liked this article · 2611 views

在这里,我们以600570恒生电子、600333长春燃气为例:

import time
def initialize(context):
# 初始化此策略
# 设置我们要操作的股票池, 这里我们只操作一支股票
g.security = '600570.SS'
set_universe(g.security)
#每天9:15 分运行集合竞价处理函数
run_daily(context, aggregate_auction_func, time='9:15')
g.snap_p_info = {}
g.stock_list = ['600570.SS', '600333.SS']
def before_trading_start(context, data):
for stock in g.stock_list:
g.snap_p_info[stock] = []
def aggregate_auction_func(context):
while True:
if int(datetime.datetime.now().strftime("%M")) <= 20:
for stock in g.stock_list:
#最新价
snapshot = get_snapshot(stock)
price = snapshot[stock]['last_px']
g.snap_p_info[stock].append(price)
log.info(g.snap_p_info)
time.sleep(3)
else:
log.info(g.snap_p_info)
break
def handle_data(context, data):
pass

Published on 2024-05-06 09:54

Disclaimers:

This document is written by 量化交流搬运工 Original published on 百果量化交流平台 ,The copyright belongs to the author。

Log in,More exciting content waiting for you to find,Contribute wonderful answers,Participate in comment interaction

go Sign in! No accountgoregister