PyInvesting

PyInvesting research guide

A backtest is a question, not an answer.

Use this guide to turn an investment idea into a clear rule, test it against an appropriate benchmark, and decide whether the evidence deserves further research.

About 10 minutes · No coding required

01 · Hypothesis

Turn the idea into a rule you could prove wrong

Start with the decision you want to study. A useful hypothesis says what can be owned, how positions are selected, when the portfolio changes, and what success will be compared with.

Universe

The securities eligible for selection, such as large US companies or a fixed ETF list.

Signal

The observable rule used to rank, include, or exclude each security.

Portfolio rule

The number of positions, their target weights, and the rebalancing schedule.

Benchmark

The investable alternative the strategy must justify outperforming.

02 · Eligibility

Decide what the strategy is allowed to own

Use the screener to narrow the market by characteristics such as size, exchange, sector, valuation, or financial quality. The securities that pass become the investment universe supplied to a backtest.

Universe rule

Who is eligible?

Example: US-listed companies above a chosen market-cap threshold.

Selection rule

Who is chosen?

Example: the ten eligible companies with the strongest six-month return.

Open the stock screener

03 · Method

Choose the builder that matches the question

Each builder represents a different portfolio rule. Choose one because its assumptions fit your hypothesis—not because its example result has the highest return.

Cross-sectional momentum

Relative strength

Rank an eligible universe by one or more price-strength signals and hold the leaders.

Tests
Whether recent relative winners continued to lead after rebalancing.
You choose
Signals, signal weights, portfolio size, and optional trend filters.
Watch for
High turnover, concentrated positions, and results driven by one market regime.
Build a relative-strength test

Company characteristics

Fundamentals

Rank companies by selected financial or valuation factors at each rebalance.

Tests
Whether the selected characteristics identified a stronger portfolio.
You choose
Factors, factor weights, portfolio size, and rebalancing frequency.
Watch for
Combining many factors until the historical result looks unusually smooth.
Build a fundamentals test

Trend filter

Moving average

Hold qualifying securities while their prices remain above a selected moving average.

Tests
Whether a trend rule reduced exposure during sustained declines.
You choose
Moving-average window, ranking signal, universe, and portfolio size.
Watch for
Frequent whipsaws when prices repeatedly cross the trend threshold.
Build a moving-average test

Price levels and risk

Breakout trading

Test entries after price moves through a defined level, with explicit exit and risk rules.

Tests
Whether moves beyond recent support or resistance showed useful continuation.
You choose
Entry level, exit logic, eligible instruments, and test period.
Watch for
False breakouts, optimistic execution assumptions, and gap risk.
Build a breakout test

04 · Test design

Make the comparison difficult to fool

A credible test uses assumptions that could have been followed at the time. Before running it, review the settings that most often make historical results look better than a real decision would have been.

  1. Use a meaningful period

    Include more than one market condition where the available history permits. A rule tested only during its ideal regime has not faced much evidence.

  2. Choose the benchmark before the result

    Compare with a simpler investable alternative that carries similar exposure—not whichever index is easiest to beat.

  3. Use a realistic rebalancing rule

    More frequent decisions can increase turnover, taxes, slippage, and the opportunity for execution to differ from the simulation.

  4. Account for implementation costs

    If the result does not deduct every fee or spread you would face, subtract a reasonable estimate when deciding whether the advantage is material.

  5. Reserve an independent check

    Develop the rule on one period, then inspect a later period without changing the rule. Treat that later result as new evidence, not another tuning opportunity.

05 · Interpretation

Read beyond the headline return

Open a completed test from Results and inspect the result as a body of evidence. A strategy can finish ahead of its benchmark and still be too fragile, concentrated, or costly to use.

Return

Did the rule add enough?

Compare cumulative and annualized performance with the benchmark, then judge whether the difference is large enough to survive costs and uncertainty.

Drawdown

What had to be endured?

Maximum drawdown shows the deepest historical decline. Also inspect how long recovery took and whether the loss fits the risk you could actually tolerate.

Risk-adjusted return

Was return efficient?

Use volatility and measures such as Sharpe when shown to compare the return earned with the variability accepted. No single ratio is a verdict.

Turnover

How much action was required?

Review position changes and simulated orders. Frequent trading can convert a small paper advantage into a negative real-world result.

Concentration

What produced the result?

Inspect historical holdings and individual positions. A strategy dependent on a few securities, trades, or years deserves a lower level of confidence.

Stability

Did the rule travel?

Compare different periods and reasonable nearby settings. Evidence is stronger when the conclusion does not disappear after a small, defensible change.

06 · Monitoring

Monitoring continues the test; it does not prove execution

Eligible subscribers can select a saved result for ongoing monitoring. PyInvesting reruns the strategy as new daily end-of-day data becomes available and reports the positions or proposed actions produced by the rule.

What monitoring provides

  • A repeatable daily evaluation of the saved strategy
  • Current model positions and proposed changes
  • A record you can compare with the original hypothesis

What monitoring does not prove

  • That an order was submitted to your broker
  • That a trade received the simulated price
  • That future results will resemble the backtest

Sign in to view saved research

07 · Evidence checkpoint

A result earns the next test—not automatic trust

Before using your own capital, make sure you can answer each question without relying on the headline chart.

  • Did the strategy outperform an appropriate benchmark by a meaningful amount?
  • Does the advantage remain after reasonable fees, spreads, slippage, and taxes?
  • Could you tolerate the historical drawdown and the time it took to recover?
  • Is the result spread across periods and positions rather than one exceptional episode?
  • Did an untouched period support the rule without further tuning?
  • Can you explain exactly when the strategy should—and should not—work?

Start with the clearest rule

Build a simple allocation, then earn complexity.

Fixed weights and a scheduled rebalance make the first hypothesis easier to explain, challenge, and compare.

Build your first allocation