Last active
February 23, 2020 19:55
-
-
Save paduel/de089b597524763bbc0514caba147846 to your computer and use it in GitHub Desktop.
Simple code to download historical data of current IBEX components.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the necessary modules | |
import pandas as pd | |
import yfinance as yf | |
# Get the current IBEX components tickers list | |
ibex_assets = pd.read_html('https://es.wikipedia.org/wiki/IBEX_35')[2] | |
assets = (ibex_assets.Ticker + '.MC').tolist() | |
# Dowload historical data to a multi-index dataframe | |
data = yf.download(assets, start='2008-01-01', as_panel=False) |
Actualizado, parece que ahora la tabla es la 2, en vez de la 1. Actualizado nombre del módulo a yfinance.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracias!, me funciona perfecto incluyendo el parámetro header=0 en pd.read_html