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.
commitTrade is a compound operation that opens a position and immediately brackets it with a protective OCO (One-Cancels-the-Other) sell order in a single call. Internally it runs the full commitBuy flow — including its open-order and balance guards — then computes the actual filled coin quantity (adjusted for maker fees and exchange minQty), and submits an OCO sell with a TAKE_PROFIT_LIMIT leg above market and a STOP_LOSS_LIMIT leg below market. After placing the OCO, it polls openOrders for up to 10 seconds to confirm the brackets are live before returning.
Signature
Parameters
Binance trading pair symbol, e.g.
"SOLUSDT".The amount in USDT to spend on the buy leg. Subject to the same
commitBuy guards: returns 0 if there are open orders or the balance is insufficient.The price at which the TAKE_PROFIT_LIMIT leg of the OCO will trigger. Must be a positive finite number strictly greater than the current market price.
The price at which the STOP_LOSS_LIMIT leg of the OCO will trigger. Must be a positive finite number strictly less than the current market price and strictly less than
takeProfitPrice.Returns
Returns
0 if no trade was placed (open orders exist or USDT balance is insufficient — same conditions as commitBuy). On success, returns { status: "ok", content: string } where content is a human-readable summary of the buy fill and the OCO bracket prices and values.Validation rules
WalletPublicService runs two rounds of validation before touching the exchange. The cross-price check happens first, then the market price is fetched, then the remaining guards run. Any violation throws an Error with a descriptive message:
| When | Rule | Error message |
|---|---|---|
Before fetchPrice | stopLossPrice > takeProfitPrice | "stop-loss price is greater than take-profit price" |
After fetchPrice | takeProfitPrice is not a finite number | "take-profit price must be a valid number" |
After fetchPrice | stopLossPrice is not a finite number | "stop-loss price must be a valid number" |
After fetchPrice | takeProfitPrice <= marketPrice | "take-profit price must be greater than average price" |
After fetchPrice | stopLossPrice >= marketPrice | "stop-loss price must be less than average price" |
After fetchPrice | stopLossPrice <= 0 | "stop-loss price must be greater than zero" |
After fetchPrice | takeProfitPrice <= 0 | "take-profit price must be greater than zero" |
marketPrice here is the live price fetched internally by WalletPublicService — it is not a parameter you supply.
Execution flow
WalletPublicServicefirst checks thatstopLossPrice < takeProfitPrice, then fetches the current market price internally, then validates both price arguments againstmarketPriceand other rules above.- The call enters the per-symbol execution queue.
COMMIT_TRADE_FNchecks for open orders and free USDT balance; returns0if either guard fails.- The pre-buy coin balance is snapshotted via
FETCH_BALANCE_FN. COMMIT_BUY_FNis executed to perform the buy (limit → poll → market fallback).- The post-buy coin balance is snapshotted again. The actual filled quantity for the OCO is:
- After a 1-second delay, the OCO sell order is placed with the following parameters:
openOrdersis polled up to 10 times (1-second interval) to verify the OCO brackets are live. Throws if no open orders appear after all retries.- A trade report string is assembled and returned as
{ status: "ok", content: report }.