CCCryptoContext Docs
Tool reference

Trading

Check, place, change and close orders and positions. Every tool here previews unless dry_run is false.

check_order

Preflight an order without placing it: amount/contracts, min notional, free margin, leverage cap, liquidation vs stop, protection plan (native|worker), equity-guard state. Same checks place_order runs. Requires analytics or trade capability (Pro and above).

Capability: analytics or trade · read-only · REST: POST /v1/tools/check_order

ParameterTypeRequiredDefaultDescription
symbolstringyes—
sidebuy | sell | long | shortyes—
typemarket | limit | stop_market | stop_limityes—
size_usdtnumberyes—
pricenumberno—
trigger_pricenumberno—
trigger_price_typemark | last | indexno—
stop_lossnumberno—
take_profitnumberno—
trailingobjectno—
ratchetobjectno—
expires_atstringno—
leveragenumberno—
margin_modeisolated | crossno—
post_onlybooleanno—
reduce_onlybooleanno—
position_sidelong | shortno—
commentstringno—
lease_tokenstringno—
dry_runbooleanno—

Example request:

{
  "symbol": "BTC/USDT:USDT",
  "side": "buy",
  "type": "market",
  "size_usdt": 0
}

place_order

Place an order sized in USDT (size_usdt) with optional stop_loss/take_profit/trailing/ratchet, expires_at, leverage, margin_mode, post_only, reduce_only, position_side. Per-call notional is capped. Never flips or widens implicitly. Response reports protection modes. 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/place_order

ParameterTypeRequiredDefaultDescription
symbolstringyes—
sidebuy | sell | long | shortyes—
typemarket | limit | stop_market | stop_limityes—
size_usdtnumberyes—
pricenumberno—
trigger_pricenumberno—
trigger_price_typemark | last | indexno—
stop_lossnumberno—
take_profitnumberno—
trailingobjectno—
ratchetobjectno—
expires_atstringno—
leveragenumberno—
margin_modeisolated | crossno—
post_onlybooleanno—
reduce_onlybooleanno—
position_sidelong | shortno—
commentstringno—
lease_tokenstringno—
idempotency_keystringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "symbol": "BTC/USDT:USDT",
  "side": "buy",
  "type": "market",
  "size_usdt": 0,
  "dry_run": true
}

close_position

Close a position by position_uid with a reduce-only market order. 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/close_position

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
lease_tokenstringno—
lease_overrideobjectno—
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
}

partial_close

Reduce a position by size_usdt or fraction (exactly one); position_uid is unchanged. 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/partial_close

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
size_usdtnumberno—
fractionnumberno—
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
}

close_all_positions

Flatten all (or symbol/market_type-filtered) positions with reduce-only markets and cancel their protection orders. 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/close_all_positions

ParameterTypeRequiredDefaultDescription
symbolstringno—
market_typespot | swapno—
lease_tokenstringno—
lease_overrideobjectno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "dry_run": true
}

reverse_position

Close and open the opposite side as one explicit operation (never implicit). Returns REVERSE_PARTIAL if the close succeeded but the opposite leg did not. 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/reverse_position

ParameterTypeRequiredDefaultDescription
position_uidstringyes—
size_usdtnumberno—
stop_lossnumberno—
take_profitnumberno—
ratchetobjectno—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

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

cancel_order

Cancel an open order by order_id. 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/cancel_order

ParameterTypeRequiredDefaultDescription
order_idstringyes—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

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

modify_pending_order

Change price/trigger/SL/TP/expiry of a pending order; retrofitting expiry works (worker-enforced where not native). 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/modify_pending_order

ParameterTypeRequiredDefaultDescription
order_idstringyes—
pricenumberno—
trigger_pricenumberno—
stop_lossnumberno—
take_profitnumberno—
expires_atstringno—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

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

set_leverage

Set leverage for a symbol (capped by connection/tier/exchange). Increases are blocked while the equity guard is breached. 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_leverage

ParameterTypeRequiredDefaultDescription
symbolstringyes—
leveragenumberyes—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "symbol": "BTC/USDT:USDT",
  "leverage": 1,
  "dry_run": true
}

set_margin_mode

Set isolated/cross margin for a symbol; rejected while a position is open on it. 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_margin_mode

ParameterTypeRequiredDefaultDescription
symbolstringyes—
margin_modeisolated | crossyes—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "symbol": "BTC/USDT:USDT",
  "margin_mode": "isolated",
  "dry_run": true
}

set_position_mode

Switch one-way/hedge mode; rejected while any position or order is open. 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_position_mode

ParameterTypeRequiredDefaultDescription
modeoneway | hedgeyes—
lease_tokenstringno—
dry_runbooleanyestrueDefault true: validate and preview only. Set false to execute.

Example request:

{
  "mode": "oneway",
  "dry_run": true
}

On this page