Appearance

Personalize your experience

Mode
Accent Color
Direction
Python: Research Toolkit

Python: Research Toolkit

Python SDK

Everything after the first backtest: tearsheet analytics, multi-asset portfolios, position sizing, optimization and walk-forward, overfitting tests, Monte Carlo, lookahead checks and HTML reports. Standard library only; numpy and pandas are optional.

Modules

ModuleMain functions
quatick.tearsheet, risk_metrics (VaR, CVaR, omega, gain-to-pain), trade_metrics (SQN, Kelly, streaks, MAE / MFE, by side / exit / holding), calendar_returns, drawdown_periods, , benchmark_metrics (beta, , IR, capture)
quatick.portfolioportfolio_backtest: target weights, every N bars or D / W / M / Q / Y, gross cap, attribution, turnover
quatick.fixed_fraction, vol_target, atr_units, kelly_fraction, max_drawdown_overlay
quatick.grid_search, random_search ( with n_jobs), walk_forward, parameter_stability, deflated_sharpe, pbo, purged_kfold
quatick.montecarlotrade_monte_carlo, stationary_bootstrap_bars, path_monte_carlo, parameter_noise
quatick.validationlookahead_check
quatick.reporthtml_report (self-contained tearsheet), to_json

Every function accepts a position (a function or module) or an event-driven Strategy class.

Tearsheet and report

python
from quatick import analytics, report
t = analytics.tearsheet(result, bars, benchmark=bench.close, rolling_window=500)
t["risk"]["cvar95"], t["trades"]["sqn"], t["trades"]["by_exit"], t["monthly"][2025][3], t["benchmark"]["beta"]
open("report.html", "w").write(report.html_report(result, bars, title="Breakout v3", benchmark=bench.close))

Portfolios

python
from quatick.portfolio import portfolio_backtest

def momentum(ctx):                        # called on each rebalance bar
    score = {s: ctx.close(s) / ctx.history(s, n=90)[0] - 1
             for s in ctx.symbols if ctx.tradable(s) and len(ctx.history(s, n=90)) == 90}
    top = sorted(score, key=score.get, reverse=True)[:5]
    return {s: 1 / len(top) for s in top}

r = portfolio_backtest(universe, momentum, rebalance="M", costs=0.05, max_gross=1.0, warmup=90)
r.summary(), r.attribution, r.turnover, r.weights[-1]

Validation and robustness

python
from quatick import optimize, validation
from quatick.montecarlo import trade_monte_carlo, path_monte_carlo, parameter_noise

validation.lookahead_check(strategy, bars)                       # {"passed": True, ...}
res = optimize.grid_search(strategy, bars, grid, n_jobs=8)
optimize.pbo([run.returns for run in res.runs], blocks=10)       # probability of overfitting
wf = optimize.walk_forward(strategy, bars, grid, in_sample=3000, out_of_sample=1000)
trade_monte_carlo([t.pnl for t in result.trades], 100_000, paths=10_000)
path_monte_carlo(strategy, bars, paths=200)                     # re-run on resampled markets
parameter_noise(strategy, bars, res.best.params, noise_pct=10)  # does it survive +-10% parameters?

Sizing a position strategy

python
from quatick import sizing, backtest
direction = [1 if f > s else -1 for f, s in zip(fast, slow)]
frac = sizing.vol_target(direction, bars.close, target_vol_pct=15, interval="1h", max_leverage=2)
r = backtest(lambda b, p: frac, bars, sizing="fraction")

See also

Related articles

  • Python: Event-Driven Strategies

    Backtesting / SDKs / Python

    Subclass quatick.Strategy to trade bar by bar with real orders: brackets, trailing stops, limits, risk-based sizing and a drawdown kill switch. The same…

  • The Backtesting Page

    Backtesting / Backtesting Page

    Automation → Backtesting runs any saved strategy or strategy file on the backtest engine, then lets you analyse, stress, optimize, validate, compare and…

  • Backtesting in Python and C++

    Backtesting / SDKs

    The quatick Python package and the header-only C++ library let you import indicators, backtest on your own machine and send the same file to Quatick.…

  • C++ SDK Reference

    Backtesting / SDKs / C++

    Header-only C++20 (packages/quatick-backtest-cpp): the position simulator, an event-driven engine with the same order rules as Python, analytics, a parallel…

  • Monte Carlo and Robustness

    Backtesting / Monte Carlo

    A backtest is one path through history. Monte Carlo asks how different the result could have been with the same edge: a different order of trades, a…

  • Parameter Optimization

    Backtesting / Optimization

    A sweep backtests every combination of a parameter grid on the same data and costs and ranks them. Used well it shows how sensitive a strategy is to its…

  • The Backtest Engine

    Backtesting / Engine

    One service backtests every kind of strategy on Quatick. Each source type runs on the engine built for it, and every result is measured with the same…

  • Engines — Python vs C++

    Automation / Predefined Strategies

    Two independent implementations of the same grid semantics, consuming the same config and the same command channel. The choice is a runtime choice, not a…

  • Orders and Fills

    Backtesting / SDKs / Orders and Fills

    The event-driven engines of the Python and C++ SDKs share one set of order types and fill rules, so the same strategy fills identically in both languages…

Browse all knowledge base articles →