Datasets¶
List of datasets¶
Dataset Name |
URL |
Description |
|---|---|---|
All Daily News |
Daily aggregated financial and macroeconomic news feed. Useful for sentiment analysis and event-driven strategies. |
|
Bonds Daily Price |
Historical daily bond price data across government and corporate bonds. |
|
Commodities Daily Price |
https://paperswithbacktest.com/datasets/commodities-daily-price |
Daily price data for major commodities such as oil, gold, and agricultural products. |
Cryptocurrencies Daily Price |
https://paperswithbacktest.com/datasets/cryptocurrencies-daily-price |
Historical daily prices for major cryptocurrencies. |
ETFs Daily Price |
Daily closing prices of exchange-traded funds (ETFs) globally. |
|
Forex Daily Price |
Daily foreign exchange rates between major and emerging market currencies. |
|
Indices Daily Price |
Historical daily prices for global stock market indices. |
|
Stocks 1-Min Price |
Intraday 1-minute price data for major equities. Ideal for high-frequency or intraday backtests. |
|
Stocks Daily Price |
Historical daily stock price dataset covering global exchanges. |
|
Stocks Quarterly Balance Sheet |
https://paperswithbacktest.com/datasets/stocks-quarterly-balancesheet |
Company-level quarterly balance sheet fundamentals. |
Stocks Quarterly Cash Flow |
https://paperswithbacktest.com/datasets/stocks-quarterly-cashflow |
Company-level quarterly cash flow statements. |
Stocks Quarterly Earnings |
https://paperswithbacktest.com/datasets/stocks-quarterly-earnings |
Quarterly earnings reports and EPS data. |
Stocks Quarterly Income Statement |
https://paperswithbacktest.com/datasets/stocks-quarterly-incomestatement |
Quarterly income statements providing revenue, expenses, and profit metrics. |
Best Alternative Data |
https://paperswithbacktest.com/datasets/best-alternative-data |
Curated collection of alternative datasets (e.g., sentiment, macro signals, ESG metrics). |
Arguments¶
Load daily stock price data for specific symbols using the load_dataset function. The first call retrieves data for Apple and Microsoft. The second call retrieves the same stocks but without price adjustments (adjust=False). The third call loads daily price data for the S&P 500 index:
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["AAPL", "MSFT"],
)
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["AAPL", "MSFT"],
adjust=False,
)
df = pwb_ds.load_dataset(
"Stocks-Daily-Price",
["sp500"],
)
The extend=True argument instructs the function to return an extended historical data using indices, commodities, and bonds data.
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"ETFs-Daily-Price",
["SPY", "IEF"],
extend=True,
)
The argument rate_to_price=False specifies that bond yield rates should not be converted to price values in the returned data:
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Bonds-Daily-Price",
["US10Y"],
rate_to_price=False,
)
The argument to_usd=False indicates that the data should not be converted to U.S. dollars, implying that it might be available in another currency.
import pwb_toolbox.datasets as pwb_ds
df = pwb_ds.load_dataset(
"Indices-Daily-Price",
["US10Y"],
to_usd=False,
)
Forex pairs: either spelling¶
Forex-Daily-Price holds each currency pair under one spelling, the one with the
longest history (USDJPY since 1971, XAUUSD since 1970). A pair can be asked
for under either spelling; the loader reads the series the table keeps and
inverts it when the other spelling was asked for (open, close → 1/x,
high → 1/low, low → 1/high, volume unchanged).
import pwb_toolbox.datasets as pwb_ds
# Default to_usd=True: every pair comes back as dollars per unit of the other
# currency, named XXXUSD, whichever spelling was asked for.
pwb_ds.load_dataset("Forex-Daily-Price", ["USDJPY"]) # symbol JPYUSD, ~0.0063
pwb_ds.load_dataset("Forex-Daily-Price", ["JPYUSD"]) # the same series
# to_usd=False: each name as spelled.
pwb_ds.load_dataset("Forex-Daily-Price", ["USDJPY", "JPYUSD"], to_usd=False)
# USDJPY ~158 (raw) and JPYUSD ~0.0063 (its inverse)
Minute bars: bound the read with start, end and columns¶
Stocks-1Min-Price, Cryptocurrencies-1Min-Price and Forex-1Min-Price are
stored as one parquet shard per month (data/train-YYYY-MM.parquet, about
350 MB a month for the stocks, ~75 GB in all). symbols= alone keeps memory
bounded to the matching rows, but every month is still downloaded. Pass a
window and the columns you use:
import pwb_toolbox.datasets as pwb_ds
bars = pwb_ds.load_dataset(
"Stocks-1Min-Price",
symbols=["SPY", "QQQ"],
start="2024-01-01",
end="2024-03-31",
columns=["adj_open", "adj_close", "volume"],
)
start,end(date-like, inclusive) select the shards to download by the month in their names, before anything is fetched, and filter thedatetimecolumn (ordate) inside the parquet read. A bare date covers the whole day (end="2024-03-31"keeps the bars of 31 March); a bound with a time of day ("2024-03-15 09:30") is compared with the stored timestamps, which are naive. One shard on each side of the window may be opened as slack for bars shifted across a month boundary; their rows outside the window are dropped on read. Either bound may be left open.columnsreads only those columns plus the keys (symbol,datetime/date). Stock bars haveadj_open,adj_high,adj_low,adj_closeandvolume; crypto and forex bars haveopen,high,low,closeandvolume. An unknown column is an error.Rows and columns are filtered by Arrow before pandas sees them, so a shard is never materialised whole.
The same parameters work on every dataset whose shards are named by period
(the daily price tables are monthly too). On the daily price tables columns
selects among the adjusted result, since the adjustment needs every price
column. Without start, end and columns, load_dataset behaves as before;
on a minute dataset it then emits an UnboundedMinuteLoadWarning, because it is
about to download every month.
Option chains: load_option_chain¶
Options-Daily-Price holds every US-listed option contract that traded since June 2014, one row per contract and session (about 560 million rows, ~20 GB). It is not loaded with load_dataset, which downloads every shard before filtering and refuses this dataset. Use load_option_chain, which downloads only what it is asked for:
from pwb_toolbox.datasets import load_option_chain
chain = load_option_chain(
["SPY"], "2024-01-01", "2024-03-31",
columns=["expiration", "strike", "option_type", "close", "volume", "implied_volatility", "delta"],
)
underlyings(required): the tickers as the table spells them, the name at the time ("FB"before June 2022,"SPX"for SPX and SPXW).start,end(required): the session window, inclusive. Only the monthly shards that meet it are opened.columns(optional): what to download besidessymbol,dateandunderlying. Fewer columns, fewer bytes.
Inside each month only the row groups of the requested chains are fetched, by HTTP range requests: one chain-month costs a few MB (SPY, October 2026: 7.7 MB of a 274 MB shard). implied_volatility and the greeks are computed from the last trade of the day; see the dataset card for how far to trust them.
The loader does not answer an empty frame for a reason it could name:
a source that answers range requests with whole files raises
RangeNotSupportedError(nothing is downloaded whole); through the API, withHF_ACCESS_TOKENalso set, it reads from the Hub instead and says so in a warning;a file list whose names carry no month is sorted by the
datestatistics in each file’s footer (one range request per file), with a warning;a window the table does not cover, or chains with no row in it, return an empty frame with a warning that says which.
Kenneth French’s Data Library: load_french¶
The Fama-French factors, the momentum and reversal factors, the industry portfolios and the sorted portfolios of Kenneth R. French’s Data Library are loaded on the fly from the author’s site. They are not on the Hub and not behind the PWB API: the library grants no redistribution right, so the zip is downloaded on your machine and kept in a local cache. Cite the library in anything you build on it.
from pwb_toolbox.datasets import load_french, load_french_blocks, french_datasets
ff5 = load_french("ff5") # monthly, decimal returns
mom = load_french("mom", frequency="daily")
ind48_ew = load_french("ind48", weighting="equal")
ff3_annual = load_french("ff3", frequency="annual")
firms = load_french("25_size_bm", block="number_of_firms_in_portfolios")
french_datasets() # every file of the library
name: an alias (ff3,ff5,mom,st_rev,lt_rev,ind5…ind49,25_size_bm,100_size_bm) or any file name of the library, e.g.Portfolios_Formed_on_MEor6_Portfolios_ME_Prior_12_2.frequency:monthly,annual(both read the main file),daily,weekly.weighting:value(default) orequal, for portfolio files.block: any other table of the file (load_french_blocks(name)lists them: number of firms, average size, BE/ME…). Those are left as published; return tables are divided by 100.-99.99and-999are NaN. Monthly rows are dated at the month end, annual rows at December 31.
No point-in-time. The library is recomputed at each update (about monthly) and the whole history changes with it; only the latest computation is served, so no historical vintage can be loaded. Each frame carries attrs["downloaded_at"] and attrs["crsp_vintage"] (e.g. "202609") to tie a result to the copy it was computed on.
Cache. $PWB_FRENCH_CACHE_DIR, else $PWB_CACHE_DIR/french, else ~/.cache/pwb/french; copies are timestamped. A copy younger than max_age_days (7) is used without any request, refresh=True downloads again, and when the site is unreachable a stale copy is used with a warning.