In [2]:
%load_ext autoreload
%autoreload 2
import plotly
import plotly.graph_objs as go
import logging
from quantfinlib.util import configure_logger
from quantfinlib.datasets import load_equity_indices
plotly.offline.init_notebook_mode()
configure_logger(verbosity=logging.WARN, log_to_file=False)
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
Equity indices
In [7]:
print('\n'.join(load_equity_indices.__doc__.strip().split('\n')[1:51]))
The dataset contains daily Close prices for 30+ equity indices.
Source: https://www.kaggle.com/datasets/mukhazarahmad/worldwide-stock-market-indices-data
| DATE | GSPC | IXIC | DJI | NYA | XAX BUK100P |...
|--------------|------------|------------|-----------|-----------|-----------------|
| 2000-01-03 | 1455.21997 | 4131.14990 | 11357.509 | 6762.1098 | 868.7399902 |
| 2000-01-04 | 1399.42004 | 3901.68994 | 10997.929 | 6543.7597 | 849.6500244 |
...
Returns
-------
pd.DataFrame
The multi-index dataset, 1 row per day, with columns: DATE, %INDEX_NAME%
where %INDEX_NAME% is one of the following:
'GSPC': S&P 500 Index (United States)
'IXIC': NASDAQ Composite Index (United States)
'DJI': Dow Jones Industrial Average (United States)
'NYA': NYSE Composite Index (United States)
'XAX': NYSE American Composite Index (United States)
'BUK100P': Cboe UK 100 Index (United Kingdom)
'RUT': Russell 2000 Index (United States)
'VIX': CBOE Volatility Index (United States)
'GDAXI': DAX Index (Germany)
'FCHI': CAC 40 Index (France)
'STOXX50E': Euro Stoxx 50 Index (Europe)
'N100': Euronext 100 Index (Europe)
'BFX': BEL 20 Index (Belgium)
'IMOEX.ME': MOEX Russia Index (Russia)
'N225': Nikkei 225 Index (Japan)
'HSI': Hang Seng Index (Hong Kong)
'000001.SS': Shanghai Composite Index (China)
'399001.SZ': Shenzhen Component Index (China)
'AXJO': S&P/ASX 200 Index (Australia)
'AORD': All Ordinaries Index (Australia)
'BSESN': S&P BSE Sensex Index (India)
'JKSE': Jakarta Composite Index (Indonesia)
'NZ50': S&P/NZX 50 Index (New Zealand)
'KS11': KOSPI Composite Index (South Korea)
'TWII': Taiwan Weighted Index (Taiwan)
'GSPTSE': S&P/TSX Composite Index (Canada)
'BVSP': Bovespa Index (Brazil)
'MXX': IPC Index (Mexico)
'IPSA': S&P/CLX IPSA Index (Chile)
'MERV': MERVAL Index (Argentina)
'TA125.TA': Tel Aviv 125 Index (Israel)
'CASE30': EGX30 Index (Egypt)
'JN0U.JO': FTSE/JSE Africa Top 40 Index (South Africa)
In [9]:
df = load_equity_indices()
fig = go.Figure()
for col in df.columns:
fig.add_trace(go.Scatter(x=df.index, y=df[col], mode='lines', name=col))
fig.update_layout(title='Indices Values\Prices',
xaxis_title='Date',
yaxis_title='Price',
legend_title='Index Names',
template='plotly_white',
width=600,
height=400,
font=dict(size=12),
margin=dict(l=40, r=40, t=40, b=40)
)
fig.show()