mmyjh86

[YouTube] 벡테스팅 - 지수수익률

Sep 12th, 2020 (edited)
1,635
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from pykrx import stock
  2.  
  3. def 지수수익률(df):
  4.     기간수익률 = df['종가'][-1]/df['종가'][0]
  5.     N = (df.index[-1] - df.index[0]).days / 365
  6.     return (기간수익률 ** (1/N)) - 1
  7.  
  8. df = stock.get_index_ohlcv_by_date("19800104", "20200831", "1001")
  9. CAGR = 지수수익률(df)
  10. print(CAGR)
RAW Paste Data