A Reproducible AI-Assisted Stock Screening Pipeline Using a Cycle-Based Model
This article outlines a reproducible workflow for using AI as a research assistant in stock screening. It explains how to avoid common pitfalls when asking AI models for market advice, how to define a quantitative six-phase cycle model with specific technical parameters, and how to build a transparent screening pipeline with manual verification checkpoints. The guide also covers prompt engineering for structured data analysis, backtesting methods to avoid overfitting, and a risk management framework for integrating AI output into a disciplined trading process.
Why AI Cannot Judge Real-Time Market Conditions
When interacting with conversational AI models, a common first request is: “Which stock should I buy right now?” The model typically responds with general risk warnings. This is not a limitation of the model’s design, but rather a result of two objective constraints.
First, general-purpose dialogue models have a training data cutoff date. They do not have real-time access to market quotes, corporate announcements, or capital flows. If a model relies on its training data to state that “trading volume has recently expanded” or “last quarter’s revenue grew,” this information may be outdated or even incorrect. Second, any language that suggests a stock will “definitely rise” could mislead investors and potentially violate compliance standards. Therefore, models should not recommend specific securities in a tone of certainty.
Within a stock selection workflow, the appropriate role for AI is to process structured materials. The full-market scan should be completed by quantifiable rules, while the model handles tasks like organizing, comparing, and flagging risks—using only data that you have already verified.
Cycle Positioning: Translating Six Market Phases into Computable Parameters
Stock price movements often follow stage-based rotations. To make these stages easier to quantify, a stock’s price trend can be divided into six phases. The thresholds in the table below are examples only; you must calibrate them through backtesting on your own historical data before using them.
| Cycle Phase | Moving Average Pattern | Volume Characteristics (5-Day Volume Ratio) | Relative Position | Invalidation Condition |
|---|---|---|---|---|
| Bottoming Phase | Close price below 60-day MA; MA flattening or sloping down | Volume ratio consistently below 0.8; volume near 120-day low | Lower band of the 120-day price range | Volume-driven decline with a new low |
| Accumulation Phase | Price oscillating around the 60-day MA | Volume ratio fluctuating between 0.8 and 1.2 | Lower-middle band of the 120-day price range | Break below the accumulation phase low |
| Breakout Phase | Price above 60-day MA; 5-day MA crosses above 20-day MA | Volume ratio on breakout day not less than 1.5 | Breakout above 60-day high | Price falls back below key MA within 3 trading days |
| Markup Phase | 5, 10, 20, 60-day MAs in bullish alignment | Volume ratio maintained between 1.0 and 2.0 | Price trending along the 10-day MA | Close price breaks below 10-day MA |
| Acceleration Phase | Bias ratio (deviation from MA) expanding significantly | Volume ratio above 2.5; turnover rate rising rapidly | Price far from the 60-day MA | High-volume stagnation or long upper shadow at high levels |
| Distribution Phase | MAs flattening; price oscillating at highs | Volume ratio expands then retreats | Price cannot continue rising after a new stage high | Break below the 20-day MA |
The purpose of this table is to provide a condition set for each phase that can be evaluated programmatically. It is not a prediction tool. It only indicates which condition set a stock’s recent price action matches; results change as new data arrives.
Building the Pipeline: Defining Parameters and Running a Full-Market Scan
Step 1: Specify the Definition of Each Parameter
The reproducibility of the screening results depends on how well you define parameters. At minimum, fix the following elements and document them in your research notes:
- Moving average periods: Use 5-day, 10-day, 20-day, and 60-day moving averages based on closing prices. Add a 120-day MA if you need a longer-term reference.
- Volume ratio definition: Divide the current day’s trading volume by the average volume of the previous 5 trading days (excluding the current day).
- Stage high/low window: Use the highest and lowest prices over the last 120 trading days to evaluate relative position. The window length must also be validated through backtesting.
- Dividend adjustment method: Use forward-adjusted price data consistently. Mixing different adjustment methods will cause incorrect moving averages and price positions.
- Data cutoff timestamp: Record the exact data cutoff for every screening run, for example, “closing data as of November 24, 2026.”
Step 2: Define Screening Rules and Invalidation Conditions
The following rules serve as an example for a first-round screen:
- Trend direction: Close price is above the 60-day MA, and the 5-, 10-, 20-, and 60-day MAs are in bullish order.
- Volume confirmation: The volume ratio on the breakout day is not less than 1.5, or a similar volume expansion occurred within the last 3 trading days.
- Relative position: The drawdown from the 120-day high does not exceed a preset threshold, and the gain from the 120-day low does not exceed a separate preset threshold. Both thresholds should be based on historical distribution analysis.
- Momentum support: MACD is above the zero line, or a golden cross forms near the zero line.
- Risk filters: Exclude stocks labeled with special status (e.g., ST stocks), stocks listed for fewer than 60 trading days, and stocks with major negative announcements within a specified period before the screening date. Announcement sources should use official exchange disclosures or formal announcement databases, with the announcement date recorded.
Every rule should come with an invalidation condition. For example, if a stock meets the trend condition but falls below the 10-day MA the next day, it no longer matches the characteristics of the markup phase and should be removed from the candidate list.
Step 3: Execute the Full-Market Scan
In your stock screening tool or database, set each rule as a filter condition. After the scan, export the candidate stock codes, names, screening date, and data cutoff time. Save the result as a text or spreadsheet file.
The number of candidates depends on parameter settings and market conditions. Record the result count for each run. If a screening run returns far more or far fewer candidates than expected, first check your parameter definitions—do not adjust thresholds simply to produce a more pleasing result.
AI Comparative Analysis: Restrict the Model to Your Supplied Data
After the initial screening, you can provide the candidate list and your own organized dataset to a conversational model. The key is to strictly define the model’s scope. Below is a prompt template you can adapt to your data structure:
【Task Description】The data below has been compiled by the user from authoritative sources, with sources and cutoff times noted.Perform comparative analysis based solely on this data. Do not use any market quotes, announcements, or financial data from your memory.【Constraints】1. If required data is not provided, mark it as "missing data." Do not infer or fill in the gap.2. Cite the data source and timestamp for every conclusion.3. Assign an uncertainty level—high, medium, or low—to each conclusion, with a rationale.4. Do not output buy, sell, or hold recommendations. Only list risk points that require manual review and hypotheses that require validation.5. If the data contains contradictions, point them out explicitly. Do not choose one side on your own.【Data】Target codes: [Fill in]Data items: [e.g., last 60 days of closing prices, volume ratio series, latest quarterly key indicators, each with source and cutoff date]
The value of the model lies in quickly organizing information. It can arrange data from dozens of stocks into a table according to your defined dimensions, identify missing items, and highlight areas that need manual verification. It is not a substitute for investment research judgment, nor should it directly rank targets or give trading instructions.
Backtesting and Out-of-Sample Validation
Before using any parameter in live trading, it must be validated through backtesting. A common approach is to split historical data into two segments: the first segment is used to set thresholds, the second segment is used for validation. If a strategy performs well on the first segment but significantly worsens on the second, the parameters may be overfit to the historical data.
Backtesting must also account for transaction costs, including commissions, stamp duties, bid-ask spreads, and slippage. Price limits, trading suspensions, and insufficient liquidity can cause actual fills to differ from theoretical results. Record the win rate, average profit/loss ratio, maximum drawdown, and sample size—do not rely only on a single attractive return figure.
Backtesting and small-scale live validation only show how the rules performed in the past or during a specific period. They do not guarantee future returns or win rates.
Risk Control: A Framework Matters More than Numbers
Many articles provide specific position sizes or stop-loss percentages. Those numbers cannot be applied directly without adjustment. The appropriate position size and stop-loss level depend on individual asset scale, income stability, investment horizon, and risk tolerance. This article does not provide specific values.
A useful framework includes the following components:
- Maximum loss per trade: Start by determining the maximum loss amount you are willing to accept for a single trade, then work backward to calculate the position size.
- Define exit conditions before entry: Write down the stop-loss level and the logic behind it before making a purchase, for example, “close price breaks below the 10-day MA and fails to reclaim it for two consecutive days.” Deciding on exit after the position is open tends to be influenced by emotions.
- Scale in and scale out in batches: Phased entries and exits can reduce the impact of a single incorrect judgment, but they also increase transaction costs. Balance this against your specific situation.
- Diversify at the portfolio level: Avoid holding multiple stocks that could decline simultaneously due to the same factor. For example, several stocks in the same sector that all depend on the same policy still represent concentrated risk.
Common Mistakes to Avoid
First, treating AI’s analysis as real-time data. The accuracy of the model’s output depends on the accuracy of the data you provide.
Second, treating the initial screening result as a buy signal. A screen only indicates that a stock meets certain rules; it does not guarantee future appreciation.
Third, ignoring transaction costs and slippage. Frequent, small trades may completely erase profits after costs are deducted.
Fourth, repeatedly tuning parameters until backtest results look good. Rules built this way typically fail to reproduce on new data.
Fifth, failing to maintain a review record. For each screening and trade, record the date, parameters, data sources, AI output, actual price movement, and the reason for any deviation. Over time, this record becomes more valuable than any single conclusion.
The Boundary of Human-AI Collaboration
This workflow narrows your focus and ensures every step is traceable and documented. It helps you reduce impulsive decisions and clarifies the reasoning behind each judgment.
It cannot eliminate market uncertainty. Macro policy adjustments, unexpected events, and shifts in market style can invalidate rules based on historical patterns. Therefore, a single strategy should not absorb all of your capital. Maintaining sufficient cash reserves is a more prudent approach.
Disclaimer
This article describes a research methodology and tool usage approach. It does not constitute any stock recommendation, investment advice, or return promise. All parameters and thresholds in this article are examples only and must be validated through backtesting on your own data. Markets carry risk, and investment requires caution. Before making any operational decisions, consult a licensed investment advisor and make independent judgments based on your own risk tolerance.
