Repository navigation
fix(futures-paper): update trailing_anchor when editing stop_price on trailing-stop orders - #54
Closed
theghostmac wants to merge 1 commit into
Closed
theghostmac wants to merge 1 commit into
theghostmac wants to merge 1 commit into
Conversation
… trailing-stop orders
Contributor
|
Thanks @theghostmac! This is fixed in v0.5.0. Editing |
needaccforwhonix
pushed a commit
to needaccforwhonix/kraken-cli
that referenced
this pull request
Nov 7, 2026
Sign in from the browser to create a restricted, expiring Spot API key. The MCP server and the REPL ship as their own binaries, kraken-mcp and kraken-shell, installed next to kraken. A paper strategy can go live in a budget-fenced workspace, and a finished session packages as a recipe. A timed-out order, cancel, withdrawal or transfer is never resent, and an envelope that may hide an execution carries "verify_first": true. Upgrading from 0.4.1 needs action from scripts, agents and MCP clients: see CHANGELOG.md under 0.5.0. Includes community fixes from krakenfx#50, krakenfx#51, krakenfx#54, krakenfx#55 and krakenfx#56. Co-authored-by: theghostmac <83423188+theghostmac@users.noreply.github.com> Co-authored-by: SashaMIT <33847880+SashaMIT@users.noreply.github.com> Co-authored-by: sashaphmn <122053040+sashaphmn@users.noreply.github.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.
Summary
Fixes a bug in
FuturesPaperState::edit_orderwhere editing--stop-priceon an opentrailing-stoporder updatedstop_pricebut lefttrailing_anchorunchanged.Root Cause
TrailingStoporder is placed inplace_triggered_order(src/futures_paper.rs),trailing_anchoris initialized fromstop_price(Some(stop_price)).check_trailing_stop_triggerevaluates trigger deviation exclusively againstorder.trailing_anchor(neverorder.stop_price).FuturesPaperState::edit_orderonly updatedself.open_orders[idx].stop_price = Some(sp)whennew_stop_pricewas provided, leavingtrailing_anchorstale at its previous value. As a result, editing--stop-priceon atrailing-stoporder had no effect on trigger evaluation.Fix
FuturesPaperState::edit_order, whennew_stop_priceisSome(sp)andorder_type == FuturesOrderType::TrailingStop, updatetrailing_anchor = Some(sp)alongsidestop_price.edit_order_updates_trailing_stop_anchorinsrc/futures_paper.rs.Verification & CLI Proof
1. Place a
trailing-stoporder (--stop-price 90000) and edit--stop-priceBefore Fix (
futures_state.json)stop_priceupdated to85000.0, whiletrailing_anchorremained stuck at90000.0:{ "id": "FP-00003", "symbol": "PF_XBTUSD", "side": "Long", "size": 0.1, "filled_size": 0.0, "order_type": "TrailingStop", "price": null, "stop_price": 85000.0, "trigger_signal": "Last", "client_order_id": null, "reduce_only": false, "leverage": 10.0, "reserved_margin": 0.0, "status": "Open", "trailing_stop_max_deviation": 2.0, "trailing_stop_deviation_unit": "percent", "trailing_anchor": 90000.0 }After Fix (
futures_state.json)Editing
--stop-price 86000updates bothstop_priceandtrailing_anchorin lockstep:{ "id": "FP-00003", "symbol": "PF_XBTUSD", "side": "Long", "size": 0.1, "filled_size": 0.0, "order_type": "TrailingStop", "price": null, "stop_price": 86000.0, "trigger_signal": "Last", "client_order_id": null, "reduce_only": false, "leverage": 10.0, "reserved_margin": 0.0, "status": "Open", "trailing_stop_max_deviation": 2.0, "trailing_stop_deviation_unit": "percent", "trailing_anchor": 86000.0 }2. Automated Tests & Lints
cargo +nightly fmt --checkcargo clippy --all-targets -- -D warningscargo test --lib edit_order_updates_trailing_stop_anchor