Live symbol resolution (instrument_id → symbol)#44
Merged
Conversation
Live data records carry only the opaque numeric hd.instrument_id; the gateway
announces the human-readable symbol out-of-band via SymbolMappingMsg. The Live
client now keeps a running instrument_id -> SymbolMappingMsg map, maintained by
the reader as those control records arrive.
- symbol_for(client, instrument_id_or_record; which=:in) -> resolve a record's
symbol (which=:out for the output symbol); returns nothing if unseen.
- symbol_map(client; which=:in) -> thread-safe snapshot Dict{UInt32,String}.
- add_symbol_mapping_callback(client, cb) -> cb(instrument_id, msg) on each
(re)mapping (lock-protected, errors logged-and-swallowed, mirrors
add_reconnect_callback).
symbol_for/symbol_map extend the DBN functions of the same name (the historical
side keys on metadata + a timestamp; the live map is current-state, so no
timestamp). Works in both typed and untyped mode and survives reconnects. In
typed mode the mapping is captured before the control_channel overflow-drop, so
it stays correct even when the control channel isn't drained.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The live counterpart to the historical symbol join (#39). Live data records carry only the opaque numeric
instrument_id; the gateway announces the human-readable symbol out-of-band viaSymbolMappingMsg. This adds a runninginstrument_id → symbolmap maintained by theLivereader so consumers can resolve a record's symbol without tracking control records themselves.API
which=:in(default) returns the subscribed symbol (stype_in_symbol, e.g."AAPL"or the parent"ES.FUT");which=:outreturnsstype_out_symbol.symbol_for/symbol_mapextend the same-named DBN functions — the historical side keys on metadata + a timestamp (ids are reused across a date range), while the live map is current-state, so no timestamp.Design notes
last_ts_event_by_id.control_channeloverflow-drop, so it's reliable even when a parent/continuous subscription floodsSymbolMappingMsgat startup and the user isn't drainingcontrol_channel.symbols_lock;symbol_mapreturns a copy; callbacks are snapshotted under the lock and fired outside it, with exceptions logged-and-swallowed (mirrorsadd_reconnect_callback).SymbolMappingMsg).SymbolMappingMsgis stored per id, so both:in/:outsymbols (and the[start,end]window) remain available.Tests / docs
test/test_live_symbols.jl(21 assertions): resolve in/out, record overload, remap-overwrites, snapshot-is-a-copy, callbacks (including map-already-updated and a raising-callback-swallowed case). Full suite 1900 pass.🤖 Generated with Claude Code