Skip to content

historical: between() omits the end date for a continuous future - #1252

Open
faysou wants to merge 2 commits into
wboayue:mainfrom
faysou:historical/contfut-between
Open

faysou wants to merge 2 commits into
wboayue:mainfrom
faysou:historical/contfut-between

Conversation

@faysou

@faysou faysou commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Why

TWS rejects any end date on a historical bars request for a continuous future with error 10339 ("Setting end date/time for continuous future security type is not allowed"). between(start, end) always resolves to an end date plus a covering duration, so it could never be used for a CONTFUT contract; callers had to compute a duration themselves and trim the bars.

What

  • For a SecurityType::ContinuousFuture, between(start, end) sends no end date and a duration covering [start, now). The existing trim to [start, end) drops the bars after end, so the result is the same as for any other contract.
  • A start that is not before now is Error::InvalidArgument, with nothing sent.
  • ending() and between() rustdoc say what TWS does for a continuous future.
  • Wire-facts entry under market data; changelog entry under Fixed.

Verified

  • Live, paper TWS server 223, ES CONTFUT 1-hour TRADES bars: a duration with no end date returns 16 bars (2026-11-12 14:30 to 2026-11-13 21:00 UTC), the same with an end date returns 10339, and between(2026-11-12 14:00, 2026-11-13 21:00) on this branch returns 15 bars (the 21:00 bar is past end).
  • Unit tests: the range resolution with a fixed now, the error when start is not before now, and the sync and async request wiring (no end date, 11 D for a start 10 days less an hour back).
  • Gates: cargo fmt; clippy, rustdoc, and examples on the default, sync-only, and all-features legs; cargo test on all three legs; tools/check-rules-graph.sh. The sync-only test leg failed once without a reported test and passed on rerun.

TWS rejects any end date on a CONTFUT historical bars request (error
10339), and between() always sent one, so every such request failed.
For a continuous future, between() now sends no end date and a duration
covering [start, now), and the existing trim drops the bars after end.
A start that is not before now is InvalidArgument.

Verified live on paper TWS (server 223): ES CONTFUT 1-hour bars between
2026-11-12 14:00 and 2026-11-13 21:00 UTC returned 15 bars, where the
request had failed with 10339.
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