Why Qoder needs a market-data tool layer
Qoder can reason about a codebase, edit files, run commands, and use external tools. But a coding agent does not inherently know the current price of a stock. Its general knowledge is not a live feed, and ordinary web results can be delayed, inconsistent, or stripped of exchange timestamps.
The dependable pattern is to give the agent a small set of typed functions such as get_quote, get_bars, and get_market_status. Those functions call a licensed provider, normalize the response, and return the timestamp, source, currency, and feed status alongside the values. Qoder receives just enough evidence to build, test, or debug the feature.
Qoder officially supports external services through MCP servers, including stdio, SSE, HTTP, and WebSocket transports. Its permission system can allow or ask for specific MCP tools, so a read-only data tool does not need broad shell or account access.
为什么 Qoder 需要市场数据工具层
Qoder 能理解代码库、修改文件、执行命令并调用外部工具,但编程智能体并不会天然知道某只股票的当前价格。模型知识不是实时数据源,而普通网页结果可能存在延迟、口径不一,甚至缺少交易所时间戳。
可靠做法是向智能体提供少量类型明确的函数,例如 get_quote、get_bars 与 get_market_status。这些函数调用具备授权的数据服务商,统一响应格式,并把时间戳、来源、币种和数据源状态与数值一并返回。Qoder 只接收完成开发、测试或调试所需的证据。
Qoder 官方支持通过 MCP 服务连接外部能力,包括 stdio、SSE、HTTP 与 WebSocket 传输。其权限系统可针对具体 MCP 工具设置允许或询问,因此只读数据工具无需获得广泛的终端或账户权限。
A production-shaped architecture
Separate the streaming pipeline from the agent interaction. A WebSocket consumer maintains the live state your application needs; an MCP endpoint exposes bounded snapshots and historical windows to Qoder. This prevents a long-lived firehose from flooding the context window while preserving freshness.
面向生产环境的架构
将持续行情流与智能体交互分开。WebSocket 消费端维护应用所需的实时状态;MCP 端点向 Qoder 提供受限快照与历史窗口。这样既能保持新鲜度,也不会让持续数据洪流挤满上下文窗口。
What the tool should return
A quote without context is an unsafe primitive. Return a structured envelope: symbol, bid, ask, last trade, exchange or feed, currency, provider timestamp, received timestamp, session state, delay classification, and an error field. For bars, state interval, adjustment policy, timezone, and whether the current bar is complete.
工具应返回什么
脱离上下文的价格并不可靠。建议返回结构化数据包:代码、买价、卖价、最新成交价、交易所或数据源、币种、服务商时间戳、接收时间、交易时段状态、延迟类型和错误字段。K 线还应注明周期、复权规则、时区以及当前 K 线是否结束。
Implementation workflow实施工作流
Define the question before choosing the feed
A portfolio dashboard may need minute bars; a spread monitor needs bid and ask; a market-open alert needs session status plus timestamps. Write the required symbols, venues, fields, freshness threshold, update rate, history depth, and whether the result will be displayed, stored, or redistributed.
先定义问题,再选择数据源
投资组合看板可能只需分钟 K 线;价差监控需要买卖报价;开盘提醒则需要交易时段状态与时间戳。先明确股票范围、交易场所、字段、新鲜度阈值、更新频率、历史深度,以及结果是否展示、存储或再分发。
Choose a provider and confirm entitlements
Compare exchange coverage, consolidated versus venue-specific feeds, delayed versus real-time access, WebSocket limits, historical depth, corporate-action adjustments, and display rights. For example, Alpaca documents its stock WebSocket feeds; its available feed and coverage depend on the subscription. Treat provider plan details as configuration, not timeless facts.
选择服务商并确认数据权限
比较交易所覆盖范围、全市场综合数据与单场所数据、延迟或实时权限、WebSocket 限制、历史深度、公司行为复权方式和展示权。例如,Alpaca 公开了股票 WebSocket 数据说明;实际可用数据源与覆盖范围取决于订阅。服务商套餐应视为可变配置,而非永久事实。
Wrap provider calls behind narrow MCP tools
Keep secrets in the MCP server environment. Validate symbols and time ranges, cap result size, normalize provider-specific fields, and add provenance. Qoder should request data by intent rather than construct arbitrary provider URLs.
用范围明确的 MCP 工具封装服务商调用
密钥保留在 MCP 服务环境中。对股票代码与时间区间进行校验,限制返回量,统一服务商字段并附加来源信息。Qoder 应按意图请求数据,而不是自行拼接任意服务商 URL。
// .mcp.json
{
"mcpServers": {
"market-data": {
"type": "stdio",
"command": "node",
"args": ["./tools/market-data-server.js"],
"env": { "MARKET_DATA_KEY": "${MARKET_DATA_KEY}" }
}
}
}
Register, reload, and constrain permissions
Qoder CLI supports project-level
.mcp.json configuration. After a change, start
a new session or run /mcp reload. Allow only
the read functions required for this use case; keep trading,
account mutation, and unrestricted network actions outside
the server.
注册、重载并约束权限
Qoder CLI 支持项目级
.mcp.json 配置。修改后启动新会话或运行
/mcp reload。只允许本场景需要的读取函数;交易、账户变更和不受限网络操作应排除在服务之外。
Prompt for evidence, not just a number
Ask Qoder to use the market-data tool, state the returned timestamp and feed, reject stale results, and separate observed values from calculations. A useful task reads: “Fetch the latest quote and five one-minute bars for AAPL. Fail if the newest observation is older than 90 seconds during regular market hours. Add a typed adapter and tests; do not place orders.”
要求证据,而不只是一个数字
要求 Qoder 使用市场数据工具,注明返回时间戳与数据源,拒绝过期结果,并把观测值与计算结果分开。一个有效任务可以是:“获取 AAPL 最新报价与最近五根一分钟 K 线。正常交易时段内,如果最新数据早于 90 秒则失败。添加类型化适配器和测试;不得下单。”
Test live, closed-market, and degraded states
Record fixtures for a live session, pre-market or after-hours, a holiday, an unknown symbol, a rate-limit response, a disconnected stream, and delayed data. Verify reconnect backoff, deduplication, ordering, timezone conversion, and visible stale-state labels.
测试实时、休市与降级状态
为盘中、盘前或盘后、节假日、未知股票、限流响应、数据流断开和延迟数据准备测试样例。验证重连退避、去重、排序、时区转换以及明显的过期状态提示。
Choose the feed by workload按工作负载选择数据源
| Need需求 | Preferred interface优先接口 | Watch closely重点关注 |
|---|---|---|
| Prompt-time quote or test fixture提示词中的报价或测试样例 | REST / MCP snapshot | Timestamp, delay, venue, cache TTL时间戳、延迟、场所、缓存 TTL |
| Live dashboard实时看板 | WebSocket + local state | Reconnects, backpressure, symbol limits重连、背压、股票数量限制 |
| Chart and indicator development图表与指标开发 | Historical bars + latest snapshot历史 K 线 + 最新快照 | Adjustments, missing bars, timezones复权、缺失 K 线、时区 |
| Alert prototype预警原型 | Stream consumer + rule engine流消费端 + 规则引擎 | Duplicate events, clock drift, delivery重复事件、时钟漂移、消息送达 |
Use QVeris provider discovery to inspect available data providers, then confirm coverage and terms in the selected provider’s official documentation. For implementation, browse QVeris tools for a precise read operation instead of granting a broad integration.
可先通过 QVeris 服务商目录检查可用数据源,再到所选服务商的官方文档确认覆盖范围与条款。实施时,可在 QVeris 工具目录中选择精确的读取操作,避免授予过宽的集成权限。
Controls that make “real time” trustworthy让“实时”可信的控制措施
Use two clocks使用两个时钟
Compare the provider event time with your gateway receipt time. A recent receipt can still contain an old market event.比较服务商事件时间与网关接收时间。刚收到的数据仍可能来自较早的市场事件。
Carry the feed identity保留数据源身份
Record provider, feed, venue, delayed status, and adjustment policy with every result.每次结果都记录服务商、数据源、交易场所、延迟状态与复权规则。
Keep it read-only保持只读
Market data and order execution should be different servers, credentials, and approval paths.市场数据与订单执行应使用不同的服务、凭据与审批路径。
Degrade explicitly明确展示降级
Show stale, delayed, closed, and disconnected states. Never silently present cached data as live.清楚展示过期、延迟、休市和断线状态,绝不把缓存数据静默标成实时。
Release checklist发布检查清单
- API keys are server-side and excluded from logs, prompts, and version control.API 密钥仅保留在服务端,不进入日志、提示词或版本控制。
- Every value has a source timestamp, receipt timestamp, currency, and session state.每个数值都包含来源时间、接收时间、币种与交易时段状态。
- Schema validation rejects missing fields, non-finite numbers, and reversed time windows.模式校验拒绝缺失字段、非有限数值与颠倒的时间窗口。
- Rate limits, reconnects, stale thresholds, and cache behavior are observable.限流、重连、过期阈值与缓存行为均可观测。
- Display and redistribution rights match the actual product behavior.展示与再分发权限与产品实际行为一致。
Three practical Qoder use patterns三种实用的 Qoder 应用模式
Build a live dashboard adapter
Ask Qoder to create a provider-independent interface, implement one adapter, and render explicit loading, stale, delayed, and disconnected states. Use recorded fixtures for deterministic tests and the live MCP tool only for an opt-in smoke test.
Debug a price discrepancy
Give Qoder two attributed snapshots and ask it to compare timestamp, venue, trade versus quote, adjustment rules, and session. This turns “the prices differ” into a reproducible data-quality investigation.
Prototype an alert without enabling trading
Stream events into a small rule engine, expose recent triggers through a read-only tool, and let Qoder build the notification path. Keep execution credentials absent. An alert can be tested safely without creating a route to place an order.
构建实时看板适配器
让 Qoder 创建与服务商无关的接口,实现一个数据适配器,并显式呈现加载、过期、延迟和断线状态。确定性测试使用录制样例,只有主动启用的冒烟测试才调用实时 MCP 工具。
排查价格不一致
向 Qoder 提供两个带来源的快照,让其比较时间戳、交易场所、成交价与报价、复权规则和交易时段。这样,“价格不一样”就能转化为可复现的数据质量调查。
在不启用交易的情况下构建预警原型
把行情事件流接入小型规则引擎,通过只读工具暴露近期触发记录,再由 Qoder 构建通知链路。不要提供交易凭据。这样可以安全测试预警,同时不产生下单路径。
Frequently asked questions常见问题
Can Qoder access real-time stock prices by itself?Qoder 能自行访问实时股票价格吗?
Not as an inherent model capability. Connect a licensed data source through a controlled integration such as an MCP server, and include timestamps and provenance in every response.这不是模型自带能力。应通过 MCP 服务等受控集成连接具备授权的数据源,并在每次响应中包含时间戳与来源信息。
Should the MCP tool expose a WebSocket stream directly?MCP 工具应该直接暴露 WebSocket 数据流吗?
Usually no. Let an application-side consumer maintain stream state and expose bounded snapshots to the agent. Direct streams can overwhelm context and complicate retries, ordering, and cancellation.通常不建议。应由应用侧消费者维护数据流状态,再向智能体暴露有限快照。直接传入数据流容易挤占上下文,并让重试、排序和取消更复杂。
What is the minimum useful quote schema?最小可用报价结构包含什么?
Symbol, bid, ask, last trade when available, currency, provider/feed, event timestamp, receipt timestamp, market-session state, delay classification, and a typed error status.至少包含股票代码、买价、卖价、可用时的最新成交价、币种、服务商/数据源、事件时间、接收时间、交易时段状态、延迟类型与类型化错误状态。
Can this workflow place trades?这套工作流可以下单吗?
This design is intentionally read-only. If execution is ever added, isolate it behind separate credentials, tools, permissions, confirmation, risk checks, and audit logs.本文设计有意保持只读。若未来加入交易执行,应使用独立凭据、工具、权限、确认流程、风控检查和审计日志进行隔离。
How do I test when the market is closed?休市时如何测试?
Use recorded, timestamped fixtures and simulate session states. Keep one opt-in live smoke test for connectivity, but do not make the core test suite depend on an open market.使用带时间戳的录制样例并模拟不同交易时段。可以保留一个主动启用的实时连通性冒烟测试,但核心测试套件不应依赖市场开盘。
Turn a live feed into a tool Qoder can use safely把实时行情变成 Qoder 可安全调用的工具
Start with one read-only operation, one symbol, and an explicit freshness rule. Validate the envelope before expanding coverage.从一个只读操作、一只股票和明确的新鲜度规则开始。先验证数据包,再逐步扩大覆盖范围。
