Skip to content

Cookbook: stops, targets and changes

Copy-paste examples to set a stop loss, add take profit and targets, use trailing and breakeven, change leverage, ticker or exchange, pause and stop.

On this page

Examples are shown as an MCP tool call and as curl ($API is https://app.prowdex.com/api/v1, $PROW_KEY is your key). A bot is either a draft (not started yet) or running. The two are changed in different ways, so every recipe says which.

Change a running bot

Prow fixes some settings when a bot starts and lets a few change afterwards. A key may change only the few that can be changed without signing again, and only in the safer direction.

SettingOn a draftOn a running bot
Take profit (takeProfitPct, tpPct, botTpPct)update_bot_draftedit_bot: set one, or lower it
Trailing take profit (trailingTpPct)update_bot_draftedit_bot: set one, or lower it
Trailing stop of a DCA bot (trailingSlPct)update_bot_draftedit_bot: set one, or lower it
Pump protection, cooldown, repeat, range exit, take-on-crossupdate_bot_draftedit_bot, only the safer way (see below)
Stop loss (slLow, slHigh, slPct)update_bot_draftSigned at the start: stop the bot first
Range, level count, investment, leverage, loss limit, order sizesupdate_bot_draftSigned at the start: stop the bot first
Market or exchangeupdate_bot_draftNot possible on a running bot: copy it with duplicate_bot

What a key may do with a running bot, setting by setting. Anything else answers needs_owner with a link to the bot in Prow, where you make the change yourself.

SettingA key mayA key may not
takeProfitPct, botTpPctSet one where none is set (from 1 to 100), or lower itRemove it, or raise it
tpPctLower itRaise it
trailingTpPctLower itSet one where there is none, remove it, or raise it
trailingSlPct, pumpMovePctSet one where none is set, or lower itRemove it, or raise it
rangeExitGo from off to close, or from keep to closeSet keep, or switch it off
takeOnCrossSet falseSet true
cooldownSecMake it longerMake it shorter
repeatSet falseSet true
tpFromSet averageSet base
alertPct (spot hedge)Raise it: the alert fires when liquidation is within this many percent of the price, so a higher value fires earlierLower it
addMarginReminder (spot hedge)Set trueSet false

What the range exit values mean: off does nothing at the edge of the range and the bot goes on with its take profit, keep ends the bot at the edge and keeps the position under its stop with no take profit applying to it any more, close ends the bot at the edge and closes the position. A key sets close only, and close ends the bot and closes the position when the price leaves the range. A trailing take profit is not set by a key where there is none, because it replaces the exit at the target with one that can end below it.

Tighter can close a bot, so a key is held to floors: a take profit is at least 1 percent, a trailing take profit, trailing stop or DCA take profit at least 0.5, pump protection at least 1, and one call lowers a distance by at most half (a take profit of 15 goes to 7.5 or more). A key changes a bot only while it runs: on a paused or stopping bot every edit by a key answers needs_owner ("the bot is paused"), because a setting could end the bot the moment it runs again. While it runs, the bots service refuses an edit that would close the bot or a deal at once, and says which: a take profit the bot's profit has already reached (takeProfitPct, botTpPct), a DCA take profit that the price is already past (tpPct, tpFrom moved to average, or a lower tpPct that pulls one of several targets under the price, which would sell part of the deal at market now), a range exit when the price is already outside the range, and a tighter trailing take profit when the profit has already fallen back further than that from the peak the bot recorded (grid) or the armed trail would fire (DCA). A DCA trailing stop is placed under the price (above, for a short), so it cannot end a deal by itself: it ends the deal only after a retrace of its distance. The bots service decides this from the bot's live state, so the answer to edit_bot is a request and last_edit in get_bot tells whether it was applied.

edit_bot answers edit_requested and Prow's bots service judges the edit once more against the live settings, which can differ from what you read a moment ago. If it refuses, get_bot shows last_edit with result: "refused" and the reason; if it applies, last_edit says applied and the log has the old and new values. Check last_edit before you assume a change happened.

To see what a bot has now and what a key may change, call get_bot: settings and protection show the stop loss, take profit, targets, trailing and loss limit (null means not set), editable_with_edit_bot lists the settings and edit_rules says which way each may move.

json
{ "name": "get_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" } }
bash
curl -sS "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" -H "x-api-key: $PROW_KEY"

