factory.py 文件源码

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

项目:zipline-chinese 作者: zhanghan1990 项目源码 文件源码
def create_test_panel_source(sim_params=None, env=None, source_type=None):
    start = sim_params.first_open \
        if sim_params else pd.datetime(1990, 1, 3, 0, 0, 0, 0, pytz.utc)

    end = sim_params.last_close \
        if sim_params else pd.datetime(1990, 1, 8, 0, 0, 0, 0, pytz.utc)

    if env is None:
        env = TradingEnvironment(load=noop_load)

    index = env.days_in_range(start, end)

    price = np.arange(0, len(index))
    volume = np.ones(len(index)) * 1000

    arbitrary = np.ones(len(index))

    df = pd.DataFrame({'price': price,
                       'volume': volume,
                       'arbitrary': arbitrary},
                      index=index)
    if source_type:
        df['type'] = source_type

    panel = pd.Panel.from_dict({0: df})

    return DataPanelSource(panel), panel
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号