我在雅虎财经上使用了pandas_datareader

问题描述 投票:0回答:1

我想在雅虎财经上检索CAC40公司的市值。但是我在运行代码时遇到问题。enter image description here

这是我运行的代码这是我运行的代码:

market_cap= get_quote_yahoo(tickers)['marketCap']
market_cap

我期望得到cac40中40家公司的市值

python jupyter
1个回答
0
投票

代码仅包含 2 个股票代码。请添加列表中的所有公司:https://finance.yahoo.com/quote/%5EFCHI/components/

代码:

import yfinance as yf

cac40_tickers = ['BNP.PA', 'CAP.PA']  # put all tickers in the list
data = yf.download(cac40_tickers)
print(data.columns)
print(data)

输出:

            Adj Close                  Close              ...       Open                  Volume
               BNP.PA      CAP.PA     BNP.PA      CAP.PA  ...     BNP.PA      CAP.PA      BNP.PA    CAP.PA
Date                                                      ...
...               ...         ...        ...         ...  ...        ...         ...         ...       ...
2023-11-10  55.610001  171.850006  55.610001  171.850006  ...  55.900002  172.399994   2489497.0  265291.0
2023-11-13  55.790001  172.449997  55.790001  172.449997  ...  55.830002  171.949997   1629208.0  210944.0
2023-11-14  56.009998  172.300003  56.009998  172.300003  ...  55.799999  171.899994   3144007.0  429876.0
2023-11-15  56.369999  175.000000  56.369999  175.000000  ...  56.169998  173.250000   1773206.0  341228.0
2023-11-16  56.090000  177.750000  56.090000  177.750000  ...  56.500000  174.500000   1746207.0  401402.0

[7755 rows x 12 columns]
© www.soinside.com 2019 - 2024. All rights reserved.