Pre Trade Check
workflow.run_pre_trade_checkFull pre-trade decision card: orchestrates position sizing, breakeven, liquidation, and funding cost in one call. Edge cases: entry_price, leverage above zero; account_balance 0 or more; give desired_size, or stop_loss together with risk_pct, otherwise an error; funding_rate is a decimal per interval (0.0001 is 0.01%) and is read live from the exchange when omitted and exchange (and symbol) are given; hold_hours above zero (default 8); fees 0 to 0.05; mmr 0 to 0.2. Not covered: slippage, tiered margin (use workflow.run_liquidation_live), a funding rate that changes during the hold, and anything about where price will go; the verdict covers setup safety only. Use when user describes a full trade setup and asks "should I take this trade?" or "run the numbers on this setup". Provide exchange+symbol to fetch live funding rate automatically. For an R:R-graded verdict on an entry, stop and target, see workflow.run_risk_reward. Returns: positionSize, breakeven, liquidationPrice, fundingCost, overnightBreakevenShift, verdict. liquidation_price and the liquidation distance are null when the position cannot be liquidated (an inverse short at 1x or less): check for null before using them.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"side": "<side>",
"entry_price": "<entry_price>",
"stop_loss": "<stop_loss>",
"account_balance": "<account_balance>",
"risk_pct": "<risk_pct>",
"leverage": "<leverage>"
},
"name": "workflow.run_pre_trade_check"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mmr | No | Maintenance margin rate, default 0.005 | |
| side | Yes | Trade direction: "long" or "short" | |
| mmBase | No | Value the maintenance margin is taken on: "liquidation" = position value at the liquidation price (default), "entry" = entry value. | |
| symbol | No | Perpetual symbol, e.g. "BTCUSDT". | |
| exchange | No | Exchange code, e.g. "binance" or "bybit". Used to fetch the live funding rate if funding_rate is omitted, and to set funding_interval_hours when that is omitted (1 for Hyperliquid, dYdX, Kraken and Backpack, whose rates are per hour; pass funding_interval_hours: 8 if you supply a rate that is per 8 hours). With funding_rate omitted and fetched live, funding_interval_hours is ignored and the interval the exchange reports for the symbol is used. | |
| leverage | Yes | Leverage multiplier | |
| risk_pct | Yes | Risk as % of balance, e.g. 1.0 = 1% | |
| stop_loss | Yes | Stop-loss price (positive) | |
| hold_hours | No | Expected hold time in hours for overnight shift calc. Default 8. | |
| liqFeeRate | No | Liquidation fee as a fraction of position value, default 0, max 0.05; added to mmr. | |
| entry_price | Yes | Entry price (positive) | |
| contractType | No | linear = USDT-margined (default), inverse = coin-margined (e.g. Bybit BTCUSD). All returned figures (notional, margin, risk_amount, funding_cost_*) stay USD-denominated either way; recommended_size is USD notional (contracts) for inverse. | |
| fee_open_pct | No | Opening fee fraction, default 0.0002 | |
| funding_rate | No | Funding rate per funding interval as decimal, e.g. 0.0001. If omitted, fetched live from exchange. | |
| fee_close_pct | No | Closing fee fraction, default 0.0005 | |
| account_balance | Yes | Total account balance in USDT | |
| funding_interval_hours | No | Hours per funding payment, the period funding_rate covers: 8 on most venues, 1 on Hyperliquid, dYdX, Kraken and Backpack, 4 or 2 on some symbols of Binance, Bybit, OKX, Gate, KuCoin, MEXC, Aster and Phemex. When funding_rate is omitted and fetched live (exchange and symbol given), any value passed here is ignored: the interval of that symbol as the exchange reports it is used (else the exchange default). Omitted otherwise: when you pass funding_rate yourself, the exchange default (1 for hourly venues, else 8), so pass funding_interval_hours for a symbol that pays every 4 or 2 hours. |