Documentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/wallet-manager/llms.txt
Use this file to discover all available pages before exploring further.
commitSell sells a specified USDT-denominated value of coin on Binance spot. It converts the USDT amount to a coin quantity at the current average price, places a LIMIT SELL slightly below market to encourage a quick fill, and runs the same poll-then-cancel-then-market-sell fallback loop as commitBuy. Unlike commitBuy, commitSell does not guard against open orders or check the coin balance before placing the order — it assumes the caller has already confirmed that the coin is available to sell.
Signature
Parameters
Binance trading pair symbol, e.g.
"SOLUSDT". Must be a valid spot pair recognized by the exchange.The USDT-denominated value of coin to sell. The function converts this to a coin quantity using
amountUSDT / averagePrice before placing the order. Must be a positive finite number — WalletPublicService throws before any network call if the value is NaN, non-numeric, or negative.Returns
The average fill price of the sell order in USDT. Derived from the
fills array on the Binance order response (or from the limit price when fills is absent). Because there is no balance guard, this method always attempts to place an order and will always return a non-zero fill price on success.Execution flow
WalletPublicServicefetches the current average price viafetchPriceand validatesamountUSDT.- The call is routed through the per-symbol
EventListenerqueue so it cannot run concurrently with other operations on the same symbol. COMMIT_SELL_FNcomputes coin quantity asusdToCoins(amountUSDT, averagePrice), rounds it toLOT_SIZEstepSize, and rounds the order price toPRICE_FILTERtickSize.- A LIMIT SELL is placed at
averagePrice × 0.999— just below market to improve fill speed. - If the response status is already
FILLED, the average fill price is returned immediately. - Otherwise,
orderStatusis polled every 10 seconds for up to 10 iterations (≈ 100 seconds). - If the order fills during polling, the fill price is returned.
- On timeout: the resting order is cancelled. The unfilled remainder (
quantity − executedQty) is submitted as a market sell. The average fill price of the market order is returned.
Difference from commitBuy
commitSell does not check for open orders and does not verify the coin balance before acting. It is the caller’s responsibility to ensure sufficient coin is available. This mirrors the design intent: commitBuy guards against double-entry, while commitSell is used to exit a position that is known to exist.