Skip to main content

Library for scraping financial data from online sources

Project description

Hello! This is a Python library for scraping various forms of public finance data in the USA. The code is shown in this GitHub repository: https://github.com/AvilashaHaldar/ajh_finance_scraper_python_library. Currently, this library can:

  1. Scrape forward 1 and 3 month SOFR curves

This can be done by doing:

from financedatascraperonline import InterestRatesScrapedData
forward_SOFR_curves_df, allowed_SOFR_lengths_months = InterestRatesScrapedData().get_scraped_SOFR_curves()

forward_SOFR_curves_df is a Pandas DataFrame containing the 1-month and 3-month forward SOFR rates for the next 10 years. allowed_SOFR_lengths_months is a NumPy array containg the allowed month lengths for the SOFR curves (currently only 1 and 3).

  1. Getting daily closing stock prices for the past 3 years
from financedatascraperonline import HistoricalDailyStockPricesAPI
closing_prices_df = HistoricalDailyStockPricesAPI().get_historical_prices_df(ticker_symbol)

closing_prices_df is a Pandas DataFrame of daily closing prices over the past 3 years containing the columns [Close, Log_Close, Daily_Returns, Annualized_Hist_Volatility, Annualized_Mean_Daily_Return]. Volatility and mean are rolling values calculated over a 252-day period. (We assume 252 business days in a year.)

  1. Compute a few key statistics from the past day
from financedatascraperonline import HistoricalDailyStockPricesAPI
mu, sigma, latest_price = HistoricalDailyStockPricesAPI().get_main_stats_from_hist_prices(ticker_symbol)

mu is the annualized mean daily log return of the last business day calculated for the last 252 days, sigma is the annualized standard deviation of daily log returns over the last 252 days, and latest_price is the last closing price.

  1. Scrape US treasury bill rates
from financedatascraperonline import InterestRatesScrapedData
treasury_bill_rates_df = InterestRatesScrapedData().get_scraped_treasury_bill_rates()

Here, we scrape US treasury bill rates from the website https://home.treasury.gov/resource-center/data-chart-center/interest-rates/TextView?type=daily_treasury_bill_rates&field_tdr_date_value=2025 and return the rates in a pandas dataframe.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

financedatascraperonline-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

financedatascraperonline-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file financedatascraperonline-0.1.0.tar.gz.

File metadata

File hashes

Hashes for financedatascraperonline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9b4c3d872909e2d80bce469b68c715d24cc6705db1da78a9a2379950f84d2e2f
MD5 c689722578dac37e33b262dc4e1b277e
BLAKE2b-256 bffe359bb1ea658bc7efcb57449652a5a51041fe48f3aaf8dc1b0e33f8c0bd3c

See more details on using hashes here.

File details

Details for the file financedatascraperonline-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for financedatascraperonline-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e99d2a6194cdf0173c7199f8c7a8e24b16d79574dc8d26f394f1cd51d5288fcf
MD5 181dd997ca0353fa460029cdc882de4e
BLAKE2b-256 bb9800ac2c776101e09ed0c7f8abb1684c61771d517364febe7e03386e29676a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page