0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【忘備録】リターンの周期変更

0
Posted at
  • リターンの周期変更
    • 日次リターンを月次リターンや週次リターンに変更
    • 日次→月次リターン、月次→年次など、頻度を下げることを想定
def make_resample_ret(df_ret, freq='W'):

    indexvalue = 100*((1 + pd.DataFrame(df_ret)).cumprod())
    indexvalue_resample = indexvalue.resample(freq).last()
    ret_resample = (indexvalue_resample/indexvalue_resample.shift(1) - 1).fillna(0)

    return ret_resample

  • インプット

    • df_ret:インプットリターン(dataframe)
    • freq:アウトプットリターンの周期'M', 'W', 'D', 'A'など
  • アウトプット

    • freqで指定された周期でのリターン(dataframe)
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?