periodic_bar_file_source.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:trade-analysis 作者: qplum 项目源码 文件源码
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
    #
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号