Change the stop loss, range or leverage of a running bot

A running bot's stop loss, range, investment, leverage and loss limit cannot be changed, by a key or in the app. They are the limits you signed when it started. To change one you have to stop the bot and start a new one, and stopping closes the bot's position at market. If you do not want the position closed, leave the bot as it is.

Prow also runs one bot per market and account, so a copy cannot be made while the old bot is still on the market: duplicate_bot answers market_busy. The order that works is:

  1. Stop the bot

    stop_bot closes the position. It cannot be undone. Ask the owner of the account first.
  2. Wait until it has stopped

    Call get_bot until status is stopped. A stop is a request that Prow applies within seconds.
  3. Copy it

    duplicate_bot with no arguments copies the stopped bot's last settings into a new draft on the same market, keeping its own prices (range, stops, targets). If the price has moved far from the range, validate warns you: change the prices with update_bot_draft. The answer has the draft object.
  4. Change the copy

    update_bot_draft with fields changes only what you name, for example the stop loss.
  5. Start it in Prow

    Open confirm_url, check the limits and press Start.
json
{ "name": "stop_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/stop" -H "x-api-key: $PROW_KEY"
json
{ "name": "duplicate_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/duplicate" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" -d '{}'

The next sections show how to change the stop loss, leverage, ticker and exchange of the draft you get.

Set or move a stop loss

On a draft. Send only the setting to change in fields. A grid uses slLow (long and neutral) and slHigh (short and neutral), a DCA bot uses slPct. Prow checks the whole draft again and saves it.

These prices are examples and will not pass today. Take a live example from get_bot_type_schema (same venue, market and direction), change only what you want, and send that.

json
{ "name": "update_bot_draft", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "fields": { "slLow": 88000 } } }
bash
curl -sS -X PUT "$API/bots/drafts/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"slLow":88000}}'

fields changes the settings the draft has now, so the rest stays. To replace all the settings send draft instead, in the shape the settings reference shows. Use one of them, not both.

On a running bot. Not possible: see the section above.

Add take profit and several targets

One take profit. A grid's takeProfitPct is a percent of the investment for the whole bot. A DCA bot's tpPct is a percent per deal and botTpPct is a percent of the investment for the whole bot.

On a running bot a key can set a take profit where none is set, or lower it:

json
{ "name": "edit_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "fields": { "takeProfitPct": 10 } } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/edit" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"takeProfitPct":10}}'

edit_bot is a request: Prow applies it within seconds, writes the old and new values in the bot's log, and sends you a notice that your key changed it (one notice every 10 minutes per bot, which lists every change made in that time; a restart of the bots service can drop the list of the later ones, and every change stays in the bot's log and in Activity). Call get_bot to confirm (settings.takeProfitPct). Raising a take profit, or sending null to remove one, answers needs_owner.

Several targets (DCA). tpTargets takes 2 to 4 targets. Each pct is further from the entry than the one before, and the share values add up to 100. The smallest share of the base order must still reach the venue's minimum order (tp_target_below_min): with shares of 40, 30 and 30, the base order needs to be at least four times the minimum. Add targets on a draft:

json
{
  "name": "create_bot_draft",
  "arguments": {
    "venue": "hyperliquid",
    "market": "ETH",
    "draft": {
      "type": "dca", "direction": "long", "investment": 100, "leverage": 2,
      "baseOrder": 50, "safetyOrder": 20, "safetyCount": 4, "deviationPct": 1.5,
      "tpPct": 2, "slPct": 12,
      "tpTargets": [ { "pct": 1.5, "share": 40 }, { "pct": 3, "share": 30 }, { "pct": 5, "share": 30 } ]
    }
  }
}
bash
curl -sS -X POST "$API/bots/drafts" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"venue":"hyperliquid","market":"ETH","draft":{"type":"dca","direction":"long","investment":100,"leverage":2,"baseOrder":50,"safetyOrder":20,"safetyCount":4,"deviationPct":1.5,"tpPct":2,"slPct":12,"tpTargets":[{"pct":1.5,"share":40},{"pct":3,"share":30},{"pct":5,"share":30}]}}'

