From 4fd2073b63aee1070fe9d1604f9f3dedd5fc6a5e Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 17 Sep 2025 15:29:18 -0400 Subject: [PATCH] improvement: Lookup timestamp col by index rather than name --- .../MarketData/Live/ReplayFutureLiveBBOStream.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/DataStreamSuite/SharedStreams/BlueOrb/MarketData/Live/ReplayFutureLiveBBOStream.cs b/src/DataStreamSuite/SharedStreams/BlueOrb/MarketData/Live/ReplayFutureLiveBBOStream.cs index 67357fdb5..1aa73abcb 100644 --- a/src/DataStreamSuite/SharedStreams/BlueOrb/MarketData/Live/ReplayFutureLiveBBOStream.cs +++ b/src/DataStreamSuite/SharedStreams/BlueOrb/MarketData/Live/ReplayFutureLiveBBOStream.cs @@ -6,6 +6,7 @@ using BCG; using Bts.DataStream; + using Bts.DataStreamCore; using Spark.Core.Disposables; @@ -26,6 +27,8 @@ readonly ViewStream source; private RowsWithPointer _rows = new RowsWithPointer(); IDisposable? sourceSub; + // The index of the 'ts_event' column (it's resolved on the first update). + int timestampIndex = -1; public ReplayFutureLiveBBOStream(string continous_contract) { Func iso_8601_now = () => { @@ -79,7 +82,10 @@ _rows.rows = new List(0); return; } - _rows.rows = source.rows.Cast().OrderBy(r => r.GetDateTime("ts_event")).ToList(); + if (timestampIndex == -1) { + timestampIndex = source.rows.schema.ResolveIndices("ts_event"); + } + _rows.rows = source.rows.Cast().OrderBy(r => r.GetDateTime(timestampIndex)).ToList(); } void OnSourceChanged(object obj) => @@ -92,12 +98,12 @@ } public void doWork() { - if (_rows.rows is null || _rows.rows.Count == 0) { + if (_rows.rows is null || _rows.rows.Count == 0 || timestampIndex == -1) { return; } IBlueRow cand_row = _rows.rows[_rows.pointer]; - string cand_ts_event = cand_row.get("ts_event"); - DateTime cand_ts_event_dt = DateTime.Parse(cand_ts_event, null, System.Globalization.DateTimeStyles.RoundtripKind); + var cand_ts_event_dt = cand_row.GetDateTime(timestampIndex) + ?? throw new InvalidOperationException("Failed to get timestamp from row"); TimeSpan cand_ts_span_file = cand_ts_event_dt - _last_fire_time.last_fireitme_file; TimeSpan ts_clock = DateTime.Now - _last_fire_time.last_firetime_clock; if (ts_clock >= cand_ts_span_file) {