Can Large Language Models Really Be Used for Stock Selection and Trading?

    This article examines why feeding a stock ticker to a general-purpose LLM and asking whether to buy is bound to fail, and reframes the problem as an engineering one: placing the model inside a pipeline with trustworthy data, verifiable reasoning, and enforceable risk constraints. It outlines the model's key failure points, then presents two practical patterns—external data injection with structured reasoning prompts, and a multi-role architecture with a debate loop and a rule-based risk gate—along with guidance on data pipelines, backtesting without look-ahead bias, evaluation metrics, and compliance. Readers will learn how to use an LLM as a reasoning engine rather than a database or stock-picker.

    1. Restating the Problem: Why “Pass a Ticker, Get a Recommendation” Always Fails

    Many developers start the same way: hand a ticker of a leading stock to a general-purpose large language model and ask whether it is worth buying. The output is usually a neatly structured, jargon-dense analysis that reads like a sell-side research report but does not hold up under verification. The problem is not that the model is “dumb”; the task itself is set beyond the model’s capability boundary.

    Abstracted as an engineering problem, a usable stock-selection or trading-assistance system needs at least three classes of input: structured data such as market quotes and financials; unstructured text such as announcements and news; and an explicit objective function with constraints (holding period, risk budget, compliance limits). A general conversational LLM naturally provides only part of the reasoning ability for the third class. The first two must be supplied by external systems. When inputs are missing, the model fills the gaps with prior knowledge from its parameters, and that filled-in content has no binding relationship with the actual state of the market.

    The right technical question, then, is not “can an LLM trade stocks” but “how do we place an LLM inside a pipeline with trustworthy data, verifiable reasoning, and constrained risk, so it takes on the cognitive work it is good at.”

    2. Capability Boundaries: Three Failure Points You Must Accept

    First, the knowledge cutoff causes temporal misalignment. A model’s parametric knowledge is a static snapshot; it cannot perceive the latest closing price, the most recent earnings release, or the newest announcement. Any judgment that depends on “today” or “recently” degrades into a recollection of a historical fragment.

    Second, the model is offline by default and lacks proactive information retrieval. Whether it can search the web depends on the specific deployment and cannot be assumed. Even with retrieval, the relevance, timeliness, and source credibility of the results still require engineering-side validation; a retrieval summary cannot be treated as fact directly.

    Third, the model has zero awareness of data outside the prompt, and its expression is highly persuasive. This is the most dangerous point: the optimization target of a language model is to generate fluent, plausible-sounding text, not to guarantee factual correctness. In a financial context, the gap between “reads professionally” and “conclusion is correct” is amplified, producing classic automation bias—users tend to trust quantitative statements produced by a machine.

    Add one more failure point that is often overlooked: distribution drift. Market style, industry conditions, and trading rules all change, so a prompt strategy validated over a historical range may fail entirely in a new environment.

    3. Practical Pattern 1: External Data Injection + Structured Reasoning Prompts

    The core idea is to treat the model as a “reasoning engine” rather than a “database.” All facts come from an external pipeline; the model only summarizes, compares, and produces verifiable judgments.

    The minimum viable data set includes: quotes (daily and intraday bars, with adjusted prices), financials (the three main statements and key ratios), events (announcements, dividends, abnormal price moves), and industry comparison (peer valuation and growth percentiles). On the engineering side, it is advisable to unify everything into timestamped fact tables, where any number entering a prompt must be traceable to a record ID.

    On the prompt side, the key is “role + fact block + output contract.” The role constrains the professional perspective, the fact block contains only data, and the output contract specifies the section structure, requires every conclusion to cite a data basis, and forbids buy/sell entry points. A sample template follows (field names are custom placeholders):

    1. You are a senior analyst covering an A-share industry. Answer using only the [FACTS] below.
    2. [FACTS]
    3. - Ticker: {ticker}
    4. - Period: {period}
    5. - Revenue: {revenue}, YoY: {revenue_yoy}
    6. - Net profit: {net_profit}, YoY: {profit_yoy}
    7. - Advance receipts: {advance_receipts}, YoY: {advance_yoy}
    8. - Events in the last 30 days: {events}
    9. [OUTPUT CONTRACT]
    10. 1 Earnings interpretation (must explain two possible causes of the YoY change in advance receipts)
    11. 2 3 bullish points / 3 bearish points (each with a [FACTS] reference number)
    12. 3 5 tracking indicators (no price levels or buy/sell advice allowed)
    13. 4 If [FACTS] are insufficient, output "insufficient evidence" and list the missing fields

    The “insufficient evidence” branch is extremely important: it converts the model’s tendency to hallucinate into an explicit list of data gaps, which makes automated data backfilling easier.

    4. Practical Pattern 2: Multi-Role Collaboration Architecture

    A single prompt struggles to cover both breadth and adversarial rigor. A common industry approach splits the flow into several dedicated roles: fundamental analysis, technical analysis, event and news analysis, market sentiment analysis, a bull-vs-bear debate, trade execution suggestions, and risk control. The LLM handles the two most reasoning-intensive stages—fundamental assessment and final synthesis—while deterministic code handles the rest.

    There are three design points. First, all data fetching and indicator computation is done by programs; the model never touches raw interfaces, which avoids fabrication. Second, force a bull-bear confrontation with a round limit, and require each round to respond to the opponent’s strongest argument or lose, which surfaces real disagreement instead of superficial balance. Third, risk control acts as a veto role, running rule checks on hard constraints such as concentration, drawdown budget, and liquidity, and outputting a structured conclusion rather than natural-language persuasion.

    The flow can be abstracted as:

    1. facts = build_facts(ticker, period) # data pipeline, the single source of truth
    2. report = analyst_fundamental(facts) # model: structured reasoning
    3. views = debate(bull(report), bear(report), rounds=2)
    4. plan = trader(report, views, constraints) # model: synthesis
    5. final = risk_gate(plan, rules) # rules: hard-constraint veto

    5. Engineering Practice: Data, Evaluation, and Risk Control

    For the data layer, a four-stage “collect–clean–store–snapshot” approach is recommended: raw data lands in object storage, normalized results go into a relational or analytical database, task scheduling and retry on failure are decoupled with a message queue, and the whole process is observed through logging and monitoring with alerts. Backtesting must strictly avoid look-ahead bias: every feature may use only information visible at the time, and event timestamps should use the announcement publication time rather than the reporting period.

    The evaluation layer cannot rely on how the output looks. Build quantifiable metrics: factual consistency (comparing cited numbers against the data tables item by item), evidence coverage, strength of bull and bear arguments, and downstream strategy metrics such as win rate, profit/loss ratio, maximum drawdown, and turnover cost. Keep a fixed test set and a fixed random seed so that prompt or model version changes remain comparable.

    The risk control and compliance layer must make clear that system output is positioned as research-assistance material and does not constitute investment advice; that externally displayed output retains a watermark with data sources and generation time; and that high-risk statements are blocked by templates.

    6. Conclusion

    Whether an LLM can be used for stock selection and trading depends on whether it is embedded in trustworthy data and hard constraints. Used as a “database” or a “stock-picker,” it will inevitably hit pitfalls; used as a “structured reasoning and argument-adversarial engine,” combined with external data injection, division of labor across roles, rule-based risk control, and rigorous backtesting, it can become a stage in the research workflow with clear efficiency gains. If general-purpose capabilities from Baidu AI Cloud are used to carry the data pipeline, task scheduling, and monitoring, more effort can go into designing the prompt contracts and the evaluation system—and that is what determines the upper bound of results.