{"id":13699978,"url":"https://github.com/innes213/pyhoofinance","last_synced_at":"2025-05-04T18:33:57.549Z","repository":{"id":18681081,"uuid":"21890165","full_name":"innes213/pyhoofinance","owner":"innes213","description":"Rapidly queries Yahoo Finance for multiple tickers and returns typed data for analysis","archived":true,"fork":false,"pushed_at":"2016-10-07T20:37:46.000Z","size":100,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T22:35:09.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/innes213.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-16T06:53:02.000Z","updated_at":"2023-05-19T07:13:06.000Z","dependencies_parsed_at":"2022-07-04T19:30:54.537Z","dependency_job_id":null,"html_url":"https://github.com/innes213/pyhoofinance","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innes213%2Fpyhoofinance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innes213%2Fpyhoofinance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innes213%2Fpyhoofinance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innes213%2Fpyhoofinance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/innes213","download_url":"https://codeload.github.com/innes213/pyhoofinance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382827,"owners_count":21739222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T20:00:46.716Z","updated_at":"2025-05-04T18:33:55.294Z","avatar_url":"https://github.com/innes213.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":["Data Sources","数据来源"],"readme":"# pyhoofinance\n\npyhoofinance is a set of tools to query Yahoo Finance's\nAPI. These tools are designed for applications which need \nto grab large numbers of quotes. Additionally, data, by \ndefault, is properly typecast for easy analysis. It is \ndesigned for flexibility and to minimize server queries.\n\n## Installation\n\nFrom PyPi:\n```\npip install pyhoofinance\n```\n\nFrom Source:\n```\npython setup.py install\n```\n\n## Example Usage\n\n```\npython\n#!/usr/bin/env python\n\nfrom pyhoofinance import quotedata     # Current stock data\nfrom pyhoofinance import historicdata  # Historic stock data\nfrom pyhoofinance import *             # Useful constants\n\n# Print the Standard quote with data typedef'd for YHOO\n\nprint('YAHOO standard quote, typed data')\nprint(quotedata.get_quotes(['YHOO']))\n\n# Print mini quotes for YHOO, GOOGL, AAPL, MSFT, SPY, and GLD with data as \n# raw strings (done with one query to Yahoo, not 6!).\nprint('\\nMultiple Miniquotes, raw strings:')\nfor quote in quotedata.get_quotes(['YHOO','GOOGL','AAPL','MSFT','SPY','GLD'],MINIQUOTE,True):\n    print (quote)\n\n# Print the last 5 days' worth of historic quote data for YHOO\nprint('\\nYHOO data for the 5 most recent trading days')\nfor day in historicdata.get_number_of_historical_quotes('YHOO',5):\n        print(day)\n```\n\n**Results:**\n\n```\nYAHOO standard quote, typed data\n[{'previous_close': 35.43, '1_yr_target_price': 41.23, 'day_low': 35.45, 'error_indication': 'N/A', 'name': 'Yahoo! Inc.', '52_week_high': 41.72, 'average_daily_volume': 19843500.0, 'pe_ratio': 29.55, 'symbol': 'YHOO', 'earnings_per_share': 1.199, 'volume': 18688504.0, 'trailing_dividend_per_share': 0.0, 'market_capitalization': 35943000000.0, 'last_trade_date': datetime.date(2014, 7, 14), 'last_trade_price_only': 35.7, 'day_high': 35.95, 'dividend_yield': None, 'open': 35.74, '52_week_low': 26.73, 'change': 0.27}]\n```\n\n```\nMultiple Miniquotes, raw strings:\n{'day_low': '35.45', 'error_indication': 'N/A', 'name': 'Yahoo! Inc.', 'average_daily_volume': '19843500', 'symbol': 'YHOO', 'volume': '18688504', 'last_trade_price_only': '35.70', 'day_high': '35.95', 'open': '35.74', 'change': '+0.27'}\n{'day_low': '586.693', 'error_indication': 'N/A', 'name': 'Google Inc.', 'average_daily_volume': '2075450', 'symbol': 'GOOGL', 'volume': '1954612', 'last_trade_price_only': '594.26', 'day_high': '594.86', 'open': '590.70', 'change': '+7.61'}\n{'day_low': '95.65', 'error_indication': 'N/A', 'name': 'Apple Inc.', 'average_daily_volume': '65240800', 'symbol': 'AAPL', 'volume': '42810156', 'last_trade_price_only': '96.45', 'day_high': '96.89', 'open': '95.86', 'change': '+1.23'}\n{'day_low': '42.04', 'error_indication': 'N/A', 'name': 'Microsoft Corpora', 'average_daily_volume': '27786900', 'symbol': 'MSFT', 'volume': '21882944', 'last_trade_price_only': '42.14', 'day_high': '42.45', 'open': '42.22', 'change': '+0.05'}\n{'day_low': '197.44', 'error_indication': 'N/A', 'name': 'SPDR S\u0026P 500', 'average_daily_volume': '84223000', 'symbol': 'SPY', 'volume': '58657920', 'last_trade_price_only': '197.60', 'day_high': '197.86', 'open': '197.61', 'change': '+0.99'}\n{'day_low': '125.45', 'error_indication': 'N/A', 'name': 'SPDR Gold Trust', 'average_daily_volume': '6160990', 'symbol': 'GLD', 'volume': '11469917', 'last_trade_price_only': '125.72', 'day_high': '126.10', 'open': '125.50', 'change': '-3.06'}\n```\n\n```\nYHOO data for the 5 most recent trading days\n{'day_low': 34.28, 'symbol': 'YHOO', 'trade_date': datetime.date(2014, 7, 8), 'volume': 23096900.0, 'last_trade_price_only': 34.53, 'day_high': 35.66, 'open': 35.64, 'adjusted_close': 34.53}\n{'day_low': 34.68, 'symbol': 'YHOO', 'trade_date': datetime.date(2014, 7, 9), 'volume': 12626900.0, 'last_trade_price_only': 34.85, 'day_high': 35.07, 'open': 34.68, 'adjusted_close': 34.85}\n{'day_low': 34.1, 'symbol': 'YHOO', 'trade_date': datetime.date(2014, 7, 10), 'volume': 18064800.0, 'last_trade_price_only': 34.93, 'day_high': 34.97, 'open': 34.33, 'adjusted_close': 34.93}\n{'day_low': 34.78, 'symbol': 'YHOO', 'trade_date': datetime.date(2014, 7, 11), 'volume': 18303700.0, 'last_trade_price_only': 35.43, 'day_high': 35.56, 'open': 34.95, 'adjusted_close': 35.43}\n{'day_low': 35.45, 'symbol': 'YHOO', 'trade_date': datetime.date(2014, 7, 14), 'volume': 18680500.0, 'last_trade_price_only': 35.7, 'day_high': 35.95, 'open': 35.8, 'adjusted_close': 35.7}\n```\n\n## Getting Current Stock Data\n\n### Getting Data for Multiple Symbols\n\nTo get current stock data for multiple symbols, use the method `get_quotes()` in quotedata.py. Using this method for multiple symbols is up to 200 times faster than querying for each symbol individually.\n\n```python\nget_quotes(symbolList,dataList,raw)\n```\n\n* `symbolList`: List of symbols. For example `[‘YHOO','GOOGL’]`.\n* `dataList`: List of requested data (like `[VOLUME_STR, LAST_TRADE_PRICE_ONLY_STR]` or some predefined list like `MINIQUOTE`. Default is `STANDARDQUOTE`. \n* `raw`: Boolean declaring whether to return raw or typed data. Default is `false` (typed data).\n\n### Getting Data for Single Symbol\n\nTo query for data for a single symbol, the method `get_quote()` in quotedata.py\ncan be used although it simply creates a single item list and calls `get_quotes`.\n\n```python\nget_quote(symbol,dataList,raw)\n```\n\n* `symbol`: Symbol string. For example `’YHOO’`. \n* `dataList`: List of requested data (like `[VOLUME_STR, LAST_TRADE_PRICE_ONLY_STR]` or some predefined list like `MINIQUOTE`. Default is `STANDARDQUOTE`.\n* `raw`: Boolean declaring whether to return raw or typed data. Default is `false` (typed data).\n\n## Getting Historic Data\n\nYahoo's historic stock data API is a little different. There is no way to grab\ndata for more than one symbol at a time. pyhoofinance does offer two options \nfor retrieving data which are described in this section.\n\nNote: there is currently no option to return data as raw strings.\n\n### Stock Data For Range of Days\n\nTo get data for a range of days from a start date to an enddate (inclusive), use\n`get_range_of_historical_prices()`.\n\n```python                                  \nget_range_of_historical_quotes(symbol, startDate, endDate)\n```\n\n* `symbol`: Symbol string. For example `’YHOO’`.\n* `startDate`: First date to grab. Date type.\n* `endDate`: Last date (date type) to grab. Default is `datetime.today()`.\n\n### Stock Data For Number of Days\n\nThis is an incredibly useful building block for calculating averages. In order\nto get historic stock data for a number of days, use \n`get_number_of_historic_quotes()`.\n\n```python\nget_number_of_historical_quotes(symbol, numDays, endDate)\n```\n\n* `symbol`: Symbol string. For example `’YHOO’`.\n* `numDays`: Integer number of days of data to retrieve.\n* `endDate`: Last date (date type) to grab. Default is `datetime.today()`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnes213%2Fpyhoofinance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnes213%2Fpyhoofinance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnes213%2Fpyhoofinance/lists"}