Checks if trade context is active (execution and method contexts).
Returns true when both contexts are active, which is required for calling exchange functions like getCandles, getAveragePrice, formatPrice, formatQuantity, getDate, and getMode.
true if trade context is active, false otherwise
import { hasTradeContext, getCandles } from "backtest-kit";if (hasTradeContext()) { const candles = await getCandles("BTCUSDT", "1m", 100);} else { console.log("Trade context not active");} Copy
import { hasTradeContext, getCandles } from "backtest-kit";if (hasTradeContext()) { const candles = await getCandles("BTCUSDT", "1m", 100);} else { console.log("Trade context not active");}
Checks if trade context is active (execution and method contexts).
Returns true when both contexts are active, which is required for calling exchange functions like getCandles, getAveragePrice, formatPrice, formatQuantity, getDate, and getMode.