Repository navigation
feat(mdds)!: make bulk fetch opt-in, split one-day option chains by expiration, and bound requests by server silence - #1513
Merged
Merged
Conversation
A bounded-interval pull declines the time axis because interval bars accumulate from the request's window start, so a band seam changes bar values. That decline also dropped the right split for chain cross-products, which has no seam: each contract's bars come from its own request over the full window. A one-day chain at 1s or 1m therefore went out as one request, while the same chain over several days split by date. Split a both-rights chain at a bounded interval into one call band and one put band over the whole window. Keep both rights together when the query asks for the out_of_the_money implied-volatility method, which the server refuses on a single right because each strike's volatility comes from the other side; the planner now reads that field from the binomial Greeks queries.
request_timeout_secs wrapped the whole request in one timeout, the wait for a request permit included. The server prepares a large response before its first byte and then streams it for as long as the rows take, so a healthy pull that was still streaming failed at five minutes, and a request queued behind a full pool spent its time waiting. A request that sets no deadline now has no total limit. The configured seconds bound how long the server may stay silent: the open, and then each next message, through the same stall guard flat-file downloads use. A stall fails as a DeadlineExceeded status, which the retry policy treats as transient. An explicit per-call deadline still bounds the whole call, and zero still lifts every limit.
…ation A one-day option chain at a bar interval cannot be cut in time, because each bar accumulates from the window start, so it went out as at most two requests, one per right. On a full chain each of those carries hundreds of millions of rows on one server stream, which delivers a few tens of thousands of rows a second. A chain over every expiration now lists the day's contracts first and sends one request per expiration, calls and puts separately, each over the whole window, so every contract's bars are unchanged. The list asks for quoted contracts, which covers every contract with a bar, and forwards the query's max_dte so it names the same expirations as the chain. A chain with one expiration, a chain under a million bars, or a failed list keeps the call/put pair; a single-right chain, or an out_of_the_money Greeks chain that needs both rights, takes one band per expiration and otherwise stays one request.
The server refuses an OHLC chain whose expiration is `*` as a single request, but it serves each expiration on its own, so the expiration split turned a refused pull into a successful one. Bulk fetch must only change how a pull is fetched, never whether the server answers it. The split now applies only to the endpoints whose server serves an every-expiration chain on one request: quotes and the Black-Scholes and binomial Greeks. An OHLC chain keeps the call and put pair, whose requests the server refuses exactly as it refuses the single stream.
Which ways a large pull can be split depends on what the server accepts: the date and time bands rely on its inclusive window semantics, and the expiration split on it serving each expiration of a chain on its own. A change on the server side can break a split before the SDK follows it, so bulk fetch is too dependent on the server to be on by default. `bulk_fetch` now defaults to `"off"`, and every query runs as one request in the server's own order unless the caller sets `bulk_fetch = "auto"`. The README lists bulk fetch among the features with that caveat, and the bulk downloads article shows how to turn it on in each language and states that an OHLC chain over every expiration is refused rather than split.
The server prepares a large response before it sends its first row, and for a one-day chain of one-second bars that preparation can take longer than five minutes. With `request_timeout_secs` at 300, such a pull failed as a stall before any data arrived, although the server would have answered: one request for the SPY chain at one-second bars over ten minutes took 23 minutes in one run and stalled out in the other. The default is now 2700 seconds. The limit still applies only to silence, so a wedged stream still fails, and a caller who wants to give up sooner sets `request_timeout_secs` lower. The flat-file article no longer tells callers to lift the limit for a large download. A download that keeps streaming has no time limit, and lifting the limit would let a stalled download wait forever.
…y expiration A time split of a quote-tick chain does not divide the server's work: every time band still carries the whole chain, and the server prepares all of it before it sends a band's first row. On SPXW quote ticks from 09:30 to 09:45, the single request and the time split each sent nothing for five minutes, while one request per expiration and right returned 108,872,335 rows in 247 seconds. DIA over the same window took 75 seconds on the time split and 17 on the expiration split, with the same rows. A quote-tick chain over every expiration now takes the listing step a bar chain takes, sized at one quote a second per contract, and keeps its time bands as the fallback when the list fails or the chain is too small. Trades are not split this way: a trade chain is sparse enough that one request per expiration made SPXW trades about twice as slow as the time split.
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.
Three changes to large history pulls.
Bulk fetch is opt-in. Which ways a large pull can be split depends on what the server accepts: the date and time bands rely on its inclusive window semantics, and the expiration split below on it serving each expiration of a chain on its own. A change on the server side can break a split before the SDK follows it, so
bulk_fetchnow defaults to"off"and every query runs as one request in the server's own order unless the caller setsbulk_fetch = "auto". The CHANGELOG entry carries the migration for each language, and the bulk downloads article shows how to turn it on.One-day bar and quote-tick chains split by expiration and right. A bounded-interval pull declines the time axis because interval bars accumulate from the request's window start, so a band seam would change bar values. That decline also dropped the right split for chain cross-products, which has no seam: each contract's bars come from its own request over the full window. A one-day chain at
1sor1mwent out as a single request while the same chain over several days split by date. The planner now sends a both-rights chain at a bounded interval as one call band and one put band over the whole window. A chain over every expiration goes further: it lists the day's quoted contracts in one request, forwarding the query'smax_dte, and sends one request per expiration and right, each over the whole window. A chain with one expiration, a chain under a million bars or a failed list keeps the call and put pair. A quote-tick chain over every expiration takes the same listing step, because every band of its time split still carries the whole chain and the server prepares all of it before the band's first row: on SPXW quote ticks from 09:30 to 09:45 the single request and the time split each stayed silent for five minutes, while the expiration split returned 108,872,335 rows in 247 seconds. A trade chain keeps the time split, which is about twice as fast as one request per expiration for its sparse rows. Only endpoints whose server serves an every-expiration chain on one request take the expiration split (quotes and the Black-Scholes and binomial Greeks); the server refuses an OHLC chain over every expiration, and splitting it would answer a pull the single stream cannot. A binomial Greeks chain withimplied_vol_method="out_of_the_money"keeps both rights in every band, since the server refuses that method on a single right.request_timeout_secsbounds silence, not the whole request. The configured limit wrapped the whole request, the wait for a request permit included. The server prepares a large response before its first byte and then streams it for as long as the rows take, so a healthy pull that was still streaming failed at five minutes, through the local server and the MCP server as well. A request without its own deadline now has no total limit: the configured seconds bound the open and each next message, through the stall guard flat-file downloads already use. The default rises from 300 to 2700 seconds, because the server's preparation of a one-day chain of one-second bars can outlast five minutes before its first row; the flat-file article no longer tells callers to lift the limit. A stall fails as aDeadlineExceededstatus, which every binding already reports asDeadlineExceededError. An explicit per-call deadline still bounds the whole call, and zero still lifts every limit. Rust code that matchedError::Timeoutfor the configured limit should matchError::Grpc { kind: GrpcStatusKind::DeadlineExceeded, .. }; the CHANGELOG entry says so.Tests: the planner tests pin the whole-window call and put bands, the listing step, the OHLC exclusion and the
out_of_the_moneyexception on both axes; a table test pins the expiration bands built from a contract list (each expiration once, the right filter, the fallbacks); the wire test pins that an expiration band rewrites the contract's expiration and right; the config tests pin the"off"default; and a routing test drives a mock that keeps streaming past the configured limit, which fails against the previous wall-clock bound.