data_handler.py 文件源码

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

项目:pyktrader2 作者: harveywwu 项目源码 文件源码
def DT_RNG(df, win = 2, ratio = 0.7):
    if win == 0:
        tr_ts = pd.concat([(pd.rolling_max(df['high'], 2) - pd.rolling_min(df['close'], 2))*0.5,
                        (pd.rolling_max(df['close'], 2) - pd.rolling_min(df['low'], 2))*0.5,
                        df['high'] - df['close'],
                        df['close'] - df['low']],
                        join='outer', axis=1).max(axis=1)
    else:
        tr_ts = pd.concat([pd.rolling_max(df['high'], win) - pd.rolling_min(df['close'], win),
                       pd.rolling_max(df['close'], win) - pd.rolling_min(df['low'], win)],
                       join='outer', axis=1).max(axis=1)
    return pd.Series(tr_ts, name = 'DTRNG%s_%s' % (win, ratio))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号