Runs a function inside a mock method and execution context.
Useful in tests and scripts that need to call context-dependent services (e.g. getBacktestTimeframe) without a real backtest runner.
getBacktestTimeframe
All context fields are optional; the defaults produce a minimal live-mode environment pointing at placeholder schema names:
exchangeName
"mock-exchange"
strategyName
"mock-strategy"
frameName
"mock-frame"
symbol
"BTCUSDT"
backtest
false
when
alignToInterval(new Date(), "1m")
Zero-argument function to execute within the context.
Partial IRunContext; any omitted field falls back to its default.
IRunContext
Promise resolving to the return value of run.
run
const price = await runInMockContext( () => getEffectivePrice("BTCUSDT"), { exchangeName: "binance", strategyName: "my-strategy", frameName: "1d" },); Copy
const price = await runInMockContext( () => getEffectivePrice("BTCUSDT"), { exchangeName: "binance", strategyName: "my-strategy", frameName: "1d" },);
Runs a function inside a mock method and execution context.
Useful in tests and scripts that need to call context-dependent services (e.g.
getBacktestTimeframe) without a real backtest runner.All context fields are optional; the defaults produce a minimal live-mode environment pointing at placeholder schema names:
exchangeName→"mock-exchange"strategyName→"mock-strategy"frameName→"mock-frame"symbol→"BTCUSDT"backtest→false(live mode)when→ current minute boundary (alignToInterval(new Date(), "1m"))