Skip to content

fix(nasdaq): keep a split whose ratio has no "a : b" form - #7760

Open
artcashin wants to merge 2 commits into
openbq-org:developfrom
artcashin:fix/nasdaq-splits-unparseable-ratio
Open

artcashin wants to merge 2 commits into
openbq-org:developfrom
artcashin:fix/nasdaq-splits-unparseable-ratio

Conversation

@artcashin

Copy link
Copy Markdown
Contributor

Problem

equity.calendar.splits (provider nasdaq) fails for any window that includes a percentage stock dividend. Nasdaq lists those in the splits calendar with a ratio like 5%, which has no a : b form. _split_ratio correctly returns (None, None), but the standard CalendarSplitsData requires numerator and denominator. So the row fails validation, and the whole request fails with it.

Change

NasdaqCalendarSplitsData declares numerator and denominator as float | None. A row whose ratio doesn't parse is kept: it has null numerator and denominator, and its published ratio in ratio_display. Parsed ratios are unchanged.

Tests

New tests/test_models_calendars.py::TestCalendarSplits::test_keeps_a_row_whose_ratio_has_no_two_parts. It passes 1 : 10, 1-for-10 and 5%, and expects three rows: the first with 1.0 / 10.0, the other two with nulls and their published ratio.

The test fails without the change and passes with it. The provider suite passes: 531 tests (Python 3.12).

Results from a deployment

We run this as an overlay on the 2.0.0 wheel in OpenBQ's Docker image. Before the change, a sweep of every widget failed the splits calendar on a split ratio it couldn't parse. With it, the widget returned 453 rows.

Not included

The standard model in openbb_core still requires both fields, so this only covers the Nasdaq provider.

🤖 Generated with Claude Code

Nasdaq's splits calendar also lists percentage stock dividends, published
with a ratio such as "5%". _split_ratio returns no numerator or denominator
for those, but the standard model requires both, so one such row failed
validation and the whole calendar request with it. The Nasdaq model makes
numerator and denominator optional; the row keeps its published
ratio_display.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@dlee-bq dlee-bq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @artcashin. I've highlighted a couple of items in the changed files. Please take a look.

json_schema_extra={"x-widget_config": CELL_CLICK_SYMBOL},
)
name: str | None = Field(default=None, description="The name of the company.")
numerator: float | None = Field(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rows that now pass validation fall through to the split_ratio fallback to_number(ratio), which strips the '%' and reports a 5% stock dividend as split_ratio=5.0, which reads as a 5-for-1 split under this endpoint's own convention ('1 : 10' gives 0.1).

Nasdaq row {ratio: '5%'} → numerator=None, denominator=None, split_ratio=5.0

The correct adjustment factor is 1.05. Anyone adjusting share counts or prices by split_ratio over-adjusts by roughly 5x.


assert rows == []

def test_keeps_a_row_whose_ratio_has_no_two_parts(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test never checks split_ratio, the one derived value whose behavior is changed.

The test passes while the 'CCC' / '5%' row carries split_ratio=5.0. Asserting r.split_ratio (expected None or 1.05) would have caught the bug in the first finding.

This branch has not been deployed

No deployments
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.

3 participants