Repository navigation
nominal_close: the price a stock traded at on the date (load_dataset, get_pricing, data.nominal) - #108
Merged
Conversation
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
|
📖 2 files modified Preview · build overview · pwb-toolbox · built Dec. 2, 2026, 8:31 a.m. UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Stocks-Daily-Pricehas no raw price:closeandadj_closeare 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
pwb.datasets.nominal:nominal_price(df)addsnominal_open/high/low/closeto a frame loaded withadjust=False(it refuses a frame withoutadj_close, whoseclosewould be dividend-adjusted);nominal_factor(symbols, dates);load_splits(). Nominal = split-adjusted price x product of theStocks-Daily-Splitsratios dated strictly after the row. Checked against the raw price of ShortOverShorted: 92.4 % of 844 653 stock-months within 10 %, against 43.3 % foradj_close.load_dataset(..., nominal=True)(Stocks-Daily-Price only, computed beforeadjust),get_pricing(..., nominal=True)or anominal_*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.FEED_EXTRA_LINESis false on Tradewind andrun_strategy(nominal=True)raises before loading anything.adjust=False: documented for what it returns, split-adjusted (not raw) OHLC andadj_close. The branch calleddf.drop(columns=["adj_close"])without keeping the result; the dead line is removed but the behaviour is kept: 38 published strategies on papersorigin/main(65f1098198) read both columns from oneadjust=Falseload (6 of them askcolumns=[..., "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:
closeis back-adjusted with those very ratios, so applying them gives the traded price and leaving them out divides it by the ratio.So the default applies them.
distributions=Falseleaves them out (for a share-count factor), readingevent_typewhen the dataset has it and otherwiseDISTRIBUTION_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_pricingcallsload_datasetwith the same arguments, the feed class isArrayPandasData. A small real run (AAPL + SPY, 2020-08 -> today, Tradewind with #67) gives the same final value with and withoutnominal=True(209 511.70).Tests
tests/test_nominal_price.py(offline, real rows of the Hub intests/data/nominal): AAPL 2020-08-28 = 499.23; NVDA through the 2021 x4 (recorded asstock_dividend) and 2024 x10; C 2011-05-06 reverse split = 4.52; XOM without split = close; GE and DD distributions applied / left out;event_typecolumn overrides the frozen list; refusal of an adjusted frame;load_dataset/get_pricingoptions;adjust=Falsecolumns.PWB_NETWORK_TESTS=1runs the same values on the Hub (passed).tests/test_nominal_feed.py:data.nominalbar by bar, NaN for an ETF, NAV identical, guard on an engine without feed lines.Not merged, nothing published on PyPI.
🤖 Generated with Claude Code
https://claude.ai/code/session_012zrKmQA3f7zJ5y5EL6MNjT