gpt4 book ai didi

pandas-datareader - 使用python中的yahoo和pandas_datareader从不同市场获取市场数据

转载 作者:行者123 更新时间:2023-12-02 02:39:58 25 4
gpt4 key购买 nike

所以我对市场之间的冗余标签名称有点问题。例如在使用以下代码获取数据时:

from pandas_datareader import data as pdr
from datetime import datetime
data = pdr.get_data_yahoo(['AC'], start=datetime(2020,1,6), end=datetime(2020,2,6))

我取回的数据是 NYSE:AC (Associated Capitol Group Incorporated) 或 TSE:AC (加航)?

最佳答案

我的理解是默认没有点和 extension name来自美国市场。股票代码的扩展名是指美国以外的市场。这里有些例子。

AC.TO : Toronto
AC.PA : Paris
AC.MX : Mexico
AC.VI : Vienna
FPI1.BE : Berlin
F7TB.MU : Munich

以下可以得到 longNameticker .
from datetime import datetime
import pandas_datareader.data as web

tickers = ['AC', 'AC.TO']

for ticker in tickers:

print('\n---------------------------------------------------------------\n')

data = web.get_data_yahoo([ticker], start=datetime(2020, 1, 6), end=datetime(2020, 2, 6))

df = web.get_quote_yahoo([ticker])

print(df[['longName', 'exchange', 'fullExchangeName', 'currency', 'quoteType', ]].T)
print()

print(data)

下面是上面代码的输出:

---------------------------------------------------------------

AC
longName Associated Capital Group, Inc.
exchange NYQ
fullExchangeName NYSE
currency USD
quoteType EQUITY

Attributes High Low Open Close Volume Adj Close
Symbols AC AC AC AC AC AC
Date
2020-01-06 39.790001 38.490002 38.490002 39.790001 3300 39.790001
2020-01-07 39.669998 38.590000 39.540001 39.160000 6200 39.160000
2020-01-08 39.790001 38.560001 38.889999 39.790001 6400 39.790001
2020-01-09 39.830002 39.750000 39.830002 39.750000 1800 39.750000
2020-01-10 39.520000 39.099998 39.520000 39.500000 5100 39.500000
2020-01-13 42.759998 39.250000 39.250000 42.759998 23000 42.759998
2020-01-14 47.779999 43.029999 43.160000 47.770000 13000 47.770000
2020-01-15 48.501999 47.049999 48.299999 48.419998 21400 48.419998
2020-01-16 52.820000 48.134998 48.160000 50.410000 10200 50.410000
2020-01-17 52.595001 50.160000 51.200001 51.080002 21400 51.080002
2020-01-21 65.459999 50.549999 50.709999 63.580002 42700 63.580002
2020-01-22 64.900002 56.000000 64.900002 57.220001 30700 57.220001
2020-01-23 57.480000 46.959999 57.480000 47.340000 26100 47.340000
2020-01-24 47.779999 42.299999 47.340000 42.349998 30000 42.349998
2020-01-27 48.540001 42.500000 42.500000 43.759998 28100 43.759998
2020-01-28 45.000000 43.040001 43.349998 43.880001 11700 43.880001
2020-01-29 43.689999 41.099998 43.689999 41.459999 15200 41.459999
2020-01-30 43.700001 41.730000 42.110001 42.790001 21900 42.790001
2020-01-31 42.730000 41.189999 42.299999 41.770000 20300 41.770000
2020-02-03 43.410000 42.020000 42.320000 42.279999 10900 42.279999
2020-02-04 43.299999 41.799999 42.490002 41.799999 16300 41.799999
2020-02-05 44.299999 41.730000 42.160000 43.889999 15200 43.889999
2020-02-06 45.430000 43.590000 43.937000 43.720001 19700 43.720001
2020-02-07 44.158001 41.290001 43.700001 41.290001 12600 41.290001

---------------------------------------------------------------

AC.TO
longName Air Canada
exchange TOR
fullExchangeName Toronto
currency CAD
quoteType EQUITY

Attributes High Low Open Close Volume Adj Close
Symbols AC.TO AC.TO AC.TO AC.TO AC.TO AC.TO
Date
2020-01-06 47.820000 47.110001 47.610001 47.299999 1134902 47.299999
2020-01-07 48.270000 47.200001 47.299999 48.240002 863739 48.240002
2020-01-08 49.279999 47.750000 47.750000 49.040001 1193122 49.040001
2020-01-09 50.389999 49.070000 49.119999 49.599998 1388006 49.599998
2020-01-10 51.014999 49.200001 49.590000 50.900002 1443019 50.900002
2020-01-13 52.180000 50.470001 50.849998 52.090000 1388026 52.090000
2020-01-14 52.709999 51.490002 52.029999 52.009998 1352906 52.009998
2020-01-15 52.459999 51.340000 51.930000 51.540001 1108539 51.540001
2020-01-16 52.220001 51.560001 51.700001 51.790001 930670 51.790001
2020-01-17 51.520000 50.160000 50.480000 51.080002 1767395 51.080002
2020-01-20 51.410000 50.660000 50.820000 51.150002 310712 51.150002
2020-01-21 50.610001 47.680000 50.500000 48.840000 3095071 48.840000
2020-01-22 49.680000 48.639999 49.299999 48.680000 1282190 48.680000
2020-01-23 49.000000 47.009998 48.459999 48.419998 2001993 48.419998
2020-01-24 48.580002 45.770000 48.450001 47.180000 2416449 47.180000
2020-01-27 45.529999 43.400002 43.410000 44.740002 2709248 44.740002
2020-01-28 45.770000 44.689999 45.119999 45.099998 2257306 45.099998
2020-01-29 45.959999 44.709999 45.279999 45.599998 1916354 45.599998
2020-01-30 45.200001 44.180000 45.099998 44.930000 1586113 44.930000
2020-01-31 45.139999 44.154999 44.630001 44.330002 1529131 44.330002
2020-02-03 45.180000 44.119999 44.369999 44.779999 1499613 44.779999
2020-02-04 47.250000 45.520000 45.590000 46.509998 1812547 46.509998
2020-02-05 48.060001 46.400002 47.250000 46.700001 1971011 46.700001
2020-02-06 47.130001 46.330002 47.000000 46.349998 1373740 46.349998
2020-02-07 46.250000 45.040001 46.250000 45.459999 1316269 45.459999

关于pandas-datareader - 使用python中的yahoo和pandas_datareader从不同市场获取市场数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60255760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com