인덱스 성과 평가

Python으로 시계열 데이터 다루기

Stefan Jansen

Founder & Lead Data Scientist at Applied Artificial Intelligence

시가총액 가중 인덱스 평가

  • 인덱스 수익률:

    • 전체 인덱스 수익률

    • 구성 종목별 기여도

  • 벤치마크 대비 성과

    • 전체 기간 수익률

    • 하위 기간 롤링 수익률

Python으로 시계열 데이터 다루기

가치 기반 인덱스 - 복습

agg_market_cap = market_cap_series.sum(axis=1)

index = agg_market_cap.div(agg_market_cap.iloc[0]).mul(100)
index.plot(title='Market-Cap Weighted Index')

index.png

Python으로 시계열 데이터 다루기

종목별 가치 기여도

agg_market_cap.iloc[-1] - agg_market_cap.iloc[0]
315,037.71
Python으로 시계열 데이터 다루기

종목별 가치 기여도

change = market_cap_series.first('D').append(market_cap_series.last('D'))

change.diff().iloc[-1].sort_values() # or: .loc['2016-12-30']
TM     -6,365.07
KO     -4,034.49
ABB     7,592.41
ORCL   11,109.65
PG     14,597.48
UPS    17,212.08
WMT    23,232.85
BABA   27,800.00
JNJ    39,931.44
T      50,229.33
XOM    53,075.38
JPM    80,656.65
Name: 2016-12-30 00:00:00, dtype: float64
Python으로 시계열 데이터 다루기

시가총액 기반 가중치

market_cap = components['Market Capitalization']

weights = market_cap.div(market_cap.sum())
weights.sort_values().mul(100)
Stock Symbol
ABB     1.85
UPS     3.45
TM      5.96
ORCL    6.93
KO      7.03
WMT     8.50
PG      8.81
T       9.47
BABA   10.55
JPM    11.50
XOM    12.97
JNJ    12.97
Name: Market Capitalization, dtype: float64
Python으로 시계열 데이터 다루기

가치 가중 구성 종목 수익률

index_return = (index.iloc[-1] / index.iloc[0] - 1) * 100
14.06
weighted_returns = weights.mul(index_return)

weighted_returns.sort_values().plot(kind='barh')

weighted-returns.png

Python으로 시계열 데이터 다루기

벤치마크 대비 성과

data = index.to_frame('Index') # Convert pd.Series to pd.DataFrame

data['SP500'] = pd.read_csv('sp500.csv', parse_dates=['Date'], index_col='Date')
data.SP500 = data.SP500.div(data.SP500.iloc[0], axis=0).mul(100)

index_vs_sp500.png

Python으로 시계열 데이터 다루기

벤치마크 대비 성과: 30일 롤링 수익률

def multi_period_return(r):
    return (np.prod(r + 1) - 1) * 100

data.pct_change().rolling('30D').apply(multi_period_return).plot()

index_vs_sp500_30D.png

Python으로 시계열 데이터 다루기

연습해 봅시다!

Python으로 시계열 데이터 다루기

Preparing Video For Download...