Skip to content

Refactor config.toml to support multi-instruments per exchange - #44

Merged
tuxmonteiro merged 1 commit into
mainfrom
refactoring/multi-instrument-config
Aug 13, 2026
Merged

Refactor config.toml to support multi-instruments per exchange#44
tuxmonteiro merged 1 commit into
mainfrom
refactoring/multi-instrument-config

Conversation

@tuxmonteiro

Copy link
Copy Markdown
Contributor

Summary

Refactors the config schema to support multiple instruments per exchange. Per-instrument fields (instrument, suffix_topic, max_level, max_level_pct) are moved from the flat [source.<exchange>] section into a new [source.<exchange>.instrument.<alias>] sub-section. The <alias> key doubles as the fallback lookup key into [source.<exchange>.fallback.<alias>].

Changes

  • New InstrumentConfig struct — holds instrument, suffix_topic, max_level, max_level_pct
  • Restructured SourceConfig — removed instrument/alias/suffix_topic/max_level/max_level_pct; added instruments: HashMap<String, InstrumentConfig> keyed by alias
  • validated_sources() flattens — produces one ValidatedSource per instrument (sorted by exchange, then alias)
  • to_data_source() signature — now accepts alias: &str and instrument_cfg: &InstrumentConfig
  • 6 new tests for multi-instrument behavior (multiple instruments per exchange, fallback binding, alias-to-fallback key mapping, max_level forwarding)
  • Config files migrated to new schema
  • ADR-014 documenting the schema decision

Fixes #43

…hange>.instrument.<alias>]

Move instrument-level fields (instrument, suffix_topic, max_level,
max_level_pct) from [source.<exchange>] into a new
[source.<exchange>.instrument.<alias>] sub-section. The <alias> key
doubles as the fallback lookup key into [source.<exchange>.fallback.<alias>].

The alias field on SourceConfig is removed — it becomes the HashMap key
instruments: HashMap<String, InstrumentConfig>. validated_sources() now
flattens over all (exchange, instrument) pairs, producing one
ValidatedSource per instrument. to_data_source() takes the alias and
InstrumentConfig as parameters.

Add InstrumentConfig struct, update SourceConfig, update all tests,
migrate config.toml.example, update README and AGENTS.md. Adds ADR-014.

Breaking change: existing config.toml files with instrument fields at
the [source.<exchange>] level must be migrated to the new nested layout.
@tuxmonteiro
tuxmonteiro merged commit 7094a3b into main Aug 13, 2026
2 checks passed
@tuxmonteiro
tuxmonteiro deleted the refactoring/multi-instrument-config branch August 13, 2026 10:12
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.

Refactor config.toml to support multi-instruments per exchange

1 participant