Targets cannot be combined with a trailing take profit. On a running bot you cannot add targets. Lowering tpPct with edit_bot moves all the targets down in proportion.

Use a trailing take profit

A trailing take profit closes the bot when its profit falls back a set percent from the peak, after the take profit is reached. It replaces the exit at the target with one that can end below it, so a key does not turn it on for a running bot. Set it on a draft, in the settings (trailingTpPct, with a take profit). On a running bot that already has one, a key can lower it, and the peak the bot recorded is kept:

json
{ "name": "edit_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "fields": { "trailingTpPct": 2 } } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/edit" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"trailingTpPct":2}}'

A tighter trailing take profit can close the bot at once if the profit has already fallen back that far from its peak: the bots service then refuses it. A grid needs a take profit for it. A DCA bot's trailingTpPct must be below tpPct (at most 50), and it is not allowed together with tpTargets. Lower it by at most half in one call, and once every 10 minutes per bot.

Turn on a trailing stop

DCA bot. trailingSlPct is the distance in percent a trailing stop follows the best price. On a draft put it in the settings. On a running bot a key can set one where none is set, or lower it:

json
{ "name": "edit_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "fields": { "trailingSlPct": 3 } } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/edit" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"trailingSlPct":3}}'

Ladder. Its stop trails after the first take profit fills when combo.trailStop is true (the default). It is set when you make the draft.

Grid. A grid has a fixed stop loss. A spot grid can follow the price with trailingUp and trailingDown, which are set on the draft.

Use breakeven

Breakeven moves the stop to the entry after the first take profit target fills. On a DCA bot set breakeven: true together with tpTargets. On a Ladder set combo.breakeven: true. Both are signed at the start, so set them on the draft. The first target must be far enough to cover fees (breakeven_target_close), and the smallest share of the base order must reach the venue's minimum.

json
{
  "name": "create_bot_draft",
  "arguments": {
    "venue": "hyperliquid",
    "market": "ETH",
    "draft": {
      "type": "dca", "direction": "long", "investment": 100, "leverage": 2,
      "baseOrder": 30, "safetyOrder": 20, "safetyCount": 4, "deviationPct": 1.5,
      "tpPct": 2, "slPct": 12,
      "tpTargets": [ { "pct": 1.5, "share": 50 }, { "pct": 3, "share": 50 } ],
      "breakeven": true
    }
  }
}
bash
curl -sS -X POST "$API/bots/drafts" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"venue":"hyperliquid","market":"ETH","draft":{"type":"dca","direction":"long","investment":100,"leverage":2,"baseOrder":30,"safetyOrder":20,"safetyCount":4,"deviationPct":1.5,"tpPct":2,"slPct":12,"tpTargets":[{"pct":1.5,"share":50},{"pct":3,"share":50}],"breakeven":true}}'

Change leverage

Leverage is signed when a bot starts, so a running bot keeps it. On a draft send the new value in fields (1 to 5, and above 3 only on the deepest markets):

json
{ "name": "update_bot_draft", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "fields": { "leverage": 3 } } }
bash
curl -sS -X PUT "$API/bots/drafts/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"leverage":3}}'

A higher leverage moves the liquidation price closer. validate_bot_config returns it as liquidation_price. To change the leverage of a running bot, follow the steps above: stop it, copy it, change the copy, start it in Prow.

Change the ticker

Needs a connected account on the venue in Prow. Without one the answer is no_account (its shape is shown in Cookbook: build bots). The prices in the examples below (ETH 3300 to 3700) are only examples: take a live example from get_bot_type_schema (the venue, the market and the same direction) and use its prices, or let duplicate_bot move them for you.

A draft. Pass market to update_bot_draft, with settings whose prices fit the new market. The draft is checked on the new market and saved as a new draft (it has a new bot_id), and the old draft is removed. The answer has created: true and replaced_bot_id, the id of the draft it replaced. A coin in the draft's name ("BTC Grid #1" on a draft moved to ETH) becomes the new coin.

