Best for one-off questions适合单次查询
Fetch a quote when a user asks, attach its timestamp, and return a bounded payload. This is the simplest path for assistants and research workflows.用户提问时获取一条行情,附上时间戳并返回有限字段。这是对话助手和研究流程最简单的方式。
Give Doubao a narrow quote tool—not a vague promise of “live data.” Your application fetches the quote, verifies its source and timestamp, then lets the model explain the result.不要笼统地承诺“实时数据”,而应给豆包一个边界清晰的行情工具:由应用获取报价、核验来源与时间戳,再交给模型解释。
Before writing code, define what your application means by “real time.” The answer depends on the venue, feed entitlement, account, endpoint, and session—not on the model name.写代码前先定义应用中的“实时”究竟指什么。答案取决于交易场所、Feed 权限、账户、端点与交易时段,而不是模型名称。
Start with a small contract such as
get_stock_quote. Accept a symbol and optional
venue. Do not combine quote retrieval, portfolio access, and
trade placement in one tool.从
get_stock_quote
这样的最小契约开始,接收股票代码与可选交易场所。不要把行情查询、持仓访问和交易执行塞进同一个工具。
Use the current Volcano Ark SDK or Chat Completions documentation for your deployed model and region. The model may propose a tool call; it does not execute your provider request or gain access to your secret.按照当前部署模型与地域对应的火山方舟 SDK 或 Chat Completions 文档发起请求。模型可以提出工具调用,但不会替你请求数据源,也不应接触数据源密钥。
Check the current Volcano Ark model-service documentation查看最新火山方舟模型服务文档
Allowlist symbol syntax, resolve ambiguous tickers, apply timeouts, and call the provider with a server-side credential. Keep last trade, bid, ask, and previous close separate; they are not interchangeable.限制股票代码格式、消除同名代码歧义、设置超时,并使用服务端凭据调用数据源。最新成交价、买价、卖价和前收盘价含义不同,不能混为一谈。
Send the normalized tool result back to Doubao for explanation. Use ISO 8601 timestamps with offsets, preserve the provider name, and include a machine-readable freshness state.把标准化后的工具结果发回豆包生成解释。时间使用带时区偏移的 ISO 8601 格式,保留数据源名称,并加入机器可读的新鲜度状态。
This is a schema example, not a live quote.以上仅为 Schema 示例,不是实时行情。
Calculate age in code, not in free-form model reasoning. If the quote is older than your use-case threshold—or the feed entitlement is unknown—label it clearly or stop the response. Never silently substitute the previous close.数据年龄应由代码计算,而不是交给模型自由判断。若行情超过业务阈值,或 Feed 权限未知,就明确标记或终止回答;绝不能悄悄用前收盘价冒充当前价格。
Fetch a quote when a user asks, attach its timestamp, and return a bounded payload. This is the simplest path for assistants and research workflows.用户提问时获取一条行情,附上时间戳并返回有限字段。这是对话助手和研究流程最简单的方式。
Consume the stream outside Doubao. Deduplicate, aggregate, and trigger the model only for a meaningful event or requested snapshot.在豆包之外消费数据流,先去重、聚合,再仅针对有意义的事件或用户请求触发模型。
Cache briefly by symbol and venue, but expose cache age. A fast stale answer is still stale; the UI and model response must say so.可按股票代码和交易场所短暂缓存,但必须暴露缓存年龄。过期答案即使返回很快,仍然是过期答案。
Ask Doubao to present facts in a stable order. This reduces the chance that a fluent explanation hides missing market context.要求豆包按固定顺序呈现事实,避免流畅的自然语言掩盖缺失的市场上下文。
| Field字段 | Why it matters作用 | Failure behavior异常处理 |
|---|---|---|
| Symbol + exchange | Disambiguates listings区分同名或跨市场标的 | Ask the user to choose请用户确认 |
| Price type | Separates last, bid, ask, close区分成交、买卖价与收盘价 | Never infer silently不得静默推断 |
| Provider timestamp | Measures event freshness衡量行情事件新鲜度 | Do not call it real time不得称为实时 |
| Market session | Explains inactive prices解释价格为何未变化 | State closed/unknown标明休市或未知 |
| Source + delay | Supports attribution and entitlement支持归因与权限核验 | Label entitlement unknown标明权限未知 |
Do not treat the model as a market-data feed. Give it a current quote from an authorized external provider and include the source, exchange, market session, delay status, and provider timestamp.不要把模型当作行情 Feed。应从获得授权的外部数据源取得当前报价,并附上来源、交易所、交易时段、延迟状态与数据源时间戳。
At minimum, return the normalized symbol, exchange, currency, price, provider timestamp, retrieval timestamp, market session, delay status, and source. Bid, ask, and last trade should remain distinct fields.至少应返回标准化股票代码、交易所、币种、价格、数据源时间戳、获取时间、交易时段、延迟状态与来源。买价、卖价和最新成交价应保持为不同字段。
No. Ingest and aggregate the stream in application code, then send a bounded snapshot or event summary to the model when needed.不需要。应在应用代码中接收并聚合数据流,只在需要时向模型发送有限的快照或事件摘要。
Keep market-data retrieval read-only. Trading should use a separate, strongly authenticated action path with deterministic risk checks, idempotency, audit logs, and explicit confirmation.行情查询应保持只读。交易需使用独立且强认证的操作路径,并配置确定性风控、幂等机制、审计日志和明确确认。
Test one symbol, inspect the selected capability and response fields, then add broader coverage only after the freshness contract passes.先测试一个股票代码,检查所选能力和返回字段;新鲜度契约通过后,再扩展覆盖范围。
Doubao can explain a normalized result, but the provider determines which markets, sessions, instruments, and delivery rights are available. Build the shortlist from the questions users need answered—not from a generic stock API ranking.豆包可以解释标准化后的结果,但市场覆盖、交易时段、品种与数据使用权仍由服务商决定。候选清单应从用户真正需要回答的问题出发,而不是照搬通用股票 API 排名。
| Decision决策项 | Verify需要核验 | Effect on Doubao对豆包回答的影响 |
|---|---|---|
| Market coverage市场覆盖 | Venue, instrument type, symbol mapping交易场所、品种、代码映射 | Prevents answers about unsupported listings避免回答未覆盖标的 |
| Feed tierFeed 层级 | Real-time, delayed, indicative, consolidated or venue-specific实时、延迟、指示性、综合或单一场所 | Determines the label beside the price决定价格旁的标签 |
| Session coverage时段覆盖 | Pre-market, regular, after-hours, auctions盘前、正常交易、盘后与集合竞价 | Explains what the latest value represents解释最新值对应的市场事件 |
| Usage rights使用权利 | Internal use, display, redistribution, retention内部使用、展示、再分发与留存 | Controls whether an answer may be shown or stored决定回答能否展示或存储 |
| Operating limits运行限制 | Rate limits, concurrency, reconnect and backfill速率、并发、重连与补数机制 | Shapes caching, retries, and errors决定缓存、重试与错误处理 |
A correct tool schema is only the start. Production needs deterministic behavior when markets close, symbols collide, providers throttle requests, or a fallback feed takes over.正确的工具 Schema 只是起点。遇到休市、代码冲突、服务商限流或备用 Feed 接管时,生产系统必须具有确定性行为。
Store event time unambiguously and retain the venue time zone. Determine session state from an exchange calendar, not the server clock alone. Holidays, half-days, daylight-saving changes, halts, and auctions can make a recent timestamp misleading.行情时间应使用无歧义格式,并保留交易场所时区。交易状态要依据交易所日历判断,不能只看服务器时间。节假日、半日市、夏令时切换、停牌和集合竞价都会让近期时间戳产生误导。
Key caches by symbol, venue, field set, and session. Coalesce
concurrent requests, but return cache_age_ms and
the original provider time. Never refresh the event timestamp
when reading cache.缓存键应包含股票代码、交易场所、字段集和交易时段。相同行情的并发请求可以合并,但必须返回
cache_age_ms
与原始数据源时间;读取缓存时不得刷新行情时间戳。
Set a provider deadline shorter than the total response budget. Retry only transient failures, add jitter, and stop retry storms with a circuit breaker. Expose any fallback substitution and recompute the delay label.数据源调用的截止时间应短于整体响应预算。只重试临时故障,加入随机抖动,并用熔断机制阻止重试风暴。切换备用源时应公开替换事实并重新计算延迟标签。
Log request ID, selected tool, validated arguments, provider status, event and retrieval times, cache age, model endpoint, and freshness decision. Redact credentials. Replay should reproduce the policy decision without a live provider call.日志应记录请求 ID、所选工具、已校验参数、数据源状态、事件与获取时间、缓存年龄、模型接入点和新鲜度结论,同时移除密钥。回放应能在不请求实时数据源的情况下复现策略判断。
Test with fixed fixtures before live credentials, then run a small shadow evaluation. Prove tool selection, field fidelity, freshness labeling, and bounded failure—not investment quality.先用固定样例测试,再接入真实凭据做小规模影子评估。目标是验证工具选择、字段保真度、新鲜度标签和受控失败,而不是评判投资结论。
| Phase阶段 | Test测试内容 | Pass evidence通过证据 |
|---|---|---|
| Contract契约 | Valid, invalid, ambiguous symbols有效、无效与歧义代码 | Validated arguments or clarification参数通过校验或触发澄清 |
| Fixtures固定样例 | Open, closed, delayed, stale, halted开市、休市、延迟、过期与停牌 | Every state gets the expected label每种状态均得到预期标签 |
| Integration集成 | Doubao tool-call round trip豆包工具调用往返 | Normalized result and sourced answer标准化结果与带来源回答 |
| Resilience韧性 | Timeout, throttle, malformed payload, fallback超时、限流、异常载荷与备用源 | Bounded error without invented price受控报错且不编造价格 |
| Security安全 | Prompt injection and secret requests提示词注入与密钥索取 | No credential or write scope exposed不暴露凭据或写权限 |
Inspect a matching capability, test the normalized output, and promote it only after stale, closed-market, and provider-failure cases behave correctly.检查匹配能力、测试标准化输出,并在过期、休市与数据源故障场景均表现正确后再上线。