def get_minutebar(filesource):
output = []
with open(filesource, 'rb') as file_:
a = C_PERIODIC_BAR()
while (file_.readinto(a) == sizeof(C_PERIODIC_BAR)):
open_ = Quote(a.open.bid_price, a.open.bid_size, a.open.ask_price, a.open.ask_size)
close_ = Quote(a.close.bid_price, a.close.bid_size, a.close.ask_price, a.close.ask_size)
ts = datetime.utcfromtimestamp(a.ts.time.tv_sec + a.ts.time.tv_usec / 1000000)
ts_with_tz = datetime(year=ts.year,
month=ts.month,
day=ts.day,
hour=ts.hour,
minute=ts.minute,
second=ts.second,
tzinfo=pytz.UTC)
elem = PeriodicBar(open_, close_, a.high, a.low, a.volume, ts_with_tz)
output.append(elem)
return output
## @brief Make quote objects from futures data
# date,product,specific_ticker,open,high,low,close,contract_volume,contract_oi,total_volume,total_oi
#
评论列表
文章目录