Skip to content

gateway: take the farm channel role from the slot, not the farm name (ibx#253) - #255

Open
userFRM wants to merge 1 commit into
deepentropy:mainfrom
userFRM:fix/regional-hmds-channel
Open

gateway: take the farm channel role from the slot, not the farm name (ibx#253)#255
userFRM wants to merge 1 commit into
deepentropy:mainfrom
userFRM:fix/regional-hmds-channel

Conversation

@userFRM

@userFRM userFRM commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • connect_farm derived the farm's channel role from a literal US name (src/gateway.rs:510): if farm_id == "ushmds" { "2" } else { "1" }. Every regional HMDS name fell to the else and requested channel 1, the trading channel, for a historical-data transport.
  • The file already supports those names — parse_farm_route handles regional routes with a test for zdc1.ibllc.com/euhmds/4000, and the comments at :1197 and :1607 state that EU accounts route to eufarm/euhmds/secdefeu. The role check was the one place that still assumed US.
  • The choice is now farm_channel_id, keyed on the hmds suffix, so ushmds, euhmds and aphmds all take channel 2 and everything else stays on 1.
  • Closes gateway: farm channel role is derived from the literal name "ushmds", so a regional HMDS (euhmds) is established on the trading channel #253.

Test

hmds_farms_take_the_data_channel_in_every_region pins the mapping for all three HMDS regions plus usfarm, eufarm and secdefeu. It is a free function beside parse_farm_route, so the mapping is testable without standing up a socket — which is why it had no coverage before.

cargo test --lib — 803 pass, clippy clean. The two config::expiry_tests failures are present on main before this branch.

Not verified live

I have a US-routed account, so the EU path is unexercised here. The change is a pure widening: ushmds keeps the exact value it had, and only names that previously got the trading channel by accident are affected.

Test plan

🤖 Generated with Claude Code

@userFRM

userFRM commented Jul 28, 2026

Copy link
Copy Markdown
Author

Reworked. The first revision keyed the role off the farm name, and the name is not a reliable discriminator.

cashhmds is the counterexample, and it is already in this repo (tests/ib_paper_compat/connection.rs:47): it ends in hmds but the extra-farm path connects it on the trading slot. My suffix rule would have moved it to channel 2, so the fix traded one wrong classification for another. Routing tags also carry whatever the server sends, so no naming invariant exists to lean on.

The caller never needed to guess. connect_farm already receives the slot as its last argument — 18 from the trading call site, 17 from the market-data one (gateway.rs:1652, :1656, and the two reconnect paths). Reading that is correct for every farm name, including both euhmds and cashhmds. The two literals are now named constants.

Also fixed: my previous insertion split parse_farm_route's doc comment, leaving the parser undocumented and its doc describing the new helper. That was a plain mistake, now restored.

Still not established by this repo: that channel 2 is right for regional HMDS specifically. Tag 6171 assigns slot 17 for every region, so it follows that the routing request should match — but the only direct evidence for the value 2 is the original ushmds branch. If you have a capture of a regional account's farm logon, that settles it.

@userFRM
userFRM force-pushed the fix/regional-hmds-channel branch from d10dfa8 to 6348456 Compare July 28, 2026 19:34
@userFRM userFRM changed the title gateway: key the farm channel role on the hmds suffix, not the US name (ibx#253) gateway: take the farm channel role from the slot, not the farm name (ibx#253) Jul 28, 2026
@userFRM
userFRM force-pushed the fix/regional-hmds-channel branch from 6348456 to 7d677fd Compare July 29, 2026 10:32
…(ibx#253)

`connect_farm` picked the routing channel with `if farm_id == "ushmds"`, so a regional historical-data farm — `euhmds` on an EU-routed account — fell through to channel 1, the trading channel, while completing logon and looking established.

The name is the wrong discriminator. Routing tags carry whatever the server sends, and this codebase already connects `cashhmds` on the trading slot, so a suffix rule gets that one wrong in the other direction. The caller does not need to guess: it splits trading from market-data farms at the call site and already passes the slot as the last argument, 18 and 17 respectively.

`farm_channel_id` now reads that slot, and the two literals the call sites pass are named. Every farm on slot 17 takes channel 2 regardless of region or name, and everything else stays on channel 1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@userFRM
userFRM force-pushed the fix/regional-hmds-channel branch from 7d677fd to 23df2fc Compare July 29, 2026 10:38
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.

gateway: farm channel role is derived from the literal name "ushmds", so a regional HMDS (euhmds) is established on the trading channel

1 participant