@dshtrading/connector-stooq 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const name = "dsh-trading-us-connector-stooq";
11
11
  interface Config {
12
12
  /** 交易安全闸门(铁律 #3):true 时下单类工具强制 dry-run。 */
13
13
  dryRun: boolean;
14
- /** 实盘总闸门:默认 false;false 时无论 dryRun 与否都拒绝实盘下单 [S4]。 */
14
+ /** 实盘镜像:默认 false。它是非权威镜像——只能收紧、永不能授予;实盘授权由 @dshtrading/authority 的人工签署平面裁定 [S4]。 */
15
15
  liveTrading: boolean;
16
16
  }
17
17
  declare const Config: Schema<Config>;
@@ -68,7 +68,7 @@ declare function buildDryRunReceipt(args: PlaceOrderArgs, marketData: Pick<Marke
68
68
  interface PlaceOrderToolDeps {
69
69
  /** 行情服务(dry-run 回执的市价参照),按接口取用,不直连 HTTP。 */
70
70
  readonly marketData: Pick<MarketDataService, 'getTicker'>;
71
- /** 插件配置(dryRun 强制模拟 / liveTrading 总闸门)。 */
71
+ /** 插件配置(dryRun 强制模拟 / liveTrading 非权威镜像——实盘授权由 @dshtrading/authority 的人工签署平面裁定)。 */
72
72
  readonly config: Config;
73
73
  }
74
74
  /**
package/lib/index.js CHANGED
@@ -1,9 +1,27 @@
1
1
  import { INTERVAL_VOCABULARY, StooqRestClient, TradingServiceError, easternWallTimeToEpochMs, isSupportedInterval, normalizeStooqSymbol } from "./rest.js";
2
+ import { liveTradingEnabled } from "@dshtrading/authority";
2
3
  import { Service } from "@deepseek-ai/cordis";
3
4
  import { defineTool } from "@deepseek-ai/dsh-tools";
4
5
  import Schema from "@deepseek-ai/schemastery";
5
6
  //#region src/index.ts
6
7
  /**
8
+ * Stooq 连接器插件(dsh-trading us 切片):真实 MarketDataService。
9
+ *
10
+ * 能力三角色(与 connector-binance 同构):
11
+ * - 声明:ctx 键 `tradingUsMarketData` 由 @dshtrading/api 的模块增强统一声明;
12
+ * - provide:StooqMarketDataService(Service 基类,随插件 fiber 自动注销);
13
+ * - inject:工具经 ctx.inject 等待服务就绪后注册,一律经服务执行,不直连 HTTP。
14
+ *
15
+ * 下单三段闸门语义照抄 crypto 切片(README 铁律 #3 / S4 修订):工具名 `us_place_order`
16
+ * 落在 base 闸门模式 `/^(?:crypto|us|cn|hk)_(?:place|cancel)_order$/`;审批不在工具内做。
17
+ * Stooq 本身无交易 API——live 路径恒为 TRADING_NOT_IMPLEMENTED(券商 API 是后续任务)。
18
+ *
19
+ * 合规(README 铁律 #5):Stooq 免费公开 CSV 端点、无 key、本仓不缓存不再分发;
20
+ * 个人/非商业使用边界以 stooq.com 条款为准(详见 src/rest.ts 头注与 README 数据源节)。
21
+ *
22
+ * @module @dshtrading/connector-stooq
23
+ */
24
+ /**
7
25
  * Cordis 插件名 = patch 行 id(TEMPLATES §8):`dsh-trading-us-*` 市场命名空间,
8
26
  * 全仓唯一(insert-only 铁律 #1)。
9
27
  */
@@ -42,10 +60,10 @@ var StooqMarketDataService = class extends Service {
42
60
  };
43
61
  function evaluateOrderGate(config, args) {
44
62
  const requestedDryRun = args.dryRun ?? true;
45
- if (!requestedDryRun && !config.liveTrading) return {
63
+ if (!requestedDryRun && !liveTradingEnabled(config.liveTrading)) return {
46
64
  action: "reject",
47
65
  code: "TRADING_LIVE_TRADING_DISABLED",
48
- message: `us_place_order rejected: the call requests real execution (dryRun=${String(args.dryRun)}) but live trading is disabled (liveTrading=false). Ask the user to enable liveTrading explicitly after confirmation, or keep dryRun=true for a simulated fill.`
66
+ message: `us_place_order rejected: the call requests real execution (dryRun=${String(args.dryRun)}) but live trading is disabled (no signed live-trading grant from the authority plane). Ask the operator to sign a live-trading grant (packages/authority/bin/sign-live-trading.mjs) after confirmation, or keep dryRun=true for a simulated fill.`
49
67
  };
50
68
  if (requestedDryRun || config.dryRun) return { action: "simulate" };
51
69
  return { action: "live" };
@@ -111,7 +129,7 @@ async function buildDryRunReceipt(args, marketData) {
111
129
  function createPlaceOrderTool(deps) {
112
130
  return defineTool({
113
131
  name: "us_place_order",
114
- description: "Place a US stock order, or simulate one. dryRun defaults to true and returns a DRY-RUN simulated fill receipt referencing the latest Stooq daily close. Real execution (dryRun=false) requires the plugin liveTrading switch plus user approval, and is not implemented yet in this slice (Stooq has no trading API).",
132
+ description: "Place a US stock order, or simulate one. dryRun defaults to true and returns a DRY-RUN simulated fill receipt referencing the latest Stooq daily close. Real execution (dryRun=false) requires a signed live-trading grant (see @dshtrading/authority) plus user approval, and is not implemented yet in this slice (Stooq has no trading API).",
115
133
  parameters: {
116
134
  symbol: {
117
135
  type: "string",
@@ -141,7 +159,7 @@ function createPlaceOrderTool(deps) {
141
159
  },
142
160
  dryRun: {
143
161
  type: "boolean",
144
- description: "true (default) = simulate only and return a DRY-RUN receipt; false = request real execution (gated by liveTrading and user approval)",
162
+ description: "true (default) = simulate only and return a DRY-RUN receipt; false = request real execution (gated by the signed live-trading authority and user approval)",
145
163
  default: true
146
164
  }
147
165
  },
@@ -172,7 +190,7 @@ function apply(ctx, config) {
172
190
  const marketData = ctx.tradingUsMarketData;
173
191
  ctx.tools.register(defineTool({
174
192
  name: "us_get_ticker",
175
- description: "Get the latest market snapshot for a US stock via the Stooq public CSV endpoint. NOTE: the original Stooq quote endpoint is gone, so this returns the latest DAILY close (price, volume, close time) — it does not reflect intraday or pre/post-market moves. No credentials required; personal/non-commercial use per stooq.com terms.",
193
+ description: "Get the latest market snapshot for a US stock via Stooq. The original Stooq quote endpoint is gone, so this returns the latest DAILY close (price, volume, close time) and does not reflect intraday or pre/post-market moves. No credentials required; personal/non-commercial use per stooq.com terms.",
176
194
  parameters: { symbol: {
177
195
  type: "string",
178
196
  required: true,
@@ -192,7 +210,7 @@ function apply(ctx, config) {
192
210
  }));
193
211
  ctx.tools.register(defineTool({
194
212
  name: "us_get_klines",
195
- description: "Get recent OHLCV candles for a US stock via the Stooq public CSV endpoint. Supported intervals: 1/5/15/30 minute (intraday availability depends on Stooq policy), 1h, 1d, 1w, 1M. No credentials required; personal/non-commercial use per stooq.com terms.",
213
+ description: "Get recent OHLCV candles for a US stock via Stooq. Supported intervals: 1/5/15/30 minute (intraday availability depends on Stooq policy), 1h, 1d, 1w, 1M. No credentials required; personal/non-commercial use per stooq.com terms.",
196
214
  parameters: {
197
215
  symbol: {
198
216
  type: "string",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dshtrading/connector-stooq",
3
3
  "description": "US market connector plugin for dsh-trading: public market data from Stooq CSV endpoints implementing the @dshtrading/api contracts (no key; personal/non-commercial use per stooq.com terms)",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "./lib/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  ],
18
18
  "license": "PolyForm-Noncommercial-1.0.0",
19
19
  "dependencies": {
20
- "@dshtrading/api": "^0.5.0"
20
+ "@dshtrading/api": "^0.6.1",
21
+ "@dshtrading/authority": "^0.6.1"
21
22
  },
22
23
  "peerDependencies": {
23
24
  "@deepseek-ai/cordis": ">=4.0.0",