Skip to content

feat(core-expert): cancel entry orders on core exit (MoonBot 7.73 N2) - #1487

Merged
guyverino merged 2 commits into
mainfrom
feat/core-exit-cancel
Nov 26, 2026
Merged

guyverino merged 2 commits into
mainfrom
feat/core-exit-cancel

Conversation

@guyverino

Copy link
Copy Markdown
Collaborator

What & why

MoonBot 7.73 N2 added a setting on its General tab: cancel the bot's own entry orders when the core exits. With it on, a core that is shut down (on Linux that includes systemd's SIGTERM) cancels its entries and pending orders before it closes. It never closes positions. This answers the "server switched off, buy orders stayed on the exchange" complaint: the watchdog still sees TurnOff and leaves the orders alone, so the core has to do it itself.

The terminal exposes it as one row on the expert window's General page, under the risk group, where MoonBot draws it.

Notable decisions

  • cancel_buys_on_exit stays Option<bool> end to end. A core older than N2 does not send the field: the row is disabled with the reason, the writer never invents the field for such a core, and a bulk overlay keeps each target's own presence of it.
  • OrderRulesSettings equality is structural. The session store dedupes arrivals with !=, so treating a missing flag as false there swallowed the None -> Some(false) transition when a core was updated to N2. The "absent behaves as false" rule lives only in agrees_in_effect, which the write confirmation uses.
  • The station MCP contract text says what null means for an optional field.

Known limitations

  • MoonProto fe02d799 projects Some(false) onto an older core from its compact settings packet (absorb.rs:121), so for a moment such a core can read as "off" rather than "absent" until the next full snapshot. The row is gated on the core's features, not on the snapshot. Reported to the library.

Issues

None of the 66 open issues tracks this setting.

How to verify

cargo build -p moon-ui-gpui --bin moonterminal --target x86_64-pc-windows-msvc --all-targets
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings
cargo test --workspace --target x86_64-pc-windows-msvc

Local, after the rebase on 183a39f7f: fmt --check exit 0, build --all-targets exit 0, clippy --workspace --all-targets --locked -D warnings zero warnings, cargo test --workspace 10580 passed / 0 failed, doc-tests green.

Adds trading.auto_start_2.cancel_buys_on_exit to the expert window's
General page as a standalone row under the risk group, as MoonBot draws
it. Kept as Option<bool> end to end: a core that does not send the field
(older than 7.73 N2) shows the row disabled with the reason, the writer
never invents the field for such a core and never turns a sent value
into None, and a bulk overlay keeps each target's own presence of it.

The area comparison reads a missing flag as false, so an older core
whose compact settings overlay projects Some(false) still confirms
unrelated order-rules edits. The probe fills an absent optional leaf in
its bases so a guarded setter is found for either value. The station
MCP contract text now says what null means for an optional field.
…ancel flag

The previous commit made OrderRulesSettings' PartialEq read a missing
cancel_buys_on_exit as false. The session store dedupes arrivals with
that same `!=`, so a core updated to 7.73 N2 (None -> Some(false)), or
an older core's full snapshot replacing the compact overlay's
Some(false), published no revision and left the expert window's row
disabled or live until another field moved.

PartialEq is structural again. The rule that an absent flag behaves as
false moves to OrderRulesSettings::agrees_in_effect, used only by the
write confirmation (rejection_within_mask, and through it agrees_within
and edit_satisfied).
@guyverino
guyverino merged commit 44b01ff into main Nov 26, 2026
12 checks passed
@guyverino
guyverino deleted the feat/core-exit-cancel branch November 26, 2026 11:13
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.

1 participant