How to Use Large Language Models for Stock Cycle Analysis

    This article explains how to position large language models as semantic reasoning engines rather than market data sources or decision makers in stock cycle analysis. It presents a finite state machine that turns market "seasons" into computable stages, a three-layer pipeline combining deterministic rule-based screening, model-based ranking with strict prompt constraints, and human review, plus common failure modes and compliance boundaries.

    1. Starting Point: What LLMs Can and Cannot Do

    Many investors ask general-purpose chat models or coding assistants which stock to buy tomorrow, and usually get a compliance-driven refusal. There are two reasons. First, investment advice is regulated, so the model will not output definitive conclusions. Second, and more fundamentally, without external structured input the model only holds general knowledge from public corpora and cannot perceive the current price and volume state of the market.

    The correct positioning is therefore to treat the LLM as a semantic understanding and reasoning engine, not as a market data source or the decision maker. It is good at condensing unstructured information into comparable fields, comparing multiple instruments against given rules, and producing argument chains that can be reviewed. It is not good at producing exact numbers, guaranteeing timeliness, or taking responsibility for outcomes.

    2. Analysis Framework: Turning “Seasons” into a Computable State Machine

    The lifecycle description in traditional technical analysis can be abstracted into a finite state machine. Stages become states, price and volume conditions become transition conditions, and the model only handles explanation and ranking.

    State Typical price/volume profile Action meaning
    Winter Prolonged downtrend, shrinking volume, contracting volatility Observe, do not enter
    Spring Range-bound near the bottom, volume recovering mildly Build a watchlist
    Early summer Volume-backed breakout at a key level, moving averages turn bullish, market recognition lags Priority research zone
    Midsummer Trend established, shallow pullbacks, healthy price-volume alignment Hold and track
    Late summer Accelerating blow-off top, turnover spikes abnormally, news flow turns positive Scale out gradually
    Autumn Weakness after good news lands, breaks key moving averages Exit

    The core discipline of the framework is one sentence: do research only from early summer to midsummer, and manage exits in late summer. This constraint must exist before any model call, otherwise the model output degrades into generalities.

    3. Implementation: A Three-Layer Pipeline

    Layer 1: Rule-Based Coarse Screening (Deterministic Computation)

    Coarse screening must be done in code to stay reproducible. A sketch:

    1. def stage_filter(df, ma_short=20, ma_long=60, vol_ratio=1.5):
    2. df["ma_s"] = df["close"].rolling(ma_short).mean()
    3. df["ma_l"] = df["close"].rolling(ma_long).mean()
    4. df["vol_r"] = df["volume"] / df["volume"].rolling(20).mean()
    5. last = df.iloc[-1]
    6. if last["ma_s"] > last["ma_l"] and last["vol_r"] >= vol_ratio:
    7. return "early_summer" # early summer candidate
    8. if last["ma_s"] > last["ma_l"] and last["vol_r"] < vol_ratio:
    9. return "midsummer" # midsummer candidate
    10. return "other"

    Engineering recommendations: keep snapshots of market and financial data in object storage, decouple batch jobs with a message queue, run compute jobs on a container platform, and send result metrics and job durations to a logging service with monitoring and alerting. This makes it possible to reconstruct why a given instrument was selected at the time.

    Layer 2: Model-Based Fine Ranking (Semantics and Reasoning)

    Coarse screening usually compresses the whole market down to a few dozen instruments. At this point, hand the model a structured list with constraints only, and no hints about conclusions:

    1. Role: quantitative research assistant
    2. Input: candidate list (code, sector, 20-day return, volume ratio, volatility, assigned stage)
    3. Task: within a 2-3 trading day window, rank by "probability of trend continuation" and output 2-3 priority names to watch
    4. Constraints:
    5. 1. Reason only from the provided input fields; do not introduce data that was not supplied;
    6. 2. Every conclusion must list at least two supporting fields and two risk fields;
    7. 3. Do not provide target prices, position sizes, or return promises;
    8. 4. Output a JSON array with fields code / rank / reason / risk.

    The key design is a field whitelist + output schema constraint + prohibitive clauses. The first suppresses fabricated data, the second makes results consumable by programs, and the third holds the compliance line.

    Layer 3: Human Review and Record Keeping

    Model output is a hypothesis, not a conclusion. The review checklist covers whether the stage assignment matches the chart, whether any disclosure event is pending, whether the sector is moving in sync, and whether liquidity is sufficient. Every analysis should be archived so it forms a sample with measurable win rates, rather than iterating on impressions.

    4. Common Failure Modes

    • Stage misclassification: breakouts fail frequently in range-bound markets, so add a “broad market state” switch and reduce the number of candidates in weak markets.
    • Data leakage: using future data when computing rolling indicators inflates backtest results.
    • Overfitting: repeatedly tuning parameters only fits historical noise; fix the parameters and validate out of sample.
    • Prompt drift: output style changes after a model version update, so put prompts under version control and run regression tests.

    5. Compliance and Risk Boundaries

    The model participates in the information processing step; the decision and its consequences remain with the person. Do not collect inside information or write non-public data into prompts; do not upload account data containing personally identifiable information; label all output as “research reference, not investment advice.” If you use cloud services, pay attention to general capabilities such as data encryption, access auditing, and least-privilege permissions.

    6. Conclusion

    The value of an LLM is not pressing the button for you, but compressing a huge candidate set into a few explainable watch items and forcing you to write down your reasoning. Rules handle determinism, the model handles induction and comparison, and the person handles the decision and the accountability. That division of labor is the methodology that stays reusable over time.