Endeks performansını değerlendirin

Python ile Zaman Serisi Verilerini Manipüle Etme

Stefan Jansen

Founder & Lead Data Scientist at Applied Artificial Intelligence

Değer ağırlıklı endeksinizi değerlendirin

  • Endeks getirisi:

    • Toplam endeks getirisi

    • Bileşen bazında katkı

  • Kıyas ölçüte karşı performans

    • Dönem toplam getirisi

    • Alt dönemler için yuvarlanan getiriler

Python ile Zaman Serisi Verilerini Manipüle Etme

Değer tabanlı endeks - özet

agg_market_cap = market_cap_series.sum(axis=1)

index = agg_market_cap.div(agg_market_cap.iloc[0]).mul(100)
index.plot(title='Piyasa Değeri Ağırlıklı Endeks')

index.png

Python ile Zaman Serisi Verilerini Manipüle Etme

Hisse bazında değer katkısı

agg_market_cap.iloc[-1] - agg_market_cap.iloc[0]
315,037.71
Python ile Zaman Serisi Verilerini Manipüle Etme

Hisse bazında değer katkısı

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 ile Zaman Serisi Verilerini Manipüle Etme

Piyasa değeri ağırlıkları

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 ile Zaman Serisi Verilerini Manipüle Etme

Değer ağırlıklı bileşen getirileri

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 ile Zaman Serisi Verilerini Manipüle Etme

Kıyas ölçüte karşı performans

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 ile Zaman Serisi Verilerini Manipüle Etme

Kıyas ölçüte karşı: 30G yuvarlanan getiri

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 ile Zaman Serisi Verilerini Manipüle Etme

Hadi pratik yapalım!

Python ile Zaman Serisi Verilerini Manipüle Etme

Preparing Video For Download...