Skip to content

nominal_close: the price a stock traded at on the date (load_dataset, get_pricing, data.nominal) - #108

Merged
edarchimbaud merged 1 commit into
mainfrom
feat/nominal-close
Dec 2, 2026
Merged

edarchimbaud merged 1 commit into
mainfrom
feat/nominal-close

Conversation

@edarchimbaud

Copy link
Copy Markdown
Collaborator

Why

Stocks-Daily-Price has no raw price: close and adj_close are both back-adjusted for every later split (AAPL on 2020-08-28: 124.81 and 120.96, for a share that traded at 499.23). About 1 240 published strategies compare one of them to a price threshold, and 7 sort on the price level (reports/price-filter-lookahead-audit-2026-12-02.md; is_share_price_relevant: Sharpe +0.49 with the adjusted price, -0.54 with the nominal one). Approved by Édouard on 2026-12-02.

What

  1. pwb.datasets.nominal: nominal_price(df) adds nominal_open/high/low/close to a frame loaded with adjust=False (it refuses a frame without adj_close, whose close would be dividend-adjusted); nominal_factor(symbols, dates); load_splits(). Nominal = split-adjusted price x product of the Stocks-Daily-Splits ratios dated strictly after the row. Checked against the raw price of ShortOverShorted: 92.4 % of 844 653 stock-months within 10 %, against 43.3 % for adj_close.
  2. Options: load_dataset(..., nominal=True) (Stocks-Daily-Price only, computed before adjust), get_pricing(..., nominal=True) or a nominal_* field (absent for non-stocks), run_strategy(..., nominal=True) -> NominalPandasData, data.nominal[0] (NaN outside the stocks). Orders, fills and NAV still use the adjusted prices.
  3. Engine: backtrader takes the extra line natively. Tradewind did not: Feeds: lines declared by a subclass (data.nominal), as in backtrader tradewind#67 (open, not merged) adds declared feed lines. Until it is released, FEED_EXTRA_LINES is false on Tradewind and run_strategy(nominal=True) raises before loading anything.
  4. adjust=False: documented for what it returns, split-adjusted (not raw) OHLC and adj_close. The branch called df.drop(columns=["adj_close"]) without keeping the result; the dead line is removed but the behaviour is kept: 38 published strategies on papers origin/main (65f1098198) read both columns from one adjust=False load (6 of them ask columns=[..., "adj_close"], which would raise) -- e.g. leveraging_the_low_volatility_effect, volatility_momentum, mispricing_and_the_cross_section_of_stock_returns, the_best_defensive_strategies_two_centuries_of_evidence, categorical_thinking.... An effective drop would change their NAV or break them. No toolbox test depended on it.

Distributions (data-api#227): applied by default, on purpose

The brief said not to apply the 31 distribution rows. Measured on the 31 rows, the session before each: close is back-adjusted with those very ratios, so applying them gives the traded price and leaving them out divides it by the ratio.

row with the ratio without ShortOverShorted raw
GE 2021-07-30 (before 1:8, GEHC, GEV) 12.95 8.07 12.95
MMM 2024-03-28 106.07 88.69 106.78
A 2014-10-31 55.28 39.54 55.28
XPO 2021-07-30 138.69 80.73 138.69
DD 2025-10-31 81.65 34.16 (SOS broken on DD)

So the default applies them. distributions=False leaves them out (for a share-count factor), reading event_type when the dataset has it and otherwise DISTRIBUTION_ROWS, the 31 rows frozen with a pointer to data-api#227.

Defaults unchanged

Without nominal, every frame, panel and NAV is the one of 0.2.1: get_pricing calls load_dataset with the same arguments, the feed class is ArrayPandasData. A small real run (AAPL + SPY, 2020-08 -> today, Tradewind with #67) gives the same final value with and without nominal=True (209 511.70).

Tests

  • tests/test_nominal_price.py (offline, real rows of the Hub in tests/data/nominal): AAPL 2020-08-28 = 499.23; NVDA through the 2021 x4 (recorded as stock_dividend) and 2024 x10; C 2011-05-06 reverse split = 4.52; XOM without split = close; GE and DD distributions applied / left out; event_type column overrides the frozen list; refusal of an adjusted frame; load_dataset/get_pricing options; adjust=False columns. PWB_NETWORK_TESTS=1 runs the same values on the Hub (passed).
  • tests/test_nominal_feed.py: data.nominal bar by bar, NaN for an ETF, NAV identical, guard on an engine without feed lines.
  • Full suite: 537 passed / 7 skipped / 2 xfailed on Tradewind (Point-in-time exits: hold to the next rebalance at real prices (pit_exit="hold") #67 installed), 544 passed / 2 skipped on backtrader.

Not merged, nothing published on PyPI.

🤖 Generated with Claude Code

https://claude.ai/code/session_012zrKmQA3f7zJ5y5EL6MNjT

Stocks-Daily-Price has no raw price: close and adj_close are both back-adjusted
for later splits (AAPL 2020-08-28: 124.81 / 120.96, traded at 499.23).

- pwb.datasets.nominal: nominal_price(df), nominal_factor(symbols, dates),
  load_splits(); close x Stocks-Daily-Splits ratios dated after the row.
  Distributions recorded as splits (data-api#227) applied by default, since
  close carries them; distributions=False reads event_type, else a frozen
  list of the 31 rows.
- load_dataset(..., nominal=True), get_pricing(..., nominal=True) and the
  nominal_* fields; run_strategy(..., nominal=True) and NominalPandasData
  expose data.nominal (backtrader; Tradewind with tradewind#67).
- adjust=False documented for what it returns (split-adjusted OHLC and
  adj_close); the dead df.drop removed, behaviour kept (38 published
  strategies read both columns).
- Defaults unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zrKmQA3f7zJ5y5EL6MNjT
@read-the-docs-community

Copy link
Copy Markdown

📖 2 files modified


Preview · build overview · pwb-toolbox · built Dec. 2, 2026, 8:31 a.m. UTC

@edarchimbaud
edarchimbaud merged commit 83d91d1 into main Dec 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant