# # Install libraries - uncomment if running on a new environment (e.g., Colab)
# !pip install --upgrade capon themes
import capon
import themes
from capon.datasets import load_stock_indexes
themes.register(enable="capon")
indices_tickers = load_stock_indexes().query("country_code=='US'")
indices_tickers
symbol | name | description | country_code | city | |
---|---|---|---|---|---|
0 | ^GSPC | S&P 500 | S&P 500 Index (SPX) | US | New York |
1 | ^DJI | Dow 30 | Dow Jones Industrial Average (DJIA) | US | New York |
2 | ^IXIC | Nasdaq | NASDAQ Composite Index (COMP) | US | New York |
3 | ^RUT | Russell 2000 | Russell 2000 Index (RUT) | US | New York |
indices = capon.stocks(
indices_tickers["symbol"],
start="2019-10-01",
end="2025-01-01",
interval="1d",
n_jobs=-1,
)
indices
0%| | 0/4 [00:00<?, ?it/s]
timestamp | symbol | currency | open | low | high | close | volume | adjclose | |
---|---|---|---|---|---|---|---|---|---|
0 | 2019-09-30 09:30:00-04:00 | ^GSPC | USD | 2967.070068 | 2967.070068 | 2983.850098 | 2976.739990 | 3249130000 | 2976.739990 |
1 | 2019-10-01 09:30:00-04:00 | ^GSPC | USD | 2983.689941 | 2938.699951 | 2992.530029 | 2940.250000 | 3560750000 | 2940.250000 |
2 | 2019-10-02 09:30:00-04:00 | ^GSPC | USD | 2924.780029 | 2874.929932 | 2924.780029 | 2887.610107 | 3914180000 | 2887.610107 |
3 | 2019-10-03 09:30:00-04:00 | ^GSPC | USD | 2885.379883 | 2855.939941 | 2911.129883 | 2910.629883 | 3515130000 | 2910.629883 |
4 | 2019-10-04 09:30:00-04:00 | ^GSPC | USD | 2918.560059 | 2918.560059 | 2953.739990 | 2952.010010 | 3005600000 | 2952.010010 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4939 | 2024-08-21 09:30:00-04:00 | ^RUT | USD | 2146.610107 | 2146.610107 | 2171.270020 | 2170.560059 | 3119670000 | 2170.560059 |
4940 | 2024-08-22 09:30:00-04:00 | ^RUT | USD | 2170.729980 | 2147.870117 | 2174.879883 | 2150.030029 | 2981530000 | 2150.030029 |
4941 | 2024-08-23 09:30:00-04:00 | ^RUT | USD | 2159.979980 | 2159.979980 | 2222.750000 | 2218.699951 | 3291940000 | 2218.699951 |
4942 | 2024-08-26 09:30:00-04:00 | ^RUT | USD | 2230.209961 | 2216.939941 | 2237.689941 | 2217.919922 | 2938570000 | 2217.919922 |
4943 | 2024-08-27 09:30:00-04:00 | ^RUT | USD | 2210.879883 | 2195.070068 | 2210.879883 | 2203.000000 | 2798990000 | 2203.000000 |
4944 rows × 9 columns
capon.plot(indices)
/opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'selection' is deprecated. Use 'selection_point()' or 'selection_interval()' instead; these functions also include more helpful docstrings. warnings.warn(message, AltairDeprecationWarning, stacklevel=1) /opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/vegalite/v5/api.py:469: AltairDeprecationWarning: The types 'single' and 'multi' are now combined and should be specified using "selection_point()". warnings.warn( /opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'add_selection' is deprecated. Use 'add_params' instead. warnings.warn(message, AltairDeprecationWarning, stacklevel=1)
capon.plot(indices, normalize="2020-01-01", title="Market Indices Change")
/opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'selection' is deprecated. Use 'selection_point()' or 'selection_interval()' instead; these functions also include more helpful docstrings. warnings.warn(message, AltairDeprecationWarning, stacklevel=1) /opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/vegalite/v5/api.py:469: AltairDeprecationWarning: The types 'single' and 'multi' are now combined and should be specified using "selection_point()". warnings.warn( /opt/miniconda3/envs/capon/lib/python3.10/site-packages/altair/utils/deprecation.py:65: AltairDeprecationWarning: 'add_selection' is deprecated. Use 'add_params' instead. warnings.warn(message, AltairDeprecationWarning, stacklevel=1)