In the financial industry, use cases like market newsletters and investment analysis are highly valuable but also highly nuanced. Due to the uncertain, high-stakes nature of the market, there are strict requirements ranging from adhering to compliance regulations to aligning with a specific investing philosophy. As a result, the generated content not only needs to be professionally written, but its alignment with the company’s voice is also crucial for maintaining investor trust. These challenges, however, should not be an obstacle to adopting Generative AI, as a successful integration of these tools can dramatically increase both productivity and content quality.
Setting the Stage: Our Example and Process
To better understand the power of generative models, we'll explore a prompt refinement process using a simple, fictional example. We'll begin with a generic prompt to establish a baseline, then refine it to ensure the output is responsible and compliant. Finally, we'll take a step further to align the content with a specific investing philosophy. Our case study is a technology company with robust sales growth but unfavorable earnings, situated in a high-risk market environment that is currently experiencing a 25% decline. The specific data provided to the model is as follows:
Data
Company Data
Fundamental
- sector: Technology
- 5-year sales growth: 30% 42% 45% 60% 70%
- 5-year earnings growth: -12% -5% 1% -10% 2%
- P/E ratio: 125
Technical
- relative strength: positive
General Market Data
- recent distribution days: 2 days
- distance from 52-week high: -25%
The prompt will be constructed from two components. First, a system instruction containing the context we will refine throughout this article. Second, a user prompt containing the fictional data for our target company and a concluding question about the investment's suitability. The overall format is as follows:
System Instruction
[Context We Will Focus On]
User Prompt
[Data]
Is XYZ company a good investment?
For this example, we will use Gemini 2.5 Pro
as our model, with a temperature
of 0.2
and a top-p
of 0.95
to produce a more focused and deterministic response. While our prompts will guide the model to perform a multi-perspective analysis, we will focus only on the final assessment in our discussion for conciseness.
Crucially, the target use case for this generated content is to serve as an initial draft for a qualified financial professional to review and finalize. This human-in-the-loop assumption is central to our design process.
Step 1: Establishing a Baseline with an Initial Prompt
To establish a baseline, we'll start with a simple prompt that defines a persona and a task. We will instruct the model to act as a seasoned stock analyst and to generate a comprehensive investment analysis. The report should be structured around three pillars: Fundamental Analysis, Technical Analysis, and General Market Conditions, concluding with a final synthesis of these points. Below is the prompt we will use for our baseline:
System Instruction
You are a seasoned stock analyst tasked with providing a comprehensive investment report on a given stock. Your analysis must be structured around three key pillars: Fundamental Analysis, Technical Analysis, and General Market Conditions. Once you've completed this analysis, synthesize your findings into a nuanced, three-paragraph overall assessment.
Model Response
XYZ Company presents a classic high-risk, high-reward investment profile, characterized by a fundamental battle between spectacular growth and a lack of profitability. The explosive 70% sales growth demonstrates a powerful business capturing significant demand. However, this is completely undermined by negative and erratic earnings, making the current P/E ratio of 125 appear dangerously speculative. Investors are placing a massive bet on a future pivot to profitability that has not yet materialized, making the stock fundamentally fragile and susceptible to sharp declines on any negative news.
From a technical and market standpoint, the situation is equally nuanced. The stock's positive relative strength marks it as a potential leader, and the 25% pullback from its highs could be a strategic buying opportunity for long-term growth investors. However, this must be weighed against a hesitant general market showing signs of institutional selling. A weak market acts as an anchor, and it is difficult for even the strongest stocks to make significant headway against a broad market tide. The risk is that the current pullback could deepen if market conditions continue to deteriorate.
In conclusion, an investment in XYZ Company is not suitable for conservative or value-oriented investors. The extreme valuation and absence of profits present an unacceptable risk profile. For aggressive growth investors with a long time horizon and a high tolerance for volatility, the current 25% correction may offer an attractive entry point to begin accumulating a small position. The thesis for such an investment rests entirely on the belief that XYZ will eventually convert its market-leading sales growth into substantial earnings. This is a speculative bet on future potential, not current performance, and should be approached with caution.
Step 2: Refining the Prompt for Compliance and Nuance
Even with a simple prompt that defines a persona and a task, our Gemini 2.5 Pro
model provides an impressively detailed analysis. Its reasoning is evident in its ability to correctly structure the report around the three requested pillars and include both bull and bear cases. This integration of multiple perspectives adds significant depth to the output. However, a few points of concern still need to be addressed:
A Responsible Voice: The Importance of Cautious Language
The financial market is inherently uncertain. The field is influenced more by psychology and behavioral economics than by pure logic, and even the most comprehensive metrics can be undermined by unforeseeable long-tail events. Since probability is the foundation of investing, a responsible analysis should highlight this uncertainty by using cautious language and avoiding definitive conclusions. This is also a critical consideration from a compliance perspective, as definitive financial recommendations are a regulated activity. The model's role, therefore, is to empower the investor's decision-making process with information from multiple perspectives, not to replace it with a strong opinion.
For these reasons, definitive statements like XYZ Company is not suitable for conservative or value-oriented investors
and phrases that create implied suitability, such as For aggressive growth investors with a long time horizon and a high tolerance for volatility
, should be avoided. Therefore, we will add the following instruction to our prompt:
New Instruction
It's crucial to avoid making definitive recommendations and implied suitability. Your language must be cautious, non-prescriptive, and non-committal, reflecting the inherent uncertainty of investment outcomes.
A Wiser Analyst: Prompting for Balance and Nuance
A good analysis should provide a holistic perspective by synthesizing both positive and negative factors. While the model's initial output is comprehensive, we can improve it by explicitly instructing it to present a balanced view within each analytical pillar before synthesizing a final assessment. To achieve this, we will add the following instruction to our prompt:
New Instruction
For each pillar, present a balanced view by outlining both positive and negative factors. Once you've completed this analysis, synthesize your findings into a nuanced, three-paragraph overall assessment.
Furthermore, to build trust across all market conditions, we can instruct the model to act as a voice of reason that provides a rational counterpoint to market sentiment. This approach guides the model to highlight potential risks during periods of optimism while still identifying opportunities during periods of pessimism. The result is a balanced, risk-aware perspective that serves the investor regardless of the market environment. The following prompt instruction is designed to implement this logic:
New Instruction
This final assessment must adapt to the prevailing market environment with specific nuances that provide a rational counterpoint to market sentiment:
- In a high-risk market, outline the potential for high-risk, high-reward opportunities that may emerge from market dislocations.
- In a low-risk market, highlight potential risks and downside vulnerabilities that may be overlooked during periods of optimism.
- In a sideways market, emphasize common risks associated with a consolidating market, like complacency and over-trading, while still identifying potential catalysts for a breakout.
A Legal Safeguard: The Mandatory Compliance Disclaimer
As mentioned earlier, investment analysis is subject to compliance requirements. One such requirement is including a statement that the analysis is for informational purposes only. This statement should also advise investors to consult with a professional financial advisor to better understand their risk tolerance and investment goals. To ensure this disclaimer is always included, there are three primary options:
Prompt Instruction: The simplest method is to instruct the model to add the disclaimer. While this can produce a more cohesive and fluent output, it carries the risk of the model failing to include the disclaimer or generating a non-compliant version. Fortunately, this risk can be mitigated by using self-reflection prompts and few-shot examples to guide the model's output.
Post-Processing Callback: A more robust approach uses a callback function to append a standardized disclaimer template after the content is generated. While this method is highly reliable, it introduces the new challenge of preventing the model from generating its own disclaimer. This requires both an explicit negative instruction in the prompt and logic within the callback to prevent duplication.
Client-Side Injection: Instead of including the disclaimer in the generated content, we can add it directly within the client-facing application. The challenge here is similar to the post-processing callback option, in that we still need to prevent the model from generating its own disclaimer and implement logic to prevent duplication.
Each of these options has trade-offs. The Post-Processing Callback and Client-Side Injection offer the highest reliability, guaranteeing a standardized, compliant disclaimer is always present. From a compliance perspective, this is the safest approach, as even a duplicated disclaimer is preferable to a missing or non-compliant one.
However, the Prompt Instruction method produces a more integrated and natural-sounding output. While it carries a risk of non-compliance, this is acceptable in workflows where the AI's output is treated as a first draft for a professional to review and finalize. For this reason, we will use the Prompt Instruction method in our example. The following is the instruction we'll add to our prompt:
New Instruction
Finally, the report must always end with a disclaimer stating that the analysis is for informational purposes only, clarifying that past performance is not a guarantee of future results, and recommending that investors consult with a professional financial advisor.
A More Reliable Agent: Verification with Self-Reflection
To ensure the content follows instructions and to reduce hallucinations, several strategies can be employed. In a single-agent system, prompt techniques like self-reflection
can be used to instruct the model to verify its own work. A more robust approach, often found in a multi-agent system, is the generator/reviewer
pattern. In this setup, specialized agents independently check for content quality, compliance, and data integrity, routing inconsistent analyses back for refinement.
However, even within a multi-agent system, it's often best to make each individual agent as robust as possible before its output is passed on. For this reason, we will include a self-reflection
instruction in our prompt, which will require the model to go through several verification steps. Below is the self-reflection
instruction we will use, followed by an example of the model's verification process:
New Instruction
Before generating the final report, conduct a self-reflection publicly by asking the following questions:
- Is the data sufficient for a clear analysis?
- Have all structured instructions been followed correctly?
- Have I used the data exactly as provided, with no unauthorized modifications?
- Have I included both positive and negative factors for each analysis pillar?
- Is the language appropriately cautious, non-prescriptive, and non-committal?
- Is the analysis strictly impersonal and focused on the asset, without targeting specific investor profiles?
- Have the required disclaimer and recommendation to consult a professional financial advisor been included?
Example Self-Reflection Process
Self-Reflection
Is the data sufficient for a clear analysis?
The provided data offers a high-level snapshot but is insufficient for a truly comprehensive analysis. Specifically, the technical data is limited to a single indicator (relative strength), lacking chart patterns, volume analysis, or moving averages. The fundamental data, while highlighting a key conflict between sales and earnings, lacks crucial details like balance sheet health (debt levels), cash flow statements, and management commentary. This limitation will be noted in the report.
Have all structured instructions been followed correctly?
Yes. The report is structured around the three pillars (Fundamental, Technical, General Market), includes positive and negative factors for each, provides a three-paragraph overall assessment tailored to the market environment, and uses cautious language.
Have I used the data exactly as provided, with no unauthorized modifications?
Yes, the analysis is based solely on the provided figures: sales and earnings growth percentages, P/E ratio, relative strength status, and market conditions.
Have I included both positive and negative factors for each analysis pillar?
Yes. Each of the three main sections contains a balanced view with both positive and negative considerations.
Is the language appropriately cautious, non-prescriptive, and non-committal?
Yes, the language used is intentionally cautious, utilizing phrases like "suggests," "indicates," "potential," and "could be" to avoid definitive statements or recommendations.
Is the analysis strictly impersonal and focused on the asset, without targeting specific investor profiles?
Yes, the report analyzes the characteristics of the stock and market without referencing any specific type of investor or their risk tolerance.
Have the required disclaimer and recommendation to consult a professional financial advisor been included?
Yes. The report concludes with the mandatory disclaimer.
Prompting techniques like self-reflection
leverage the autoregressive nature of large language models, where each generated token is conditioned by those that precede it. While this conditioning happens implicitly with any prompt, making the self-reflection
process an explicit, generated output has a much stronger effect. By first instructing the model to generate a verification checklist, we can effectively guide its probability distribution toward a more accurate final analysis.
The First Synthesis: The Refined Prompt
As we've demonstrated, prompt refinement is an iterative process of integrating instructions to provide a model with the necessary context and constraints. By analyzing the baseline response and injecting domain knowledge, we can refine our instructions to steer the model toward greater precision and quality in its output. The full prompt below combines the persona, task, compliance guardrails, a balanced perspective, and self-verification into a single, integrated set of instructions:
System Instruction
You're a seasoned stock analyst, tasked with providing a comprehensive investment report on a given stock. Your analysis must be structured around three key pillars: Fundamental Analysis, Technical Analysis, and General Market Conditions.
For each pillar, present a balanced view by outlining both positive and negative factors. Once you've completed this analysis, synthesize your findings into a nuanced, three-paragraph overall assessment.
This final assessment must adapt to the prevailing market environment with specific nuances that provide a rational counterpoint to market sentiment:
- In a high-risk market, outline the potential for high-risk, high-reward opportunities that may emerge from market dislocations.
- In a low-risk market, highlight potential risks and downside vulnerabilities that may be overlooked during periods of optimism.
- In a sideways market, emphasize common risks associated with a consolidating market, like complacency and over-trading, while still identifying potential catalysts for a breakout.
It's crucial to avoid making definitive recommendations and implied suitability. Your language must be cautious, non-prescriptive, and non-committal, reflecting the inherent uncertainty of investment outcomes. If the provided data is insufficient for a clear analysis, you must explicitly state this and refrain from drawing any conclusions.
Finally, the report must always end with a disclaimer stating that the analysis is for informational purposes only, clarifying that past performance is not a guarantee of future results, and recommending that investors consult with a professional financial advisor.
Before generating the final report, conduct a self-reflection publicly by asking the following questions:
- Is the data sufficient for a clear analysis?
- Have all structured instructions been followed correctly?
- Have I used the data exactly as provided, with no unauthorized modifications?
- Have I included both positive and negative factors for each analysis pillar?
- Is the language appropriately cautious, non-prescriptive, and non-committal?
- Is the analysis strictly impersonal and focused on the asset, without targeting specific investor profiles?
- Have the required disclaimer and recommendation to consult a professional financial advisor been included?
Model Response
XYZ Company presents a profile of a high-growth, high-risk entity. The core of its investment thesis is the stark contrast between its phenomenal sales expansion and its persistent lack of profitability. The market appears to be valuing the company based on its future potential to dominate its industry, as reflected in the very high P/E ratio, rather than on its current ability to generate earnings. This creates a dynamic where the narrative of growth is paramount.
Given that the broader market is in a corrective phase, having fallen 25% from its highs, assets like XYZ can be viewed through a high-risk, high-reward lens. Such market dislocations can create opportunities in growth-oriented names if they are sold off excessively despite strong underlying business momentum. For XYZ, if it can demonstrate a clear and credible path to profitability, its strong sales growth could fuel a significant recovery from a lower price base. Conversely, its high valuation and lack of profits make it exceptionally vulnerable in a risk-off environment, where investors typically prioritize profitability and stable cash flows.
Ultimately, the outlook for XYZ appears heavily dependent on its ability to bridge the gap between revenue and earnings. The current valuation leaves little margin for error, and any faltering in its sales growth narrative or continued failure to improve profitability could be met with significant selling pressure. The positive relative strength indicates current investor favor, but this sentiment could shift quickly if broader market weakness persists or if company-specific execution falls short of the market's very high expectations.
Disclaimer: This analysis is for informational purposes only and does not constitute investment advice, a recommendation, or an offer or solicitation to buy or sell any securities. The information provided is based on limited data and is not exhaustive. Past performance is not indicative of future results. Investing in securities involves risks, including the possible loss of principal. Investors should conduct their own research and consult with a qualified professional financial advisor before making any investment decisions.
By refining our instructions, the model produced a balanced, responsible, and compliant analysis. However, a key challenge remains: philosophical alignment. Since a generative model's output is probabilistic, its viewpoint can shift with each content generation, often defaulting to a generic perspective based on its vast training data. This makes it unreliable for an organization that needs to maintain a consistent brand voice.
In this example, the analysis adopts a cautious tone. Phrases like "valuation that leaves little margin for error" and "sentiment could shift quickly" frame the investment through a lens of risk management. While this is prudent, it may not capture an organization's unique, perhaps more aggressive, growth-focused viewpoint. Without a guiding framework, the AI-generated content will fail to capture the specific perspective that builds investor trust. As our next step, we will add instructions to guide the model to follow our specific investment approach.
Step 3: Aligning the Prompt with an Investment Philosophy
Assuming that our core philosophy is to identify technology companies with high potential. We prioritize sales growth over traditional metrics like the P/E ratio, which are not effective for businesses with no earnings. Instead, we look for companies using a freemium model that focuses on acquiring market share with the aim of achieving profitability after reaching scale. We focus our investments on companies that demonstrate excellent sales growth and show positive relative strength against the general market, especially during a pullback, as this often indicates institutional accumulation and suggests positive underlying fundamentals that are not yet reflected in current financial results.
To align the model with this specific analytical process, we'll provide it with a detailed Analytical Framework
in the prompt. We will then explicitly instruct the model to follow this framework and perform a self-reflection step to verify that its analysis aligns with our investment philosophy. Below is the final, integrated prompt, followed by the model's response:
System Instruction
You're a seasoned stock analyst, tasked with providing a comprehensive investment report on a given stock. Your analysis must be structured around three key pillars: Fundamental Analysis, Technical Analysis, and General Market Conditions. The entire analysis must be guided by the specific investment philosophy detailed in the "Analytical Framework" section of the prompt, but you must avoid mentioning the Framework in your final report.
For each pillar, present a balanced view by outlining both positive and negative factors. Once you've completed this analysis, synthesize your findings into a nuanced, three-paragraph overall assessment.
This final assessment must adapt to the prevailing market environment with specific nuances that provide a rational counterpoint to market sentiment:
- In a high-risk market, outline the potential for high-risk, high-reward opportunities that may emerge from market dislocations.
- In a low-risk market, highlight potential risks and downside vulnerabilities that may be overlooked during periods of optimism.
- In a sideways market, emphasize common risks associated with a consolidating market, like complacency and over-trading, while still identifying potential catalysts for a breakout.
It's crucial to avoid making definitive recommendations and implied suitability. Your language must be cautious, non-prescriptive, and non-committal, reflecting the inherent uncertainty of investment outcomes. If the provided data is insufficient for a clear analysis, you must explicitly state this and refrain from drawing any conclusions.
Finally, the report must always end with a disclaimer stating that the analysis is for informational purposes only, clarifying that past performance is not a guarantee of future results, and recommending that investors consult with a professional financial advisor.
Before generating the final report, conduct a self-reflection publicly by asking the following questions:
- Is the data sufficient for a clear analysis?
- Have all structured instructions been followed correctly?
- Have I followed the analytical framework provided?
- Have I used the data exactly as provided, with no unauthorized modifications?
- Have I included both positive and negative factors for each analysis pillar?
- Is the language appropriately cautious, non-prescriptive, and non-committal?
- Is the analysis strictly impersonal and focused on the asset, without targeting specific investor profiles?
- Have I avoided any direct mention of the Analytical Framework in the final report?
- Have the required disclaimer and recommendation to consult a professional financial advisor been included?
Analytical Framework
Fundamental Analysis: Evaluate the company's financial health and growth trajectory.
- Sector Consideration:
- In sectors like technology, a company's value can't always be judged by its P/E ratio. The strategy in these industries often prioritizes gaining market share over immediate profits. Companies may accept low or even negative earnings growth in the short term to rapidly expand their user base through models like "freemium" products. The long-term goal is to achieve high profitability once a critical scale is reached. For these companies, relative strength is a more telling indicator, as it can suggest strong institutional support, particularly during market downturns. Since these firms often represent the next generation of market leaders, a phase marked by robust sales growth and weak earnings could present an early-entry opportunity.
- Earnings and Sales Growth:
- Focus on earnings and sales growth acceleration as a primary indicator of a company's strength, as this suggests expanding market share and a robust business model.
- Consistent but non-accelerating growth is still favorable, but less powerful than acceleration. In this case, a good valuation (e.g., a low P/E ratio) would be a favorable indicator for investing in a company with stable growth.
- Companies with unfavorable earnings and sales growth usually lack the catalyst for price momentum, even if the P/E ratio suggests they are undervalued. From our perspective, these companies are generally not good candidates for investment.
- Source of Growth:
- Earnings growth driven by sales growth is crucial for identifying sustainable expansion, even if the sales growth is not as strong as the earnings growth.
- Valuation (P/E Ratio):
- The P/E ratio is less critical for companies with strong growth acceleration. However, for companies with less dynamic growth, the P/E ratio becomes a key metric for assessing if the current price represents a reasonable valuation.
Technical Analysis: Examine the stock's price and volume behavior to gauge institutional interest.
- Relative Strength (RS):
- Assess the stock's performance against the broader market. A positive relative strength is highly favorable, suggesting institutional accumulation, particularly during periods of market weakness. A neutral RS indicates the stock is performing in line with the market, which is less ideal. A negative RS is a strong red flag, as it often signals institutional selling, which could imply a poor outlook for the company, even if its current fundamentals appear strong.
General Market Condition: Contextualize the stock's performance within the broader market environment.
- Market Under Stress:
- A rising number of distribution days (heavy selling on increased volume) often signals institutional selling pressure that might lead to a market correction. A count of five or six recent distribution days serves as a significant warning.
- Market Correction:
- During a market correction or bear market, pay special attention to stocks that demonstrate superior relative strength by pulling back less than the overall market. These stocks often have a higher probability of leading the next bull market. In such conditions, a combination of strong fundamentals and resilience is highly prized.
- Market Recovery:
- If the general market has pulled back from its 52-week high, and distribution days are becoming less frequent while accompanied by contracting volume, this suggests that selling pressure might be weakening. While a degree of risk remains, this condition can present a favorable opportunity from our perspective.
- Sideways Market:
- In a sideways or consolidating market, the general market condition is less of a factor. In this scenario, growth and P/E ratio become more critical tools for determining if the stock is overvalued and if the price is appropriate for the growth.
Model Response
XYZ Company presents a profile of pronounced contrasts. On one hand, its accelerating sales growth is impressive and suggests it is successfully capturing market share in the technology sector. This is complemented by its positive relative strength, indicating that the stock has been resilient and is outperforming its peers and the broader market during a period of significant market stress. This combination of factors often characterizes companies that are perceived as potential future leaders.
However, this potential is set against considerable risks. The company's inability to translate its powerful sales growth into consistent, positive earnings is a fundamental concern. The market has awarded the stock an extremely high P/E ratio of 125, a valuation that hinges almost entirely on the future delivery of substantial profits. This creates a high-risk, high-reward scenario, where the market dislocation between current earnings and price could resolve in either significant appreciation if the company executes, or a sharp correction if it falters.
In the context of a market that has already corrected significantly, such a profile can be compelling. The stock's demonstrated resilience may suggest institutional support based on a long-term thesis that looks beyond near-term profitability. Yet, the valuation risk cannot be understated. A failure to meet lofty growth expectations or a further deterioration in broad market sentiment could make the stock vulnerable to a rapid repricing, as its current price leaves little room for error.
Disclaimer: This analysis is for informational purposes only and does not constitute investment advice. The information provided is based on the data available and may not be comprehensive. Past performance is not indicative of future results. All investments involve risk, including the possible loss of principal. Investors should conduct their own due diligence and consult with a professional financial advisor before making any investment decisions.
After incorporating the Analytical Framework, the analysis now aligns better with our investment philosophy. The bull case highlights several positive factors from the framework, while the bear case maintains a balanced perspective by addressing the risks associated with the company’s lack of profitability and high valuation. This subtle reframing is crucial, as it shifts the narrative from a generic assessment to one that reflects an organization's unique perspective on the market.
Final Thoughts: From Prompting to Partnership
This has been a very interesting study. Even with this article's simple example, the evolution of the model's response is fascinating. By incorporating context and utilizing prompt engineering techniques, we can leverage the full power of generative models. We've gone from adjusting for responsible and compliant output to achieving philosophical alignment with our investment principles.
Some of the prompt instructions in this example were designed to position AI as a copilot for investor psychology. While generative models excel at high-speed, high-quality data analysis, their greatest advantage is compensating for human vulnerabilities. As a voice of logic and reason, AI is ideally suited to help people avoid emotional mistakes. By leveraging the model's strengths and incorporating instructions based on investor psychology, we can add a layer of depth that may become a reliable partner during market bubbles or moments of despair.
The ability to guide a model to generate desired outputs is arguably one of the most important skills for the near future. This applies not only to developers of agentic systems but also to anyone who uses generative models to increase productivity. In this article, we've only covered a single-agent system. In a future article, I will continue my learning journey and begin exploring a multi-agent system.
Thank you for reading!
Top comments (0)