indicator.py 文件源码

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

项目:trading-stock-thailand 作者: adminho 项目源码 文件源码
def is_strong(df_close, window=12):
    """ In 12 days periods, How many are ROC'security more than ROC' SET (percent %) """
    # df_roc has calculated by daily_returns    
    df_roc = roc(df_close)

    # Empty Data Frame
    df_main = pd.DataFrame(index=df_close.index, columns=df_close.columns) 

    for symbol in df_close.columns:
        if symbol == 'SET':
            continue

        df_compare  = df_roc['SET'] < df_roc[symbol]
        # In python True is 1, False is 0
        # 1: meaning 12 days periods, ROC'security > ROC'SET always
        # 2: meaning 12 days periods, ROC'security < ROC'SET always
        df_main[symbol] = pd.rolling_mean(df_compare[window:], window)

    df_main['SET']=0
    print(df_main)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号