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. 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.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). We scrape the data from Pensford.

  1. Getting daily closing stock prices for the past 3 years
from financedatascraperonline import HistoricalDailyStockPricesAPI
closing_prices_df = HistoricalDailyStockPricesAPI.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.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.InterestRatesScrapedData().get_scraped_treasury_bill_rates()

Here, we scrape US treasury bill rates from the (US Treasury 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.2.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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for financedatascraperonline-0.1.2.tar.gz
Algorithm Hash digest
SHA256 314c15af80fade734ca6bd1514cbe3397df0d0994cfec2fe3d1cfac0ed695d34
MD5 dcfdadff0397e77938ff8480d69fc57f
BLAKE2b-256 76f8b7f59a632195d763243a23fdb69f4cc598e5771264ae87d96bceedfe764f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for financedatascraperonline-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bae893e77b6af305ed0824a8525978c6e78e9ad674b6a754fe7349ca02284ebb
MD5 97a38c4ddf2ebbdb0c155619c292e6ee
BLAKE2b-256 d9c592b89029e4ad94b5da23b496b2c9e09e02adaa34ef62dc5b0f46d4cb00af

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