@dshtrading/connector-yahoo 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 +2 -2
- package/lib/index.js +21 -3
- package/package.json +3 -2
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const name = "dsh-trading-us-connector-yahoo";
|
|
|
11
11
|
interface Config {
|
|
12
12
|
/** 交易安全闸门(铁律 #3):true 时下单类工具强制 dry-run。 */
|
|
13
13
|
dryRun: boolean;
|
|
14
|
-
/**
|
|
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, TradingServiceError, YahooRestClient, isSupportedInterval, normalizeYahooSymbol, parseChartBars } 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
|
+
* Yahoo Finance 连接器插件(dsh-trading us 切片,任务 G 数据面切换)。
|
|
9
|
+
*
|
|
10
|
+
* 能力三角色(与 connector-stooq/binance 同构):
|
|
11
|
+
* - 声明:ctx 键 `tradingUsMarketData` 由 @dshtrading/api 的模块增强统一声明;
|
|
12
|
+
* - provide:YahooMarketDataService(Service 基类,随插件 fiber 自动注销);
|
|
13
|
+
* - inject:工具经 ctx.inject 等待服务就绪后注册,一律经服务执行,不直连 HTTP。
|
|
14
|
+
*
|
|
15
|
+
* 下单三段闸门语义照抄 crypto/us 切片(README 铁律 #3 / S4 修订):工具名 `us_place_order`
|
|
16
|
+
* 落在 base 闸门模式 `/^(?:crypto|us|cn|hk)_(?:place|cancel)_order$/`;审批不在工具内做。
|
|
17
|
+
* Yahoo 本身无交易 API——live 路径恒为 TRADING_NOT_IMPLEMENTED(券商 API 是后续任务)。
|
|
18
|
+
*
|
|
19
|
+
* 合规(README 铁律 #5):Yahoo Finance 非官方 API,个人使用属灰色但被普遍使用的边界;
|
|
20
|
+
* 无 key、本仓不缓存不再分发(详见 README 数据源节与 src/rest.ts 头注)。
|
|
21
|
+
*
|
|
22
|
+
* @module @dshtrading/connector-yahoo
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
7
25
|
* Cordis 插件名 = patch 行 id(TEMPLATES §8):`dsh-trading-us-*` 市场命名空间,
|
|
8
26
|
* 全仓唯一(insert-only 铁律 #1)。
|
|
9
27
|
*/
|
|
@@ -42,10 +60,10 @@ var YahooMarketDataService = 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 (
|
|
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" };
|
|
@@ -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
|
|
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
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/connector-yahoo",
|
|
3
3
|
"description": "US market connector plugin for dsh-trading: public market data from the Yahoo Finance v8 chart API implementing the @dshtrading/api contracts (unofficial API, no key; personal use per Yahoo terms of use)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dshtrading/
|
|
24
|
+
"@dshtrading/authority": "^0.6.1",
|
|
25
|
+
"@dshtrading/api": "^0.6.1"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@deepseek-ai/cordis": ">=4.0.0",
|