Run Backtest

Run a custom strategy backtest using the ConditionEngine. This is the core Strategy Builder endpoint.

post/backtest

Request

  • Base URL: https://api.pruviq.com (the document declares no server; this is the origin it was published from)
  • URL: https://api.pruviq.com/backtest
  • Auth: none declared

Request body

namestring
directionstring

short | long. Omitted → SHORT (the documented /backtest default). Unlike /simulate, which resolves an omitted direction from the strategy registry, /backtest has no strategy id to resolve from — send direction explicitly. The response's direction_source says whether it was sent or defaulted (Q-B82).

indicatorsobject

Indicator configs: {'bb': {'period': 20}, 'ema': {}, ...}

entryobject required

Entry conditions tree: {'type': 'AND', 'conditions': [...]}

exit_conditionsobject nullable

Optional exit-signal conditions tree (same shape as entry). When met during an open trade, exit early (exit_reason='signal'). null = no signal exit (TP/SL/trailing/timeout only).

avoid_hoursinteger[]

UTC hours to avoid (0-23)

avoid_monthsinteger[] nullable

Months to avoid entering trades (1-12). null = no month filter

min_vol_regimenumber nullable

Minimum ATR ratio (current ATR / 14-period ATR MA) to allow entry. e.g., 0.7 = skip low-volatility periods. null = no filter

sl_pctnumber

Stop Loss %

tp_pctnumber

Take Profit %

tp_source'custom_pct' | 'trailing'

Exit mode: custom_pct = fixed TP/SL; trailing = trailing stop (tp_pct is the trail distance)

trailing_pctnumber nullable

Trailing stop distance %. If null and tp_source=trailing, uses tp_pct.

max_barsinteger

Max holding period (bars)

top_ninteger nullable

Number of coins (null = top 50)

symbolsstring[] nullable

Specific symbols

include_stablecoinsboolean

Include stablecoins (USDC, DAI…) in the top_n universe. Default false — ~0 volatility → empty backtests. Ignored when symbols is set (explicit picks always honored).

symbolstring nullable

Single-symbol alias for symbols. Auto-mapped (prevents silent ignore).

start_datestring nullable

Backtest start date (YYYY-MM-DD)

end_datestring nullable

Backtest end date (YYYY-MM-DD)

timeframe'1H' | '2H' | '4H' | '6H' | '12H' | '1D' | '1W'

Candle timeframe: 1H, 2H, 4H, 6H, 12H, 1D, 1W

fee_pctnumber nullable

Fee per side (0.0005 = 0.05%). None = use market_type default

per_coin_usdnumber

USD per coin position (compounding=True: total portfolio capital)

leverageinteger

Leverage multiplier

max_concurrent_positionsinteger

Max simultaneous open positions

compoundingboolean

True = reinvest profits (compound), False = fixed position size (simple)

Response

Successful Response

namestring required
directionstring required
executedboolean

False when the strategy failed validation and nothing was run — every metric is a placeholder (0), NOT a 0-trade result. validation_errors says why. HTTP stays 200 (documented contract).

direction_source'request' | 'default_short'

«request» = the request sent direction; «default_short» = it was omitted and this run is SHORT (the /backtest default — /simulate would use the strategy registry's direction instead).

sl_pctnumber required
tp_pctnumber required
max_barsinteger required
indicators_usedstring[] required
conditions_countinteger required
total_tradesinteger required
winsinteger required
lossesinteger required
win_ratenumber required
total_return_pctnumber required
profit_factornumber required
avg_win_pctnumber required
avg_loss_pctnumber required
max_drawdown_pctnumber required
max_consecutive_lossesinteger required
tp_countinteger required
sl_countinteger required
timeout_countinteger required
total_fees_pctnumber
total_funding_pctnumber
sharpe_rationumber
sortino_rationumber
calmar_rationumber
coins_usedinteger required
top_n_requestedinteger nullable

The top_n this run resolved to. null for explicit symbols= requests (no top-N universe).

eligible_universeinteger nullable

Coins eligible for a top-N universe at run time (stablecoins unless include_stablecoins, non-crypto and liquidity-dead markets excluded), read in the same selection as the coins run. null for symbols= requests (and on /backtest when the strategy is invalid, is_valid=false).

universe_cappedboolean nullable

eligible_universe < top_n_requested: the request asked for more coins than exist, so the whole eligible universe ran. A cap only — coins lacking data are reported in coins_missing_data. null for symbols= requests.

coins_missing_datainteger nullable

min(top_n_requested, eligible_universe) - (selected coins with at least one candle inside start_date..end_date). Counts selected coins with no complete candle up to the cutoff AND coins whose candles all fall outside the requested window (those stay in coins_used, so this can exceed min(top_n_requested, eligible_universe) - coins_used). null for symbols= requests.

data_rangestring required
compoundingboolean
ruin_indexinteger nullable
per_coin_usdnumber
leverageinteger
initial_capital_usdnumber
total_return_usdnumber
total_return_pct_portfolionumber
max_drawdown_usdnumber
expectancynumber
recovery_factornumber
payoff_rationumber
btc_hold_return_pctnumber
eth_hold_return_pctnumber
var_95number
cvar_95number
strategy_gradestring
grade_detailsstring
edge_p_valuenumber nullable
warningsstring[]
walk_forward_consistencynumber nullable
walk_forward_detailsstring
deflated_sharpenumber nullable
dsr_haircut_pctnumber nullable
mc_p_valuenumber nullable
mc_percentilenumber nullable
jensens_alphanumber nullable
avg_bars_heldnumber
median_bars_heldnumber
positions_skippedinteger
pnl_distributioninteger[]
pnl_bucketsstring[]
is_validboolean required
validation_errorsstring[]
compute_time_msinteger
reliability_warningstring nullable required

계약은 build_reliability_warning 한 곳이 소유한다(룰3).

Changes

No recorded changes to this operation across all 2 revisions of this API.