Fast entry#
execute_fast_entry turns "I want to put 100 USDT at 10x into a long on BTC" into one SDK call. The adapter looks up the price, sets leverage, computes the quantity and sends a market order.
let order = trader.execute_fast_entry(
"BTCUSDT",
"long", // direction
100.0, // usdt_amount
10, // leverage
Some(2.0), // tp_percent
Some(1.0), // sl_percent
None, // current_price
).await?;
What it does#
- Takes
current_priceif you passed one, otherwise fetches a ticker. - On derivatives markets, tries to set leverage. Most adapters log a failure here and carry on.
- Computes the quantity (see below) and sends a market order.
- On Bybit and Phemex only, sends take-profit and stop-loss as follow-up requests.
It is one SDK call. It is not always one network request, and the TP/SL part is not atomic.
Parameters#
| Parameter | Meaning |
|---|---|
symbol |
Exchange-neutral symbol such as BTCUSDT. The adapter formats it. |
direction |
"long" buys. Any other string, including "short", sells. The check is case-insensitive and nothing validates the value, so a typo becomes a sell. |
usdt_amount |
Margin you commit, in USDT. |
leverage |
Integer multiplier. |
tp_percent, sl_percent |
Percent of the entry price, so 2.0 is 2%. Only used on Bybit and Phemex. |
current_price |
Optional. Skips the sizing ticker request on most adapters (exceptions below). |
Position size#
On swap markets the quantity is usdt_amount * leverage / price. On spot it is usdt_amount / price. Two adapters differ:
- OKX and Ourbit apply the leverage formula to every market, spot included.
- Deribit uses
usdt_amount * leverageas the order amount for perpetual and inverse contracts, without dividing by price.
For 100 USDT at 10x with BTC at 50,000 the quantity is 0.02 BTC. The pure calculation is also available offline as calculate_position_size in tradersdk-trading.
TP and SL: what each exchange does#
| Exchange | TP/SL |
|---|---|
| Bybit (swap) | One extra request after a 100 ms pause: a trading-stop update carrying both levels, triggered on last price. |
| Phemex (swap) | One conditional close order per level you pass, after a 100 ms pause. |
| MEXC | Prices are computed and logged, then nothing is sent (the code has a TODO). |
| Deribit | Logs a warning that TP/SL was not placed. |
| All others | Parameters are accepted and ignored. |
For Bybit and Phemex the long levels are price * (1 + tp/100) and price * (1 - sl/100). Short positions reverse them. The base is the price used for sizing, not the actual fill price. A failed TP/SL request is logged and swallowed, so a returned OrderResult does not prove the protection exists. Check the position afterwards, or place the protective orders yourself with the order methods.
Leverage and errors#
- The entry order's own failure comes back to you as an error (or, on a few adapters such as BingX and CoinEx, as an
OrderResultwithsuccess: false). Checksuccessas well as theResult. - A failed leverage call does not stop the entry. The order goes out at whatever leverage the account already has. BingX and OKX discard the leverage result silently; the others log it.
- Kraken, Bitfinex and LBank make no leverage request at all: the setter is a no-op or is not called.
- Bitget, WEEX and XT set both long and short leverage, so they make two requests.
Price lookups#
| Behavior | Exchanges |
|---|---|
Passing current_price skips the sizing ticker request |
Binance, Bybit, Bitget, BingX, HTX, KuCoin, OKX, Phemex, WEEX, XT, BitMart, Bitfinex, CoinEx, Deribit, Kraken, LBank |
| Fetches a ticker anyway | Gate, MEXC, Ourbit |
| Skips the sizing lookup, but the order builder fetches a price again for its 5% IOC limit | Hyperliquid |
Hyperliquid has no market order type, so the adapter sends an immediate-or-cancel limit order 5% through the market (buy at price * 1.05, sell at price * 0.95).
Request counts (happy path)#
Counts include the entry order, leverage, and the ticker when current_price is None.
| Exchange | Spot | Swap |
|---|---|---|
| Binance, BingX, KuCoin, OKX, BitMart, CoinEx | 2 | 3 |
| Bybit | 2 | 3, or 4 with TP or SL |
| Phemex | 2 | 3, plus one per TP/SL level |
| Bitget, WEEX, XT | 2 | 4 |
| Gate, MEXC | 2 | 3 |
| HTX | 3 | 3 |
| Bitfinex, LBank, Kraken, Deribit | 2 | 2 |
| Ourbit | 3 | 3 |
| Hyperliquid | n/a | 4, or 5 on a cold asset cache |
With current_price supplied, subtract one on the adapters in the first row of the price table above. HTX spot makes an extra account-id request inside order placement.
Dry run first#
Use test_market_order and test_limit_order to check an order's size and cost without sending it, and a testnet where the exchange has one (see Exchanges). Fast entry has no dry-run mode of its own.