Building a Personal Quantitative Trading System from Scratch

    A practical guide to building a personal, daily-frequency quantitative trading system focused on research and alerts. Learn how to define its scope, organize data and software layers, express reproducible trading rules, test realistic execution assumptions, apply risk controls, and operate reliable daily workflows before considering automated execution.

    A personal quantitative trading system should not try to replicate an institutional research operation. Its purpose is to turn “what to watch, when to notify, how to validate, and how to control risk” into a repeatable process.

    For most part-time traders, sustained attention is scarcer than another subjective market opinion. The guiding principle should therefore be simple: support disciplined decisions before increasing automation, and make every signal explainable before expanding market coverage.

    1. Define the Scope First

    Trend following assumes that prices can continue moving in a particular direction for a period of time. A rules-based system identifies the formation, continuation, and weakening of a trend, then generates buy or sell alerts when predefined conditions are met. It does not promise consistent returns or eliminate drawdowns.

    For an individual trader, the first version is better designed as a research and alerting system: notify the user when market conditions meet the rules, then leave order confirmation and placement to the user. Fully automated execution adds account permissions, retry behavior, slippage, and compliance responsibilities. These are substantially more complex than signal calculation and should not be first-stage goals.

    Before development, write a one-page specification covering four points:

    • Instruments and market: For example, cash equities in China’s A-share market.
    • Decision frequency: Prefer daily or lower-frequency decisions initially.
    • Capital and position limits: Define the maximum capital allocation and exposure.
    • Default behavior on failure: Stop generating trading signals and do not trade automatically.

    Without clear boundaries, data collection and backtesting will lose focus.

    2. Design the Overall Architecture

    A maintainable personal system typically has six layers. Each should communicate with the others through explicit data contracts.

    1. Data ingestion: Retrieve market prices, trading calendars, corporate-action adjustment factors, and auxiliary fields such as fundamentals or capital-flow data. Align them by time.
    2. Data storage: Keep raw data separate from cleaned research datasets. Object storage suits raw-file archives; relational or columnar storage supports queries by instrument and date.
    3. Research and computation: Run features, signals, portfolios, and backtests under the same rules. Avoid having one implementation for research and another for live operation.
    4. Risk and portfolio management: Apply constraints on position size, sector exposure, daily turnover, and suspended securities.
    5. Scheduling and runtime: Schedule jobs around trading days. Containers help keep the runtime environment consistent.
    6. Observability and notifications: Log each job’s input versions and output signals. Alert the user when data is missing, jobs fail, or signals appear abnormal.

    A message queue can decouple “computation completed” from “notification sent,” preventing notification failures from disrupting calculation jobs.

    If using cloud infrastructure, select services by basic capability: scheduled execution, object storage, logging, and alerts. A first version does not need a complex distributed computing platform.

    3. Get the Data Right Before Adding More

    Many quantitative trading errors originate in data rather than formulas. A daily trend-following system needs, at minimum:

    • A trading calendar
    • Open, high, low, and close prices
    • Trading volume
    • Adjusted prices or adjustment factors
    • Trading suspension and daily price-limit status

    Use a consistent corporate-action adjustment convention. In A-share data, forward-adjusted series, which restate historical prices to the current price basis, are convenient for chart analysis. Backward-adjusted series, or raw prices combined with adjustment factors, can make it easier to avoid artificial returns around corporate-action dates in backtests. Signals and execution prices must use a consistent basis.

    Organize the data pipeline into four steps: fetch, validate, store, and version.

    Validation should check whether:

    • Dates belong to the trading calendar
    • Prices are positive
    • High prices are not below low prices
    • Volume is consistent with suspension status
    • Missing-data rates exceed a defined threshold

    A failed validation should block that day’s signals, not trigger arbitrary filling followed by forced calculation.

    Record a batch identifier whenever data is stored. Backtest reports must be traceable to that batch; otherwise, results cannot be reproduced.

    Real-time or near-real-time data can wait. Post-close batch processing is sufficient to validate a daily strategy, with more manageable latency and interface reliability. Minute-level data adds complications involving storage, corporate-action adjustments, opening auctions, and market-session breaks. Consider it only after the daily workflow works end to end.

    4. Express Strategies as Computable Rules

    Trend following has many mathematical formulations. Start with one that is easy to explain, such as:

    • Price relative to a moving average
    • A channel breakout
    • Agreement in momentum direction across several observation windows

    Express the rule as a pure function. Its input should contain only information available on or before the evaluation date; its output should be a target position or discrete signal. Reading a “next-day” field inside the function is a common source of look-ahead bias.

    The following is a conceptual separation of responsibilities, not a trade-ready implementation:

    • Signal calculation: Use the adjusted price series available through day T to determine the instrument’s target state after the close: flat, holding, or reducing exposure.
    • Execution assumption: Generate the signal after the close on T. Assume execution no earlier than T+1 at a predefined price, with costs deducted.
    • Recordkeeping: Save the instrument, date, signal, trigger reason, parameters, and data batch.

    Avoid broad parameter searches at the outset. Fix a set of windows with a plausible economic rationale—for example, medium-term trends rather than very short-term noise—and inspect the resulting behavior.

    Are signals infrequent? Do they reverse repeatedly in sideways markets? Frequent reversals often mean transaction costs will consume the apparent advantage. Consider filtering the signals before pursuing further parameter fitting.

    5. Backtest the Process, Not Just the Equity Curve

    A backtest should answer two questions: how the rules behaved historically under explicit execution assumptions, and how sensitive that behavior is to those assumptions.

    At minimum, include the following.

    Execution Prices

    Declare the execution-price assumption in advance: the next session’s open, next-day average price, or an executable price after signal generation where the market permits it. Do not use a signal-day price that was no longer available when the signal became known.

    Transaction Costs

    Estimate commissions, transaction taxes, and slippage using conservative constants. In China’s A-share market, selling costs are generally higher than buying costs; do not reverse the direction of that asymmetry.

    Trading Constraints

    Account for daily price limits, suspensions, and price gaps when trading resumes. Do not assume that an arbitrary quantity can always trade at a theoretical price.

    Account Equity

    Mark account equity to market each day. Simply adding individual trade returns ignores overlapping positions and capital allocation.

    Sample Splits

    Use an earlier period to develop the rules and a later period for a single confirmation. Repeatedly tuning parameters on the full dataset effectively embeds future information in those parameters.

    Beyond cumulative returns, review at least:

    • Maximum drawdown
    • Return-to-drawdown ratio
    • Turnover
    • Distribution of holding periods
    • Performance by year
    • Percentage of time spent out of the market

    Trend strategies often experience long stretches of small losses or uneventful performance, with a few trends producing most of the profits. An unusually smooth backtest should prompt checks for look-ahead bias, survivorship bias—such as using only current index constituents—or omitted costs.

    Robustness checks matter more than adding another indicator. Shift lookback windows by several days, raise cost assumptions, exclude extreme years, and try simple position-sizing rules other than equal weighting. If the conclusion holds only at one parameter setting, the strategy should not proceed to live alerts.

    6. Separate Signals from Risk and Position Sizing

    A signal is not an order instruction. The risk layer translates it into an acceptable target position.

    For a personal account, favor simple, explicitly enforced rules, such as:

    • Maximum exposure to one instrument
    • Maximum total exposure
    • Maximum number of simultaneous holdings
    • Maximum exposure to one sector
    • Reduced exposure or a halt to new positions after a drawdown threshold is reached

    Set these limits according to losses you can tolerate, not the values that produce the best backtest.

    Typical trend-following risks include repeated false breakouts in sideways markets and sharp givebacks near the end of a trend. Define when a position must be exited: a rule reversal, a trailing-stop breach, or a lack of progress within the planned holding period. An entry rule without an exit rule is only half a strategy.

    Distinguish model risk from operational risk. Out-of-sample testing and robustness checks help expose model risk. Least-privilege access helps limit operational risk: an alerting system should not retain a complete set of credentials capable of placing orders, and the computation environment should remain separate from the user’s trading terminal.

    7. Turn Research into a Daily Workflow

    Once the backtest produces explainable behavior under conservative assumptions, build the daily job.

    A recommended workflow is:

    1. Wait for data to become available after the market closes.
    2. Validate the data.
    3. Calculate signals for the full market or a selected watchlist.
    4. Apply risk limits to target positions.
    5. Compare the results with the previous trading day’s state.
    6. Notify the user only of state changes.
    7. Log the complete signal table so that missing alerts can be investigated later.

    Each alert should include the instrument, direction, a short explanation of the triggering rule, the suggested position ceiling, and the data cutoff time. A bare “buy” message is insufficient.

    The user must still check suspensions, company announcements, and available capital before acting. If data is delayed or validation fails, send an operational failure alert and suppress trading signals. Do not repeatedly issue alerts based on stale data.

    Failed jobs must be safely rerunnable and idempotent. Repeating a job for the same trading day should update the same batch rather than accumulate contradictory signals.

    Keep input hashes, parameter versions, and code versions in the logs. Months later, you should still be able to explain why a particular alert appeared.

    8. Establish Engineering Practices and Limits

    Organize the code into data, signals, backtesting, portfolio, and notification modules. Research scripts and daily jobs should share the same signal functions.

    Separate configuration from code, and keep secrets out of the repository.

    Use a small, stable test suite to protect critical invariants:

    • Corporate-action dates should not create unexplained jumps in returns.
    • Removing future data should not change previously calculated signals.
    • Suspended instruments should not execute trades on suspension days.

    These tests are more valuable for preventing silent errors than accumulating indicators.

    AI coding tools can accelerate boilerplate and documentation drafts, but a person must verify data conventions, execution assumptions, and risk thresholds. If a model-generated formula cannot be explained in one sentence, it should not enter a workflow that affects capital.

    The gap between personal systems and professional institutions lies mainly in data procurement, execution algorithms, portfolio optimization, and dedicated research and risk teams—not in whether someone has implemented a moving average.

    A runnable first version within a few weeks is realistic when the scope stays limited to daily data, a watchlist, signal alerts, and rigorous backtesting. Automated execution, intraday trading, and complex portfolios should each be separate follow-up projects, with fresh assessments of permissions, latency, and compliance.

    9. Operate, Observe, and Refine After Launch

    Launch is not the end of the process. Begin with paper or simulated tracking through at least one complete sideways phase and one trending phase. Compare alerts with subsequent prices and record three types of discrepancy:

    • Misunderstanding of the rules
    • Data errors
    • Failure to follow the alerts

    Consider parameter changes only after the sources of these discrepancies are clear. Any adjustment must go through out-of-sample validation again. Do not casually change lookback windows in response to a few weeks of gains or losses.

    If signal quality remains stable over time, assess whether finer-grained data or stricter portfolio constraints are necessary.

    Until then, the most valuable output is a reproducible research record: the hypothesis behind each experiment, the data batch, the cost assumptions, and the conclusions from failed tests. The advantage of quantitative trading comes from a repeatable process, not a single impressive backtest chart.