These prices are examples and will not pass today. Take a live example from get_bot_type_schema (same venue, market and direction), change only what you want, and send that.

json
{
  "name": "update_bot_draft",
  "arguments": {
    "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa",
    "market": "ETH",
    "draft": { "type": "grid", "direction": "long", "investment": 200, "leverage": 2, "lower": 3300, "upper": 3700, "count": 20, "slLow": 3150 }
  }
}
bash
curl -sS -X PUT "$API/bots/drafts/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"market":"ETH","draft":{"type":"grid","direction":"long","investment":200,"leverage":2,"lower":3300,"upper":3700,"count":20,"slLow":3150}}'

Any grid, DCA, QFL or Ladder bot or draft, with the prices moved for you. duplicate_bot copies the settings a bot has now onto another market as a new draft. The range, the stops, a trigger and the trailing limits move with the new market's price by the same rule Prow uses for a ready setting (a copy on the same market keeps the bot's own prices). Percentages, the number of levels, order sizes, leverage and the investment are copied as they are.

json
{ "name": "duplicate_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "market": "ETH" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/duplicate" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"market":"ETH"}'

The answer is a draft with confirm_url, draft (the settings, in the shape update_bot_draft takes) and copied_from (which bot, prices_rescaled, and when the prices moved, price_before, price_now and for a grid range_before and range_after). A copy is always a new draft with its own bot_id, even on the same market with the same settings; a copy on the same market is named like the source with "copy" added. When the prices moved, the message says so plainly ("Prices were moved to today's price of BTC") with the old and the new range. If the new market refuses the copy (below the venue's minimum order, a short grid on a market that is not among the deepest, too much leverage) the answer is invalid_settings with the reasons: change them with create_bot_draft. At 50 drafts it answers too_many_drafts and deletes none of yours: delete the ones you do not need first.

A running bot cannot change its market. Copy it with duplicate_bot to the other market, start the copy in Prow, then stop the old bot with stop_bot (its position is closed). Copying to another market needs no stop first.

Move a bot to another exchange

Needs a connected account on the new venue in Prow. Without one the answer is no_account.

Pass venue. The market keeps its name when the other venue lists the same coin.

json
{ "name": "duplicate_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "venue": "aster" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/duplicate" -H "x-api-key: $PROW_KEY" -H "Content-Type: application/json" \
  -d '{"venue":"aster"}'

To move a draft, call update_bot_draft with venue and a draft that fits the new venue (and market if the name differs). If you have more than one account on the new venue, add account_id. Arbitrage, Funding and the spot hedge keep no draft: call create_two_leg_bot_link again with the other coin or strategy.

Pause, resume and stop

Pause cancels the bot's entry orders and keeps its position and its stop. Resume works only for a bot this same key paused. Stop closes the position at market (a spot grid sells its inventory) and cannot be undone. All three are requests the bots service applies within seconds: call get_bot to confirm.

json
{ "name": "pause_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa", "idempotency_key": "pause-0001" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/pause" -H "x-api-key: $PROW_KEY" -H "Idempotency-Key: pause-0001"
json
{ "name": "resume_bot", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" } }
bash
curl -sS -X POST "$API/bots/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa/resume" -H "x-api-key: $PROW_KEY"

A bot can be paused or resumed again only a minute after the last pause or resume (bot_cooldown).

Stop everything

stop_all_bots stops every bot that is running, paused or starting, of every type, and closes their positions. The answer lists the bots it stopped and the ones it skipped with the reason.

json
{ "name": "stop_all_bots", "arguments": {} }
bash
curl -sS -X POST "$API/bots/stop-all" -H "x-api-key: $PROW_KEY"

Delete a draft

json
{ "name": "delete_bot_draft", "arguments": { "bot_id": "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" } }
bash
curl -sS -X DELETE "$API/bots/drafts/aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa" -H "x-api-key: $PROW_KEY"

Only an unstarted draft is deleted. A bot that has started is stopped with stop_bot.

Last updated