A large language model (LLM) is a generative AI model trained on extensive data to process language and produce answers. Unlike a stock-price forecasting model, it supports broad natural-language tasks, including financial research. Its attention mechanism focuses on relationships between keywords, enabling models with billions of parameters. section 8.2 section 8.5
Use LLMs as research assistants rather than unquestioned investment advisers:
- Summarize lengthy company documents, earnings materials, and presentations into focused research notes. section 8.3.1
- Investigate management performance, lawsuits, insider trades, business models, customer segmentation, and nonfinancial risks. section 8.3.1
- Improve answers by supplying an investor profile with goals, risk tolerance, capital, sectors, and relevant domain language. section 8.4.1
- Treat outputs as preliminary evidence: models may hallucinate, use dated information, produce nondeterministic answers, or reflect incomplete context. section 8.2.1 section 8.2.3
Programmers can call proprietary services through APIs or run open-source models locally. Python integrations accept prompts and return responses for further processing. Model choice involves trade-offs: newer or larger models may improve results, while smaller models can reduce latency and token costs. Parameters such as temperature influence output randomness and speculation. section 8.3.2
Comparing investment prompts
A prompt asking for stocks matching Warren Buffett’s strategy produced Microsoft and Costco among GPT-4o’s suggestions, Costco and Microsoft from Gemini, and Allegion and Danaher from Finance Chat. These differing answers illustrate why model output requires comparison and due diligence rather than automatic acceptance. section 8.2.1
Listing 8.8 Submit a prompt via the OpenAI API
from openai import OpenAI
client = OpenAI(
api_key=api_key
)
completion = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": system_content},
{"role": "user", "content": question}
]
)
Use the OpenAI API pattern to place a system instruction and user question in Python, then retrieve the model response for downstream analysis. section 8.3.2


































































