CCCryptoContext Docs
Tool reference

Protection and exits

Stops, take-profits (including staged legs), breakeven, trailing stops and ratchets.

set_protection

Set stop_loss, take_profit, breakeven, trailing and R-ratchet on a position in one call. A stop is never widened unless allow_widen:true and never removed unless allow_remove:true. The response states native vs worker protection for each leg. dry_run defaults to true: nothing is sent to the exchange until dry_run:false is passed explicitly. Responses on a simulated connection carry mode:"simulated". Requires the trade capability (Pro and above; simulated connections may trade on every tier).

Changes your exchange account or platform state. It previews by default: pass dry_run: false to execute. Paper mode forces a preview.

Capability: trade · mutating · REST: POST /v1/tools/set_protection

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
stop_lossnumberno—
take_profitnumberno—
breakevenobjectno—
trailingobjectno—
ratchetobjectno—
take_profit_legsobject[]no—
allow_widenbooleanno—
allow_removebooleanno—
lease_tokenstringno—
expect_stop_lossnumberno—
expect_take_profitnumberno—
expect_amount_basenumberno—
expect_tolerancenumberno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "position_uid": "<position_uid>",
  "dry_run": true
}

modify_position

Alias of set_protection for stop_loss/take_profit only. Never widens a stop unless allow_widen:true. Accepts lease_token and expect_stop_loss/expect_take_profit/expect_amount_base (PRECONDITION_FAILED when the position changed). dry_run defaults to true: nothing is sent to the exchange until dry_run:false is passed explicitly. Requires the trade capability (Pro and above; simulated connections may trade on every tier).

Changes your exchange account or platform state. It previews by default: pass dry_run: false to execute. Paper mode forces a preview.

Capability: trade · mutating · REST: POST /v1/tools/modify_position

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
stop_lossnumberno—
take_profitnumberno—
allow_widenbooleanno—
lease_tokenstringno—
expect_stop_lossnumberno—
expect_take_profitnumberno—
expect_amount_basenumberno—
expect_tolerancenumberno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "position_uid": "<position_uid>",
  "dry_run": true
}

set_breakeven

Alias of set_protection{breakeven}: move the stop to entry (plus buffer_bps) once the position is in profit; POSITION_NOT_IN_PROFIT otherwise. Accepts lease_token and expect_stop_loss/expect_take_profit/expect_amount_base (PRECONDITION_FAILED when the position changed). dry_run defaults to true: nothing is sent to the exchange until dry_run:false is passed explicitly. Requires the trade capability (Pro and above; simulated connections may trade on every tier).

Changes your exchange account or platform state. It previews by default: pass dry_run: false to execute. Paper mode forces a preview.

Capability: trade · mutating · REST: POST /v1/tools/set_breakeven

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
buffer_bpsnumberno0
lease_tokenstringno—
expect_stop_lossnumberno—
expect_take_profitnumberno—
expect_amount_basenumberno—
expect_tolerancenumberno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "position_uid": "<position_uid>",
  "dry_run": true
}

set_trailing_stop

Alias of set_protection{trailing}. State persists across restarts (native trailing where the exchange supports it, otherwise a server-side worker). Accepts lease_token and expect_stop_loss/expect_take_profit/expect_amount_base (PRECONDITION_FAILED when the position changed). dry_run defaults to true: nothing is sent to the exchange until dry_run:false is passed explicitly. Requires the trade capability (Pro and above; simulated connections may trade on every tier).

Changes your exchange account or platform state. It previews by default: pass dry_run: false to execute. Paper mode forces a preview.

Capability: trade · mutating · REST: POST /v1/tools/set_trailing_stop

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
percentnumberno—
distance_pricenumberno—
activation_pricenumberno—
offtrueno—
lease_tokenstringno—
expect_stop_lossnumberno—
expect_take_profitnumberno—
expect_amount_basenumberno—
expect_tolerancenumberno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "position_uid": "<position_uid>",
  "dry_run": true
}

get_trailing_status

Trailing stops on this connection (or one position_uid): configuration, mode native|worker, activation, and the current stop. order:"newest_first". Available on every tier.

Capability: read · read-only · REST: POST /v1/tools/get_trailing_status

ParameterTypeRequiredDefaultDescription
position_uidstringno—

Example request:

{}

cancel_trailing_stop

Retire the server's trailing stop on a position; the current stop stays where it is. Alias of set_protection{trailing:{off:true}}. Accepts lease_token and expect_stop_loss/expect_take_profit/expect_amount_base (PRECONDITION_FAILED when the position changed). dry_run defaults to true: nothing is sent to the exchange until dry_run:false is passed explicitly. Requires the trade capability (Pro and above; simulated connections may trade on every tier).

Changes your exchange account or platform state. It previews by default: pass dry_run: false to execute. Paper mode forces a preview.

Capability: trade · mutating · REST: POST /v1/tools/cancel_trailing_stop

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
lease_tokenstringno—
expect_stop_lossnumberno—
expect_take_profitnumberno—
expect_amount_basenumberno—
expect_tolerancenumberno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "position_uid": "<position_uid>",
  "dry_run": true
}

On this page