QVeris
Freshness-first implementation以数据新鲜度为核心的实现

How to Add Real-Time Stock Market Data to Doubao如何为豆包接入实时股票市场数据

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.不要笼统地承诺“实时数据”,而应给豆包一个边界清晰的行情工具:由应用获取报价、核验来源与时间戳,再交给模型解释。

Short answer: connect a Doubao model endpoint on Volcano Ark to an external market-data function. Keep execution in your backend, return freshness metadata with every price, and refuse to present stale or entitlement-unknown data as real time.简要答案:通过火山方舟调用豆包模型,并把外部行情函数作为工具接入。实际请求由后端执行;每个价格都要附带新鲜度信息;来源不明或已过期的数据不能标成“实时”。
Market data passing through freshness and permission checks before reaching a Doubao assistant
The model receives a validated snapshot; the data pipeline owns collection, timing, and access control.模型接收经过校验的行情快照;采集、时效与访问控制由数据管道负责。
The freshness contract新鲜度契约

A price without context is not a reliable quote没有上下文的价格,不是可信行情

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 权限、账户、端点与交易时段,而不是模型名称。

SOURCENamed provider and feed明确的数据源与 Feed
EVENT TIMEWhen the quote occurred行情事件发生时间
SESSIONRegular, pre, post, or closed正常、盘前、盘后或休市
DELAYReal-time, delayed, or unknown实时、延迟或未知

Define one read-only quote function定义一个只读行情函数

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 这样的最小契约开始,接收股票代码与可选交易场所。不要把行情查询、持仓访问和交易执行塞进同一个工具。

{ "name": "get_stock_quote", "parameters": { "type": "object", "properties": { "symbol": {"type": "string"}, "venue": {"type": "string"} }, "required": ["symbol"] } }

Send the tool definition with the Doubao request随豆包请求发送工具定义

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查看最新火山方舟模型服务文档

Validate, fetch, and normalize in application code在应用代码中校验、请求并标准化

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.限制股票代码格式、消除同名代码歧义、设置超时,并使用服务端凭据调用数据源。最新成交价、买价、卖价和前收盘价含义不同,不能混为一谈。

Return an evidence-rich result返回带证据的结果

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 格式,保留数据源名称,并加入机器可读的新鲜度状态。

{ "symbol": "EXAMPLE", "exchange": "XNAS", "currency": "USD", "last": null, "provider_timestamp": "2026-08-12T09:31:04-04:00", "retrieved_at": "2026-08-12T09:31:05-04:00", "session": "regular", "delay_status": "unknown", "source": "YOUR_PROVIDER" }

This is a schema example, not a live quote.以上仅为 Schema 示例,不是实时行情。

Apply a deterministic stale-data rule用确定性规则判断数据是否过期

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 权限未知,就明确标记或终止回答;绝不能悄悄用前收盘价冒充当前价格。

Choose the transport选择传输方式

Use snapshots for questions, streams for your application问答用快照,数据流留在应用侧

REST SNAPSHOT

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.用户提问时获取一条行情,附上时间戳并返回有限字段。这是对话助手和研究流程最简单的方式。

WEBSOCKET

Best for alerts and live views适合预警与实时看板

Consume the stream outside Doubao. Deduplicate, aggregate, and trigger the model only for a meaningful event or requested snapshot.在豆包之外消费数据流,先去重、聚合,再仅针对有意义的事件或用户请求触发模型。

CACHED SNAPSHOT

Best when latency and cost matter适合关注延迟与成本的场景

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.可按股票代码和交易场所短暂缓存,但必须暴露缓存年龄。过期答案即使返回很快,仍然是过期答案。

Output contract输出契约

Make every answer auditable at a glance让每个答案都能一眼核验

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标明权限未知
Keep retrieval separate from trading.行情查询必须与交易执行分离。 A read-only quote tool is suitable for research. An order tool needs separate credentials, deterministic limits, idempotency, audit logging, and explicit human confirmation. This guide does not implement trading.只读行情工具适合研究;下单工具则需要独立凭据、确定性限额、幂等控制、审计日志和明确的人类确认。本指南不实现交易。
Acceptance test验收测试

Test the failure cases before the happy path先测试失败场景,再测试正常流程

Ambiguous ticker triggers a clarification股票代码有歧义时要求澄清
Closed market is identified correctly正确识别休市状态
Delayed feed is never labeled real time延迟 Feed 不会被称为实时
Missing timestamp blocks a current-price claim缺少时间戳时禁止声称当前价格
Provider timeout returns a bounded error数据源超时返回受控错误
Prompt injection cannot expose credentials提示词注入无法获取凭据
Bid, ask, and last remain distinct买价、卖价与成交价保持区分
No tool path can place an order任何只读工具路径都不能下单
FAQ

