【问题标题】:getting multiple company names from their respective ticker从各自的股票代码中获取多个公司名称
【发布时间】:2021-09-16 21:16:22
【问题描述】:

只是在寻找回报,我可以在其中输入股票代码并收到完整公司名称的列表:

list = ['MSFT','HIVE','etc','etc']

ticker(list) 将返回公司名称列表

【问题讨论】:

  • 那么到目前为止你尝试了什么?

标签: python loops stock yahoo-finance yfinance


【解决方案1】:

你可以试试这个:

import yfinance as yf

ticker_list = ['MSFT','HIVE', "AAPL", "HOOD", "TSLA", "GOOG"]


def ticker(ticker_list):
    com_name = []
    for ticker in ticker_list:
        stock = yf.Ticker(ticker)
        name = stock.info.get('longName')
        com_name.append(name)
    return com_name


com_name_list = ticker(ticker_list)
print(com_name_list)

输出:

['Microsoft Corporation', 'HIVE Blockchain Technologies Ltd.', 'Apple Inc.', 'Robinhood Markets, Inc.', 'Tesla, Inc.', 'Alphabet Inc.']

您必须安装 yfinance 才能运行此代码。

yfinance安装命令:pip install yfinance

【讨论】:

    猜你喜欢
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 2023-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多