{"id":13699995,"url":"https://github.com/ZachLiuGIS/stock_extractor","last_synced_at":"2025-05-04T18:34:01.193Z","repository":{"id":3807941,"uuid":"50929545","full_name":"ZachLiuGIS/stock_extractor","owner":"ZachLiuGIS","description":"General Purpose Stock Extractors from Online Resources","archived":false,"fork":false,"pushed_at":"2022-12-26T20:00:47.000Z","size":21,"stargazers_count":48,"open_issues_count":4,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-05T23:47:22.031Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZachLiuGIS.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-02T15:19:10.000Z","updated_at":"2025-03-19T05:57:01.000Z","dependencies_parsed_at":"2023-01-13T12:45:51.408Z","dependency_job_id":null,"html_url":"https://github.com/ZachLiuGIS/stock_extractor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZachLiuGIS%2Fstock_extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZachLiuGIS%2Fstock_extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZachLiuGIS%2Fstock_extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZachLiuGIS%2Fstock_extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZachLiuGIS","download_url":"https://codeload.github.com/ZachLiuGIS/stock_extractor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382845,"owners_count":21739226,"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.886Z","updated_at":"2025-05-04T18:33:57.868Z","avatar_url":"https://github.com/ZachLiuGIS.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":["Data Sources"],"readme":"*****\nStock Extractor\n*****\n\nThis package includes a series of stock data extractor class from a few widely used sources, such as Yahoo Finance,\nBarchart.com, etc.\n\n\n=====\nInstallation\n=====\n\n``pip install stock_extractor``\n\nThe package has the following dependencies:\n\n\t* requests\n\t* pandas\n\t* beautifulsoup4\n\n\n=====\nUSAGE\n=====\n\nThe package currently has four extractor class\n\n\t* SP500Extractor\n\n\t  It is used to extract stock data about S\u0026P 500 companies\n\n\t* YahooFinanceInfoExtractor\n\n\t  It is used to extract latest stock data and information from Yahoo Finance\n\n\t* YahooFinanceHistoryQuoteExtractor\n\n\t  It is used to extract historical quote data for stocks from Yahoo Finance\n\n\t* YahooFinanceDivExtractor\n\n\t  It is used to extract historical dividend data for stocks from Yahoo Finance\n\nSP500Extractor\n-----\n\n.. code-block:: python\n\n\t# import extractor class\n\tfrom stock_extractor import SP500Extractor\n\n\textractor = SP500Extractor()\n\n\t# get_sp500_symbol_list() returns all SP500 company symbols as a list\n\tsp500_symbols = extractor.get_sp500_symbol_list()\n\n\t# get_sp500_data_by_type(type) retrieves sp500 company stock infomation and store the result in a pandas dataframe\n\t# type can be 'main', 'technical', or 'performance'\n\t# 'main' includes fields: 'Symbol', 'Name', 'Last Price', 'Change', 'Percent', 'High', 'Low', 'Volume', 'Time'\n\t# 'technical' includes fields: 'Symbol', 'Name', 'Last Price', 'Opinion', '20D-Strength', '20D-Volty', '20D-AVol', '52W-Low', '52W-High'\n\t# 'performance' includes fields: 'Symbol', 'Name', 'Last Price', 'Weighted-Alpha', 'YTD-Pct', '1Month-Pct Change', '3Month-Pct Change', '1Year-Pct Change'\n\textractor.get_sp500_data_by_type('technical')\n\n\t# get_sp500_full_data() will retrieve all three types of data and combine them into the dataframe\n\textractor.get_sp500_full_data()\n\n\t# get_dataframe() will return the dataframe that stores retrieved data\n\textractor.get_dataframe()\n\n\t# save_to_csv(filepath) will save the dataframe as a csv file\n\textractor.save_to_csv('sp500_data.csv')\n\n\nYahooFinanceInfoExtractor\n-----\n\nThis extractor class extract latest stock data and stock information on Yahoo Finance\nThe fields that can be extracted from this class include:\n\n'Ask', 'AvgDVol', 'AskSize', 'Bid', 'AskRealTime', 'BidRealTime', 'BookValue', 'BidSize', 'Change\u0026Pct', 'Change',\n'Commission', 'ChangeRealTime', 'AfterHourChangeRealTime', 'Dividend', 'LastTradeDate', 'TradeDate', 'EPS',\n'ErrorIndication', 'EPSE_CurrentYear', 'EPSE_NextYear', 'EPSE_NextQuarter', 'FloatShares', 'D-Low', 'D-High',\n'52W-Low', '52W-High', 'HoldingsGainPercent', 'AnnualizedGain', 'HoldingsGain', 'HoldingsGainPercentRealTime',\n'HoldingsGainRealTime', 'MoreInfo', 'OrderBookRealTime', 'MarketCap', 'MarketCapRealTime', 'EBITDA',\n'ChangeFrom52W-Low', 'PctChangeFrom52W-Low', 'LastTradeRealTime', 'PctChangeRealTime', 'LastTradeSize',\n'ChangeFrom52W-High', 'PctChangeFrom52W-High', 'LastTradeWithTime', 'LastTradePrice', 'HighLimit',\n'LowLimit', 'DayRange', 'DayRangeRealTime', '50MA', '200MA', 'ChangeFrom200MA', 'PctChangeFrom200MA',\n'ChangeFrom50MA', 'PctChangeFrom50MA', 'Name', 'Notes', 'Open', 'PreviousClose', 'PricedPaid', 'PctChange',\n'Price/Sales', 'Price/Book', 'Ex-DividendDate', 'P/E', 'DividendPayDate', 'P/E_RealTime', 'PEG',\n'P/E-EstCurrentYear', 'P/E-EstNextYear', 'Symbol', 'SharesOwned', 'ShortRatio', 'LastTradeTime', 'TradeLinks',\n'TickerTrend', '1YrTarget', 'Volume', 'HoldingsValue', 'HoldingsValueRealTime', '52W-Range', 'DayValueChange',\n'DayValueChangeRealTime', 'StockExchange', 'Yield'\n\nExample:\n\n.. code-block:: python\n\n\t# import extractor class\n\tfrom stock_extractor import YahooFinanceInfoExtractor\n\n\textractor = YahooFinanceInfoExtractor()\n\n\t# read a list of symbols from txt file.\n\t# extractor.set_symbol_list(symbol_list) can set symbol list as python list\n\textractor.read_symbol_list_from_txt('../sample_data/sample_symbol_list.txt')\n\n\t# set which fields are included in extraction\n\textractor.set_field_list([\n\t\t'Symbol', 'LastTradePrice', 'LastTradeDate', 'LastTradeTime', 'D-High', 'D-Low', '52W-High', '52W-Low',\n\t\t'50MA', '200MA', 'PctChangeFrom50MA', 'PctChangeFrom200MA', 'EBITDA', 'MarketCap',\n\t\t'Dividend', 'Yield', 'EPS', 'P/E', 'PEG', 'Price/Sales', 'Price/Book', 'Name'\n\t])\n\n\t# extract data from Yahoo Finance\n\textractor.load_yahoo_data()\n\n\t# save the result in a csv file\n\t# you can call extractor.get_dataframe() to return the result as pandas dataframe\n\textractor.save_to_csv('../output/sample_stock_info.csv')\n\nYahooFinanceHistoryQuoteExtractor\n-----\n\nThis extractor extract historical quote data for the input symbol list for a time span\n\nExample:\n\n.. code-block:: python\n\n\t# import extractor class\n\tfrom stock_extractor import YahooFinanceHistoryQuoteExtractor\n\n\textractor = YahooFinanceHistoryQuoteExtractor()\n\n\t# set start and end date for extraction\n\textractor.set_end_date('2016-01-01')\n\textractor.set_start_date('2015-01-01')\n\n\t# set symbol list, you can also set this from a txt file, see example above\n\textractor.set_symbol_list(['CAT', 'SPLS', 'ETP', 'HCP', 'T'])\n\n\t# the method that actually extracts data from Yahoo Finance\n\textractor.load_data_by_symbol_list()\n\n\t# filter out other fields, leave only adj price here since this field is usually what people need.\n\textractor.get_adj_price_only_dataframe()\n\n\t#return the result as a pandas dataframe\n\textractor.get_dataframe()\n\n\t# save the result as csv file\n\textractor.save_to_csv()\n\nYahooFinanceDivExtractor\n-----\n\nThis extractor extracts historical dividend data from Yahoo Finance.\nThe api is very similar to the previous one.\n\nExample:\n\n.. code-block:: python\n\n\t# import extractor class\n\tfrom stock_extractor import YahooFinanceDivExtractor\n\n\textractor = YahooFinanceDivExtractor()\n\textractor.set_end_date('2016-01-01')\n\textractor.set_start_date('2001-01-01')\n\textractor.read_symbol_list_from_txt('../sample_data/sample_symbol_list.txt')\n\textractor.load_data_by_symbol_list()\n\textractor.get_dataframe()\n\textractor.save_to_csv()\n\nTEST\n=====\n\nrun this code\n\n``$ python -m unittest discover``\n\n\nCONTACT\n=====\n\nThe package is created by Zach Liu. Please send email to zachliugis@gmail.com if you have questions or comments.\n\nLICENCE\n=====\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZachLiuGIS%2Fstock_extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZachLiuGIS%2Fstock_extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZachLiuGIS%2Fstock_extractor/lists"}