Skip to content

feat(paper): simulate viqc (volume in quote currency) for market buys - #64

Closed
richmiles wants to merge 1 commit into
krakenfx:mainfrom
richmiles:paper-viqc
Closed

richmiles wants to merge 1 commit into
krakenfx:mainfrom
richmiles:paper-viqc

Conversation

@richmiles

Copy link
Copy Markdown

What

kraken paper buy gains --oflags, and simulates viqc: the volume is a quote-currency amount, as on the live venue.

kraken paper buy BTCUSD 30 --oflags viqc      # buys $30 of BTC on paper

In a paper workspace, kraken order buy ... --oflags viqc now maps onto the same path instead of being refused.

Why

A dollar-cost-averaging agent places order buy BTCUSD 30 --type market --oflags viqc for real, but paper had no way to rehearse that order. The DCA skill told agents that paper buy takes base volume and had them compute it with bc. While testing kraken-mcp with a Claude agent in paper mode, converting dollars to volume, and getting the rounding and minimums right, was where it was most likely to slip.

Behavior

  • Only viqc is simulated, and only on market buys, matching the API rule ("supported only for buy market orders"). A sell, a limit order, or any other flag is refused by name, in the existing "honest validation" style.
  • The engine converts the amount to base volume at the fill price (slippage included), truncated to 8 decimals so the cost never exceeds the amount. It then fills through the existing market-order path, so the funds check and fee model are unchanged.
  • A live workspace still refuses --oflags. Its allocation ledger prices and reserves volume in the base asset, so a quote amount must not reach it. A test drives live_order_at with viqc and asserts zero AddOrder calls.
  • The journal records oflags: "viqc" on the command and on any rejection, and kraken replay shows it, so a logged volume is never misread as base. Old journals still load (the field is optional).
  • A paper --validate receipt reports the converted base volume.
  • README, AGENTS.md, the DCA skill, the changelog and the generated tool catalog are updated. The README states the limit: a viqc strategy does not yet survive promotion to live.

Open question

Paper charges the fee on top of the quote amount, as for every paper fill. I could not confirm from the docs whether the live venue's viqc takes the fee out of the amount instead. If it does, the paper fill should match.

Checks

cargo +nightly-2026-08-20 fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo doc -D warnings, the catalog check, prettier and markdownlint on the changed docs, and cargo test --workspace all pass. I also exercised it end to end against live prices in a paper workspace.

Written with help from Claude Code, then reviewed and tested.

`kraken order buy --oflags viqc` buys a quote amount on the live venue,
but `kraken paper buy` had no way to express it, and `order buy --oflags
viqc` in a paper workspace was refused. So the paper engine could not
rehearse the order a dollar-cost-averaging agent places for real; the
DCA skill had agents compute base volume with `bc` instead.

`paper buy`/`paper sell` gain `--oflags`. Only `viqc` is simulated, and
only for market buys, matching the API rule; any other flag, and viqc on
a sell or a limit order, is refused by name. The engine converts the
quote amount to base volume at the fill price (slippage included),
truncated to 8 decimals so the cost never exceeds the amount, then fills
through the existing market-order path, so the funds check and fee model
are unchanged.

In a paper workspace, `order buy --oflags viqc` now maps onto this path,
and a `--validate` receipt reports the converted base volume. A live
workspace still refuses `--oflags`: its allocation ledger prices and
reserves volume in the base asset. The journal records the flag on the
command and on any rejection, so a logged volume is read in the right
currency, and replay shows it.

README, AGENTS.md, the DCA skill and the changelog describe the flag and
its limit: a viqc strategy does not yet survive promotion to live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richmiles richmiles closed this Nov 10, 2026
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