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.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.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 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.1.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.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for financedatascraperonline-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f91e9fe1c393cd331378678ceb3523463f4422c5ecda7a606f0bd41ce0d09031
MD5 0f15eee704d743770a2bd74bed1d82be
BLAKE2b-256 97d1d05f8b1931fb876bba1c788bebdca970a2de218bebb20c4fff705036b7d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for financedatascraperonline-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 314111e93bf5d33bc892e73f965bfaecdd11a3cd68d9a8a2421c2bc4dbe31d02
MD5 4abe198ee777b364dcf5ec159dab5a6d
BLAKE2b-256 65b6af63e4f0a698bb5a39309d1141820b47bbc51527eca7b4d85638e2e36afc

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