Stock queries
The use of this flow is to act as a finance expert to answer questions about markets. It uses an agent that, upon a request for actions, accesses data from Yahoo Finance and then uses that information to generate a precise answer.
+2
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
Prompt-sistq[<div><img alt="logo" src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Prompt]
style Prompt-sistq stroke:#a170ff
ChatInput-s9apd[<div><img alt="logo" src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Entrada de Usuario]
style ChatInput-s9apd stroke:#a170ff
Prompt-3ogxb[<div><img alt="logo" src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Prompt]
style Prompt-3ogxb stroke:#a170ff
OpenAIModel-kp0l0[<div><img alt="logo" src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>Analizador de Intención]
style OpenAIModel-kp0l0 stroke:#a170ff
OpenAIModel-712yx[<div><img alt="logo" src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>Generador de Respuesta]
style OpenAIModel-712yx stroke:#a170ff
Prompt-3y0vr[<div><img alt="logo" src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Constructor de Respuesta Final]
style Prompt-3y0vr stroke:#a170ff
ChatOutput-up1u4[<div><img alt="logo" src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-up1u4 stroke:#a170ff
OpenAIModel-o282l[<div><img alt="logo" src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-o282l stroke:#a170ff
YFinanceToolComponent-zoqeh[<div><img alt="logo" src="/_astro/badge-euro.b_yZ5I36.svg" style="height: 20px !important;width: 20px !important"/></div>YFinance Tool]
style YFinanceToolComponent-zoqeh stroke:#a170ff
AdvancedAgent-n79by[Agent]
style AdvancedAgent-n79by stroke:#a170ff
OpenAIModel-712yx -.- ChatOutput-up1u4
linkStyle 0 stroke:#a170ff
Prompt-3y0vr -.- OpenAIModel-712yx
linkStyle 1 stroke:#a170ff
Prompt-sistq -.- OpenAIModel-kp0l0
linkStyle 2 stroke:#a170ff
ChatInput-s9apd -.- Prompt-sistq
linkStyle 3 stroke:#a170ff
ChatInput-s9apd -.- Prompt-3y0vr
linkStyle 4 stroke:#a170ff
OpenAIModel-kp0l0 -.- Prompt-3ogxb
linkStyle 5 stroke:#a170ff
AdvancedAgent-n79by -.- Prompt-3y0vr
linkStyle 6 stroke:#a170ff
Prompt-3ogxb -.- AdvancedAgent-n79by
linkStyle 7 stroke:#a170ff
YFinanceToolComponent-zoqeh -.- AdvancedAgent-n79by
linkStyle 8 stroke:#a170ff
OpenAIModel-o282l -.- AdvancedAgent-n79by
linkStyle 9 stroke:#a170ff
Stock Queries Workflow Documentation
🧩 Overview
This workflow automates the process of answering user queries about financial markets. A user submits a question, the system extracts relevant ticker symbols, retrieves up‑to‑date market data via Yahoo Finance, and synthesises a concise, data‑driven response.
⚙️ Main Features
- User‑friendly chat input that captures natural language questions.
- Automatic ticker extraction using a language model prompt.
- Tool‑enabled agent that queries Yahoo Finance for the required data.
- Two‑stage reasoning: the agent first gathers data, then generates the final answer.
- Seamless integration of prompts, models, tools, and output display.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Chat Input | Receives the user’s natural‑language question. | User message | Text message |
| Prompt (Ticker Extraction) | Forms a prompt that asks the LLM to list tickers mentioned in the user’s message. | User message | Prompt message |
| OpenAI Model | Generates a list of ticker symbols from the prompt. | Prompt message | Text list of tickers |
| Prompt (Agent Instruction) | Creates a detailed instruction prompt for the agent, embedding the extracted ticker list. | List of tickers | Prompt message |
| Advanced Agent | Processes the instruction, decides which tool to invoke, and compiles the raw data into a structured format. | Prompt message | Structured ticker data |
| YFinance Tool | Retrieves current market information for the specified ticker(s) using Yahoo Finance. | Ticker symbol(s) | Financial data (price, news, etc.) |
| Prompt (Final Response) | Builds a prompt that asks the LLM to produce a user‑friendly answer based on the retrieved data and the original question. | Financial data, original user message | Prompt message |
| OpenAI Model | Generates the final, polished answer to the user. | Prompt message | Text answer |
| Chat Output | Sends the answer back to the user in the chat interface. | Text answer | Displayed chat message |
🧠 Notes
- The workflow relies on an OpenAI API key for all language model calls; ensure the key is kept secure.
- Yahoo Finance data retrieval requires network access and may be subject to rate limits or temporary outages.
- The agent’s decision logic can be overridden by changing the Agent Description or by adding additional tools.
- The system can be extended with fallback models or additional data sources if the primary OpenAI model fails or if higher‑frequency data is required.
- All components are stateless except the agent, which maintains short‑term memory for multi‑turn interactions.
- The prompt templates are designed to be concise and avoid excessive token usage, improving response latency.