Files
ritmex-bot/docs/binance/binance-spot/faqs_trailing-stop-faq.md
DisneyandGitHub d6399b92aa Feat/support binance (#22)
* add docs

* Add Binance exchange support

- Updated the environment configuration to include Binance as a selectable exchange option.
- Enhanced the README documentation to reflect the addition of Binance.
- Implemented the Binance exchange adapter and integrated it into the existing exchange framework.
- Modified the basis arbitrage strategy to support Binance alongside existing exchanges.
- Added tests to ensure proper functionality and integration of Binance within the trading system.

* Enhance README with detailed Binance exchange configuration

- Added comprehensive instructions for setting up Binance as an exchange option.
- Included environment variable specifications for API keys, market types, and trading symbols.
- Provided examples for both perpetual and spot trading strategies.
- Clarified the use of WebSocket and REST for the Binance adapter.

* Enhance exchange support and testing framework

- Added a new test suite for exchange contracts to ensure consistency and functionality across supported exchanges.
- Refactored exchange ID handling to utilize a centralized list of supported exchanges, improving maintainability.
- Updated CLI argument parsing and help documentation to reflect the new exchange structure.
- Introduced utility functions for validating supported exchanges and their display names.
- Enhanced the BasisApp and strategy runner to leverage the new exchange validation logic.
- Added a new test command for running exchange-related tests.

* Refactor exchange contract tests and update CLI commands

- Removed the trailing supported exchanges set and simplified the logic for trailing stop support in the exchange contract tests.
- Updated the test command for exchange contracts to exclude unnecessary tests, streamlining the testing process.
- Enhanced test descriptions for clarity and improved understanding of the functionality being tested.
2026-02-27 11:37:44 +08:00

17 KiB
Raw Permalink Blame History

title, source, fetched_at
title source fetched_at
Trailing Stop FAQ | Binance Open Platform https://developers.binance.com/docs/binance-spot-api-docs/faqs/trailing-stop-faq 2026-02-26T10:38:08.171Z

Spot Trailing Stop order FAQ

What is a trailing stop order?

Trailing stop is a type of contingent order with a dynamic trigger price influenced by price changes in the market. For the SPOT API, the change required to trigger order entry is specified in the trailingDelta parameter, and is defined in BIPS.

Intuitively, trailing stop orders allow unlimited price movement in a direction that is beneficial for the order, and limited movement in a detrimental direction.

Buy orders: low prices are good. Unlimited price decreases are allowed but the order will trigger after a price increase of the supplied delta, relative to the lowest trade price since submission.

Sell orders: high prices are good. Unlimited price increases are allowed but the order will trigger after a price decrease of the supplied delta, relative to the highest trade price since submission.

What are BIPs?

Basis Points, also known as BIP or BIPS, are used to indicate a percentage change.

BIPS conversion reference:

BIPS

Percentage

Multiplier

1

0.01%

0.0001

10

0.1%

0.001

100

1%

0.01

1000

10%

0.1

For example, a STOP_LOSS SELL order with a trailingDelta of 100 is a trailing stop order which will be triggered after a price decrease of 1% from the highest price after placing the order.

What order types can be trailing stop orders?

Trailing stop orders are supported for contingent orders such as STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT.

OCO orders also support trailing stop orders in the contingent leg. In this scenario if the trailing stop condition is triggered, the limit leg of the OCO order will be canceled.

How do I place a trailing stop order?

Trailing stop orders are entered the same way as regular STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, or TAKE_PROFIT_LIMIT orders, but with an additional trailingDelta parameter. This parameter must be within the range of the TRAILING_DELTA filter for that symbol.

Unlike regular contingent orders, the stopPrice parameter is optional for trailing stop orders. If it is provided then the order will only start tracking price changes after the stopPrice condition is met. If the stopPrice parameter is omitted then the order starts tracking price changes from the next trade.

What kind of price changes will trigger my trailing stop order?

Trailing order type

Side

Stop price condition

Market price movement required to trigger

TAKE_PROFIT

SELL

market price >= stop price

decrease from maximum

TAKE_PROFIT_LIMIT

SELL

market price >= stop price

decrease from maximum

STOP_LOSS

SELL

market price <= stop price

decrease from maximum

STOP_LOSS_LIMIT

SELL

market price <= stop price

decrease from maximum

STOP_LOSS

BUY

market price >= stop price

increase from minimum

STOP_LOSS_LIMIT

BUY

market price >= stop price

increase from minimum

TAKE_PROFIT

BUY

market price <= stop price

increase from minimum

TAKE_PROFIT_LIMIT

BUY

market price <= stop price

increase from minimum

How do I pass the TRAILING_DELTA filter?

For STOP_LOSS BUY, STOP_LOSS_LIMIT BUY, TAKE_PROFIT SELL, and TAKE_PROFIT_LIMIT SELL orders:

  • trailingDelta >= minTrailingAboveDelta
  • trailingDelta <= maxTrailingAboveDelta

For STOP_LOSS SELL, STOP_LOSS_LIMIT SELL, TAKE_PROFIT BUY, and TAKE_PROFIT_LIMIT BUY orders:

  • trailingDelta >= minTrailingBelowDelta
  • trailingDelta <= maxTrailingBelowDelta

Trailing Stop Order Scenarios

Scenario A - Trailing Stop Loss Limit Buy Order

At 12:01:00 there is a trade at a price of 40,000 and a STOP_LOSS_LIMIT order is placed on the BUY side of the exchange. The order has of a stopPrice of 44,000, a trailingDelta of 500 (5%), and a limit price of 45,000.

Between 12:01:00 and 12:02:00 a series of linear trades lead to a decrease in last price, ending at 37,000. This is a price decrease of 7.5% or 750 BIPS, well exceeding the order's trailingDelta. However since the order has not started price tracking, the price movement is ignored and the order remains contingent.

Between 12:02:00 and 12:03:00 a series of linear trades lead to an increase in last price. When a trade is equal to, or surpasses, the stopPrice the order starts tracking price changes immediately; the first trade that meets this condition sets the "lowest price". In this case, the lowest price is 44,000 and if there is a 500 BIPS increase from 44,000 then the order will trigger. The series of linear trades continue to increase the last price, ending at 45,000.

Between 12:03:00 and 12:04:00 a series of linear trades lead to an increase in last price, ending at 46,000. This is an increase of ~454 BIPS from the order's previously noted lowest price, but it's not large enough to trigger the order.

Between 12:04:00 and 12:05:00 a series of linear trades lead to a decrease in last price, ending at 42,000. This is a decrease from the order's previously noted lowest price. If there is a 500 BIPS increase from 42,000 then the order will trigger.

Between 12:05:00 and 12:05:30 a series of linear trades lead to an increase in last price to 44,100. This trade is equal to, or surpasses, the order's requirement of 500 BIPS, as 44,100 = 42,000 * 1.05. This causes the order to trigger and start working against the order book at its limit price of 45,000.

image

Scenario B - Trailing Stop Loss Limit Sell Order

At 12:01:00 there is a trade at a price of 40,000 and a STOP_LOSS_LIMIT order is placed on the SELL side of the exchange. The order has of a stopPrice of 39,000, a trailingDelta of 1000 (10%), and a limit price of 38,000.

Between 12:01:00 and 12:02:00 a series of linear trades lead to an increase in last price, ending at 41,500.

Between 12:02:00 and 12:03:00 a series of linear trades lead to a decrease in last price. When a trade is equal to, or surpasses, the stopPrice the order starts tracking price changes immediately; the first trade that meets this condition sets the "highest price". In this case, the highest price is 39,000 and if there is a 1000 BIPS decrease from 39,000 then the order will trigger.

Between 12:03:00 and 12:04:00 a series of linear trades lead to a decrease in last price, ending at 37,000. This is a decrease of ~512 BIPS from the order's previously noted highest price, but it's not large enough to trigger the order.

Between 12:04:00 and 12:05:00 a series of linear trades lead to an increase in last price, ending at 41,000. This is an increase from the order's previously noted highest price. If there is a 1000 BIPS decrease from 41,000 then the order will trigger.

Between 12:05:00 and 12:05:30 a series of linear trades lead to a decrease in last price to 36,900. This trade is equal to, or surpasses, the order's requirement of 1000 BIPS, as 36,900 = 41,000 * 0.90. This causes the order to trigger and start working against the order book at its limit price of 38,000.

image

Scenario C - Trailing Take Profit Limit Buy Order

At 12:01:00 there is a trade at a price of 40,000 and a TAKE_PROFIT_LIMIT order is placed on the BUY side of the exchange. The order has of a stopPrice of 38,000, a trailingDelta of 850 (8.5%), and a limit price of 38,500.

Between 12:01:00 and 12:02:00 a series of linear trades lead to an increase in last price, ending at 42,000.

Between 12:02:00 and 12:03:00 a series of linear trades lead to a decrease in last price. When a trade is equal to, or surpasses, the stopPrice the order starts tracking price changes immediately; the first trade that meets this condition sets the "lowest price". In this case, the lowest price is 38,000 and if there is a 850 BIPS increase from 38,000 then the order will trigger.

The series of linear trades continues to decrease the last price, ending at 37,000. If there is a 850 BIPS increase from 37,000 then the order will trigger.

Between 12:03:00 and 12:04:00 a series of linear trades lead to an increase in last price, ending at 39,000. This is an increase of ~540 BIPS from the order's previously noted lowest price, but it's not large enough to trigger the order.

Between 12:04:00 and 12:05:00 a series of linear trades lead to a decrease in last price, ending at 38,000. It does not surpass the order's previously noted lowest price, resulting in no change to the order's trigger price.

Between 12:05:00 and 12:05:30 a series of linear trades lead to an increase in last price to 40,145. This trade is equal to, or surpasses, the order's requirement of 850 BIPS, as 40,145 = 37,000 * 1.085. This causes the order to trigger and start working against the order book at its limit price of 38,500.

image

Scenario D - Trailing Take Profit Limit Sell Order

At 12:01:00 there is a trade at a price of 40,000 and a TAKE_PROFIT_LIMIT order is placed on the SELL side of the exchange. The order has of a stopPrice of 42,000, a trailingDelta of 750 (7.5%), and a limit price of 41,000.

Between 12:01:00 and 12:02:00 a series of linear trades lead to an increase in last price, ending at 41,500.

Between 12:02:00 and 12:03:00 a series of linear trades lead to a decrease in last price, ending at 39,000.

Between 12:03:00 and 12:04:00 a series of linear trades lead to an increase in last price. When a trade is equal to, or surpasses, the stopPrice the order starts tracking price changes immediately; the first trade that meets this condition sets the "highest price". In this case, the highest price is 42,000 and if there is a 750 BIPS decrease from 42,000 then the order will trigger.

The series of linear trades continues to increase the last price, ending at 45,000. If there is a 750 BIPS decrease from 45,000 then the order will trigger.

Between 12:04:00 and 12:05:00 a series of linear trades lead to a decrease in last price, ending at 44,000. This is a decrease of ~222 BIPS from the order's previously noted highest price, but it's not large enough to trigger the order.

Between 12:05:00 and 12:06:00 a series of linear trades lead to an increase in last price, ending at 46,500. This is an increase from the order's previously noted highest price. If there is a 750 BIPS decrease from 46,500 then the order will trigger.

Between 12:06:00 and 12:06:50 a series of linear trades lead to a decrease in last price to 43,012.5. This trade is equal to, or surpasses, the order's requirement of 750 BIPS, as 43,012.5 = 46,500 * 0.925. This causes the order to trigger and start working against the order book at its limit price of 41,000.

image

Scenario E - Trailing Stop Order Without A Stop Price

At 12:01:00 there is a trade at a price of 40,000 and a STOP_LOSS_LIMIT order is placed on the SELL side of the exchange. The order has a trailingDelta of 700 (7%), a limit price of 39,000 and no stopPrice. The order starts tracking price changes once placed. If there is a 700 BIPS decrease from 40,000 then the order will trigger.

Between 12:01:00 and 12:02:00 a series of linear trades lead to an increase in last price, ending at 42,000. This is an increase from the order's previously noted highest price. If there is a 700 BIPS decrease from 42,000 then the order will trigger.

Between 12:02:00 and 12:03:00 a series of linear trades lead to a decrease in last price, ending at 39,500. This is a decrease of ~595 BIPS from the order's previously noted highest price, but it's not large enough to trigger the order.

Between 12:03:00 and 12:04:00 a series of linear trades lead to an increase in last price, ending at 45,500. This is an increase from the order's previously noted highest price. If there is a 700 BIPS decrease from 45,500 then the order will trigger.

Between 12:04:00 and 12:04:45 a series of linear trades lead to a decrease in last price to 42,315. This trade is equal to, or surpasses, the order's requirement of 700 BIPS, as 42,315 = 45,500 * 0.93. This causes the order to trigger and start working against the order book at its limit price of 39,000.

image

Trailing Stop Order Examples

Assuming a last price of 40,000.

Placing a trailing stop STOP_LOSS_LIMIT BUY order, with a price of 42,000.0 and a trailing stop of 5%.

# Excluding stop pricePOST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=42000&trailingDelta=500&timestamp=<timestamp>&signature=<signature>'# Including stop price of 43,000POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=42000&stopPrice=43000&trailingDelta=500&timestamp=<timestamp>&signature=<signature>'

Placing a trailing stop STOP_LOSS_LIMIT SELL order, with a price of 37,500.0 and a trailing stop of 2.5%.

# Excluding stop pricePOST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=37500&trailingDelta=250&timestamp=<timestamp>&signature=<signature>'# Including stop price of 39,000POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=0.01&price=37500&stopPrice=39000&trailingDelta=250&timestamp=<timestamp>&signature=<signature>'

Placing a trailing stop TAKE_PROFIT_LIMIT BUY order, with a price of 38,000.0 and a trailing stop of 5%.

# Excluding stop pricePOST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=38000&trailingDelta=500&timestamp=<timestamp>&signature=<signature>'# Including stop price of 36,000POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=38000&stopPrice=36000&trailingDelta=500&timestamp=<timestamp>&signature=<signature>'

Placing a trailing stop TAKE_PROFIT_LIMIT SELL order, with a price of 41,500.0 and a trailing stop of 1.75%.

# Excluding stop pricePOST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=41500&trailingDelta=175&timestamp=<timestamp>&signature=<signature>'# Including stop price of 42,500POST 'https://api.binance.com/api/v3/order?symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_LIMIT&timeInForce=GTC&quantity=0.01&price=41500&stopPrice=42500&trailingDelta=175&timestamp=<timestamp>&signature=<signature>'