Repository navigation
Fix history paging and trade tick source - #17
AlexCatarino wants to merge 5 commits into
Conversation
Page until a short page, resume at the last index timestamp without gaps or duplicates, and read trade ticks from the trades schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The workflow still pointed at the SDK template's projects. Tests that call the Databento API are left out because CI has no key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github.ref is refs/pull/N/merge there, which fetched Lean's own PR N. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEAN parses it as an int, so the empty value failed every test's setup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Requesting changes: the paging and trade-source fixes look right, but nothing shows they work against Databento.
1. Missing proof that the fix works against Databento. The description doesn't say how the change was tested. CI runs only the offline converter and mapper tests, so it doesn't cover the paging loop or the switch to the trades schema. GetTradesPagesPastLimitWithoutGapsOrDuplicates, GetLevelOneDataPagesPastLimitWithoutGapsOrDuplicates and ShouldFetchTicks need an API key, and nothing records that they ran. Please run them and add the results to the description: pass or fail, the record counts, and how many pages each one took. Please also add the outcome of an end-to-end tick trade history request through the history provider. Before and after this change, does it return more than 10,000 ticks with no book updates? That run is what users will see, and it's the evidence risk:low would need.
I checked the loop offline against a stubbed server that filters start (inclusive) and end on ts_recv and truncates at limit with 200 OK. With 20k–30k records and 1, 7 or 50 records per timestamp across page boundaries, it returned every record once, in order, in 3–4 requests. So the logic holds under those assumptions about the API. What's still missing is proof that Databento behaves that way.
2. The file rename is out of scope. Renaming DataBentoHistoryProivder.cs to DataBentoHistoryProvider.cs isn't part of #16. Please move it to its own PR. I'm leaving the CI workflow and test config fixes in: CI can't check this change without them.
Label: risk:high. This changes the history data users get, and there's no run against Databento yet. The results in item 1 would lower it.
| Assert.Greater(trades.Count, 10_000, "The window must span more than one page"); | ||
| Assert.IsTrue(trades.All(t => t.Action == ActionType.Trade)); | ||
| var barVolume = _client.GetHistoricalOhlcvBars("ESH5", start, end, Resolution.Minute, Dataset).Sum(b => b.Volume); | ||
| Assert.AreEqual(barVolume, trades.Sum(t => (decimal)t.Size)); |
There was a problem hiding this comment.
Does this hold exactly at the window edges? ohlcv-1m filters on ts_event, but trades filters on ts_recv. A trade whose ts_event is just before end and whose ts_recv is just after it is in the bars but not in the trades, and the reverse can happen at start. At 14:30 UTC on ESH5 that can happen. The run result in the review body would answer it. If the test fails for that reason, comparing over bars whose ts_event lies strictly inside the window would avoid the edges.
Closes #16.
Paging now continues until a page comes back short, because Databento returns
200 OKeven when it truncates. Each page resumes at the previous page's last index timestamp (ts_recv, orts_eventwhen a schema has nots_recv) and skips the records already emitted. Trade ticks are read from thetradesschema instead ofmbp-1.CI has failed on every run since this repo was created. This PR fixes it:
job-user-idbroke LEAN's setup.ReturnsCorrectDataBentoDataSetwas out of date.CI now runs only the offline tests, because it has no Databento key.
Also fixes the
DataBentoHistoryProivder.csfile name typo.