Skip to content

fix(messages): classify 2188 as a data advisory, not an error - #765

Merged
wboayue merged 2 commits into
wboayue:mainfrom
ms32035:fix/classify-2188-as-warning
Aug 27, 2026
Merged

fix(messages): classify 2188 as a data advisory, not an error#765
wboayue merged 2 commits into
wboayue:mainfrom
ms32035:fix/classify-2188-as-warning

Conversation

@ms32035

@ms32035 ms32035 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #764.

TWS sends 2188 (Up-to-the-second historical data requires additional subscription for the API.) on the error callback and then serves the historical data anyway — the account merely cannot receive the up-to-the-second tail.

Because 2188 sits outside WARNING_CODE_RANGE (2100..=2169) and was not in DATA_ADVISORY_CODES, classify_error routed it as RoutedItem::Error. historical_data() inspects only the first frame on its subscription, so it returned Err before HistoricalData arrived and the caller got no bars at all for every instrument whose real-time feed the account does not hold.

Change

Add 2188 to DATA_ADVISORY_CODES, whose doc comment already describes this case: an advisory on a request that then proceeds. RoutedItem::Notice is skipped by into_legacy(), so the fetch reads the following HistoricalData frame and returns the bars. Both the sync and async paths go through the same classifier, so the one constant covers both.

Tests

Regression tests on both fetch paths push a 2188 frame ahead of HistoricalData and assert the bars still arrive. Both fail on main without the classification change:

test market_data::historical::sync::tests::test_historical_data_up_to_the_second_advisory_is_skipped ... FAILED
test market_data::historical::async::tests::test_historical_data_up_to_the_second_advisory_is_skipped ... FAILED

Verified against a live gateway: a bulk daily-bar gather over a US equity universe on an account without NYSE Network A returned no bars for the affected symbols before the change, and the full history after it.

Checks

cargo fmt --check
cargo test                                    # async
cargo test --no-default-features --features sync
cargo test --all-features
cargo clippy --all-features --all-targets

All clean.

ms32035 and others added 2 commits August 26, 2026 22:16
TWS sends 2188 ("Up-to-the-second historical data requires additional
subscription for the API.") on the error callback and then serves the
historical data anyway — the account simply cannot have the
up-to-the-second tail. Because 2188 sits outside WARNING_CODE_RANGE
(2100..=2169) and was not in DATA_ADVISORY_CODES, classify_error routed
it as RoutedItem::Error. historical_data() inspects only the first frame
on its subscription, so it returned Err before HistoricalData arrived and
the caller got no bars at all for every instrument whose real-time feed
the account does not hold.

Add 2188 to DATA_ADVISORY_CODES, which already describes exactly this
case: an advisory on a request that then proceeds. RoutedItem::Notice is
skipped by into_legacy(), so the fetch reads the following HistoricalData
frame and returns the bars.

Regression tests on both the sync and async fetch paths push a 2188 frame
ahead of HistoricalData and assert the bars still arrive; both fail
without the classification change.
@wboayue
wboayue force-pushed the fix/classify-2188-as-warning branch from 27ce874 to eb790da Compare August 27, 2026 05:25
@wboayue

wboayue commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Thanks @ms32035 — excellent diagnosis in #764, and the live before/after verification plus regression tests on both fetch paths made this easy to confirm. I rebased onto main (resolving the overlap with #759), added a changelog entry, and updated the one remaining doc site (Notice::is_data_advisory) to include 2188. Merging.

@wboayue
wboayue merged commit 9d97926 into wboayue:main Aug 27, 2026
4 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.

historical_data() returns Err on notice 2188 and drops the bars TWS then sends

2 participants