Real-time stock data for Doubao: common questions豆包实时股票数据常见问题

Does Doubao provide real-time stock prices by itself?豆包本身会提供实时股票价格吗?

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。应从获得授权的外部数据源取得当前报价,并附上来源、交易所、交易时段、延迟状态与数据源时间戳。

What should the stock quote tool return?股票行情工具应该返回哪些字段?

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.至少应返回标准化股票代码、交易所、币种、价格、数据源时间戳、获取时间、交易时段、延迟状态与来源。买价、卖价和最新成交价应保持为不同字段。

Should I stream every market tick into Doubao?需要把每个行情 Tick 都发送给豆包吗?

No. Ingest and aggregate the stream in application code, then send a bounded snapshot or event summary to the model when needed.不需要。应在应用代码中接收并聚合数据流,只在需要时向模型发送有限的快照或事件摘要。

Can the same tool place trades?同一个工具可以直接下单吗?

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.行情查询应保持只读。交易需使用独立且强认证的操作路径,并配置确定性风控、幂等机制、审计日志和明确确认。

Start with one quote从一条行情开始

Verify the timestamp before trusting the answer先核验时间戳,再相信答案

Test one symbol, inspect the selected capability and response fields, then add broader coverage only after the freshness contract passes.先测试一个股票代码,检查所选能力和返回字段;新鲜度契约通过后,再扩展覆盖范围。

Production deep dive生产级深入指南

Choose coverage and data rights before choosing an API先确定覆盖范围与数据权利,再选择 API

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决定缓存、重试与错误处理
Keep the provider behind an adapter.把服务商留在适配层之后。 Maintain a stable quote contract. For capabilities beyond market data, use the separate guide to APIs for Doubao; this page remains focused on current stock quotes.保持稳定的行情契约。如果需要行情之外的能力,可查看独立的豆包 API 选型指南;本页只聚焦当前股票行情。
Production operations生产运行

Control time, latency, cost, and failure outside the model在模型之外控制时间、延迟、成本与故障

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 接管时,生产系统必须具有确定性行为。

Time zones and calendars时区与交易日历

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.行情时间应使用无歧义格式,并保留交易场所时区。交易状态要依据交易所日历判断,不能只看服务器时间。节假日、半日市、夏令时切换、停牌和集合竞价都会让近期时间戳产生误导。

Caching and coalescing缓存与请求合并

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 与原始数据源时间;读取缓存时不得刷新行情时间戳。

Timeouts and circuit breakers超时与熔断

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.数据源调用的截止时间应短于整体响应预算。只重试临时故障,加入随机抖动,并用熔断机制阻止重试风暴。切换备用源时应公开替换事实并重新计算延迟标签。

Observability and replay可观测性与回放

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、所选工具、已校验参数、数据源状态、事件与获取时间、缓存年龄、模型接入点和新鲜度结论,同时移除密钥。回放应能在不请求实时数据源的情况下复现策略判断。

Release playbook上线流程

Validate the complete Doubao market-data loop验证完整的豆包行情数据闭环

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不暴露凭据或写权限
Glossary术语表

Terms that change what real time means影响实时含义的关键术语

Provider timestamp数据源时间戳
Time attached to the market event by the provider, not when your service received it.数据源为市场事件附加的时间,不等同于服务收到数据的时间。
Retrieval timestamp获取时间戳
Time the application received the result, used to measure transit and cache age.应用收到结果的时间,用于衡量传输延迟与缓存年龄。
Entitlement数据权限
The right to receive, display, retain, or redistribute a market-data feed.接收、展示、留存或再分发某类市场数据 Feed 的合同权利。
Market session交易时段
The pre-market, regular, after-hours, auction, halted, or closed phase.盘前、正常交易、盘后、集合竞价、停牌或休市阶段。
Last trade最新成交
The most recent reported transaction; it may differ from bid and ask.最近一笔已报告成交,可能与当前买价和卖价不同。
Staleness threshold过期阈值
A use-case rule deciding when a quote is labeled stale or rejected.按业务场景定义、用于决定行情何时应标记过期或被拒绝的规则。
Production next step生产实施下一步

Prove one timestamped quote end to end端到端验证一条带时间戳的行情

Inspect a matching capability, test the normalized output, and promote it only after stale, closed-market, and provider-failure cases behave correctly.检查匹配能力、测试标准化输出,并在过期、休市与数据源故障场景均表现正确后再上线。