@dshtrading/kit-us 0.2.1 → 0.4.0

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.
@@ -30,6 +30,8 @@ description: 财经观点沉淀与知识库策展指南:基于 Content Insight
30
30
  - `medium`:核心逻辑有参考价值,但部分数据存在滞后或口误出入;
31
31
  - `low`:存在重大关键事实失准或关键数据无法核实。
32
32
 
33
+ > **分层说明(勿混用)**:卡片 `factCheck` 三桶是**素材级**核查记录(这条声称被核实到什么程度);结论级证据契约的 `supported` / `contradicted` / `mixed` / `insufficient` 四态是**结论级**判定(这条结论能否成立)。卡片字段不因四态改名;引用卡片时按证据契约归入 C/D 级线索,不得单独支撑 `supported` 结论。
34
+
33
35
  ---
34
36
 
35
37
  ## 3. 标准策展 SOP
@@ -1 +1,25 @@
1
- ../../../packages/kit-us/assets/skills/us-risk-checklist.md
1
+ ---
2
+ name: us-risk-checklist
3
+ description: 美股交易风控检查清单:开仓前逐项核对盘前盘后流动性、熔断与个股停牌、做空规则、T+1 与 PDT 日内限制、财报跳空风险。
4
+ ---
5
+
6
+ # 美股风控检查清单(us-risk-checklist)
7
+
8
+ 开仓前逐项核对,任何一项不过则不建仓:
9
+
10
+ **依据闸门(先过)**:每条开仓理由必须能指回锚点(工具名 + 参数 + 数值 + 数据时间 / 公告或章节 / facts 条目 / 知识卡 id + updatedAt)。只有 C/D/E 级来源、或写不出锚点的理由,按证据不足处理(insufficient),不得作为入场依据。
11
+
12
+ 1. **交易时段与流动性**:常规时段 9:30–16:00 ET。盘前 4:00–9:30 / 盘后 16:00–20:00 流动性薄、点差宽、报价不构成可成交承诺,限价单优先、禁用市价单扫单。注意:本插件行情来自 Stooq 日线收盘,**不反映盘前盘后价**,时段外引用价格须明确标注。
13
+ 2. **熔断与个股停牌**:大盘熔断以标普 500 较前收盘为准——跌 7%(L1)/13%(L2)暂停 15 分钟,跌 20%(L3)当日休市。个股有 LULD 波动暂停与财报/公告停牌;持仓期间挂单可能在暂停中无法成交,恢复后价格可能跳变。
14
+ 3. **做空规则**:开空前确认可融券(locate);难借券(HTB)有融券费与强平召回风险。Reg SHO 严格限制裸卖空;个股当日跌幅 ≥10% 触发 Rule 201 替代 uptick 限制。轧空(squeeze)下亏损无上限,空头仓位必须设强制止损位。
15
+ 4. **T+1 交收与 PDT**:美股已实行 T+1 交收。融资账户权益 < $25,000 时,滚动 5 个交易日内日内回转(day trade)不得超过 3 次(FINRA PDT),第 4 次触发 90 天限制;现金账户注意 Good Faith Violation(用未交收资金卖出再买入)。当日回转次数是硬约束,下单前先查计数。
16
+ 5. **仓位与跳空风险**:单笔风险 ≤ 账户权益既定百分比;美股存在隔夜跳空,止损单不能保证按止损价成交(gap 直接穿越),重仓隔夜必须缩减仓位。财报、拆分、分红除权、FOMC 等日历事件发生前核对是否持仓过夜。
17
+ 6. **基本面估值与新闻**:调用 `us_get_fundamentals` 核对市值、P/E、P/B、EPS 与 52 周区间;调用 `us_get_news` 核查近期财报、管理层动作或分析师调级;避免在估值极端偏离且临近财报发布时盲目追高。
18
+ 7. **订单类型与有效期**:限价单默认核对有效期(DAY/GTC);止损用 stop-limit 时评估穿透风险。暗池/场外成交可能使盘口显示深度失真,小市值股降低仓位上限。
19
+ 8. **对手侧情景**:价格反向运行到止损位后,是否接受该笔亏损并继续执行原计划(不允许临时加倍摊平);连续两笔止损即当日停手复盘。
20
+
21
+ 退出纪律:
22
+ - 达到目标位或止损位按计划执行;移动止损只朝有利方向。
23
+ - 财报前夜重新评估隔夜仓:跳空无法被日内止损保护,不确定就减仓。
24
+
25
+ > 本清单是方法论,不构成投资建议。行情与下单工具均为 dry-run 起步,实盘需显式开关与审批(dsh-trading 铁律 #3);行情数据来自 Stooq,个人/非商业使用边界以 stooq.com 条款为准。
@@ -584,6 +584,10 @@ declare module '@deepseek-ai/cordis' {
584
584
  tradingCnMarketData: MarketDataService;
585
585
  /** hk 市场行情服务(由腾讯连接器同包双实例提供,config.market 分流;cn+hk 切片 2026-08-31 补齐)。 */
586
586
  tradingHkMarketData: MarketDataService;
587
+ /** futures 市场行情服务(由同花顺期货连接器提供,issue #97;日K + 当日分时聚合)。 */
588
+ tradingFuturesMarketData: MarketDataService;
589
+ /** 全球品种行情(global 市场:大宗/外汇/海外指数;@dshtrading/connector-jin10 dataplane 行提供)。 */
590
+ tradingGlobalMarketData: MarketDataService;
587
591
  /**
588
592
  * crypto 市场交易服务(R3 2026-08-29 补齐,crypto 市场第一个真实 TradeService):
589
593
  * 由 connector-okx 实现(签名 demo/live 下单),与 connector-binance 经
@@ -614,6 +618,10 @@ declare module '@deepseek-ai/cordis' {
614
618
  * 各市场 Kit apply 时注册 aggregateNews 纯函数,GUI 行情桥按市场获取。
615
619
  */
616
620
  tradingNewsRegistry: TradingNewsRegistry;
621
+ /** 跨市场快讯源(@dshtrading/connector-jin10 提供;缺席 = 未安装快讯连接器)。 */
622
+ tradingFlashFeed: FlashFeedService;
623
+ /** 宏观/利率源(@dshtrading/connector-jin10 提供;缺席 = 未安装金十连接器)。 */
624
+ tradingMacroFeed: MacroFeedService;
617
625
  }
618
626
  }
619
627
  /**
@@ -689,6 +697,8 @@ interface NewsItem {
689
697
  readonly publishedAt: string;
690
698
  /** 关联标的代码(可选,格式随源不同)。 */
691
699
  readonly relatedCodes?: readonly string[];
700
+ /** 热度等级(可选;金十快讯网页版 火/热/沸/爆,其他源不填)。 */
701
+ readonly hot?: string;
692
702
  }
693
703
  /** 新闻聚合请求选项。 */
694
704
  interface AggregateNewsOptions {
@@ -700,6 +710,11 @@ interface AggregateNewsOptions {
700
710
  symbol?: string | undefined;
701
711
  /** CryptoPanic API token(仅 crypto 市场使用,可选)。 */
702
712
  cryptoPanicKey?: string | undefined;
713
+ /**
714
+ * 启用的新闻/公告源 id 列表(issue #96 源配置化;各 kit 的 NewsSource 词汇)。
715
+ * 缺省 = 该市场全部默认源;空数组 = 显式关闭(返回空结果)。
716
+ */
717
+ sources?: readonly string[] | undefined;
703
718
  }
704
719
  /** 新闻聚合结果。 */
705
720
  interface AggregateNewsResult {
@@ -710,6 +725,73 @@ interface AggregateNewsResult {
710
725
  }
711
726
  /** 新闻聚合器函数签名(各 Kit 导出的 aggregateNews 符合此形状)。 */
712
727
  type NewsAggregator = (options?: AggregateNewsOptions) => Promise<AggregateNewsResult>;
728
+ /**
729
+ * 跨市场快讯源契约(2026-09-13 金十接入):host 平面由快讯连接器 provide
730
+ * tradingFlashFeed,GUI 快讯面板(桥 /dshtrading/api/flash)与 agent 快讯工具
731
+ * 共用同一取数实现;服务缺席 = 未安装/未启用该数据源 → 消费方报
732
+ * TRADING_NOT_IMPLEMENTED,绝不把「没有数据源」伪装成「没有快讯」。
733
+ */
734
+ interface FlashFeedService {
735
+ /**
736
+ * 最新快讯流(cursor 翻页);条目只含元数据(标题/时间/链接)。
737
+ * `hot` 非空时按热度等级服务端过滤(金十网页版 火/热/沸/爆)。
738
+ */
739
+ listFlash(options?: {
740
+ cursor?: string | undefined;
741
+ limit?: number | undefined;
742
+ hot?: readonly string[] | undefined;
743
+ }): Promise<{
744
+ readonly items: readonly NewsItem[];
745
+ readonly nextCursor?: string | undefined;
746
+ readonly hasMore: boolean;
747
+ }>;
748
+ /** 关键词搜快讯(上游一次性返回、不支持翻页)。 */
749
+ searchFlash(keyword: string, limit?: number | undefined): Promise<readonly NewsItem[]>;
750
+ }
751
+ /**
752
+ * 宏观经济日历条目(金十当周经济数据,2026-09-15):数值均为上游快照原样字符串,
753
+ * `actual` 缺省 = 未公布。
754
+ */
755
+ interface MacroCalendarEntry {
756
+ /** ISO 8601 公布时间(东八区解释,同 NewsItem 口径)。 */
757
+ readonly publishedAt: string;
758
+ /** 重要度(上游 star,0–5)。 */
759
+ readonly star: number;
760
+ /** 地区(标题前缀推断,如 美国/日本/中国;未识别 = 空串)。 */
761
+ readonly region: string;
762
+ readonly title: string;
763
+ readonly previous?: string;
764
+ readonly consensus?: string;
765
+ readonly actual?: string;
766
+ readonly revised?: string;
767
+ /** 上游公布影响词(利多/利空/影响较小…;原样透传)。 */
768
+ readonly affect?: string;
769
+ }
770
+ /** 央行最新利率条目(金十网页版,2026-09-15)。 */
771
+ interface MacroRateEntry {
772
+ /** 地区(flag 名推断,如 美国/日本/中国;未识别 = 空串)。 */
773
+ readonly region: string;
774
+ readonly bankName: string;
775
+ /** 最新利率(上游原样字符串,如 "3.75"/"0")。 */
776
+ readonly rate: string;
777
+ /** 公布日(上游原样 YYYY-MM-DD)。 */
778
+ readonly publishedAt: string;
779
+ /** 所属指标名(如「美联储利率决定(上限)」;部分央行缺省)。 */
780
+ readonly indicatorName?: string;
781
+ }
782
+ /**
783
+ * 宏观/利率源契约(2026-09-15 金十接入):host 平面由金十连接器 provide
784
+ * tradingMacroFeed,GUI 宏观面板(桥 /dshtrading/api/macro/*)消费;服务缺席 =
785
+ * 未安装/未启用该数据源 → 消费方报 TRADING_NOT_IMPLEMENTED,绝不把「没有数据源」
786
+ * 伪装成「没有数据」。日历走官方 MCP(list_calendar),利率走网页版公开接口
787
+ * (spikes/impl-jin10-macro-rates/EVIDENCE.md)。
788
+ */
789
+ interface MacroFeedService {
790
+ /** 当周经济日历(周一~周日,北京时间;limit 截尾,缺省全周)。 */
791
+ listCalendar(limit?: number | undefined): Promise<readonly MacroCalendarEntry[]>;
792
+ /** 央行最新利率(全量,客户端按地区过滤)。 */
793
+ listRates(): Promise<readonly MacroRateEntry[]>;
794
+ }
713
795
  /** 新闻聚合器注册表契约(Issue #37,router 插件提供)。 */
714
796
  interface TradingNewsRegistry {
715
797
  register(market: string, aggregator: NewsAggregator): () => void;
@@ -717,4 +799,4 @@ interface TradingNewsRegistry {
717
799
  markets(): string[];
718
800
  }
719
801
  //#endregion
720
- export { AccountBalance, AggregateNewsOptions, AggregateNewsResult, AuctionSnapshot, BuybackItem, CompanyProfile, CryptoFundamentals, DerivativesData, DerivativesHistory, DerivativesPoint, Disposable, DividendItem, DragonTigerItem, FinancialCell, FinancialIndicatorRow, FinancialReportGroup, FinancialReportMatrix, ForecastSummary, FundamentalsPackage, HolderNumSummary, InsiderTradeItem, InstitutionalHoldingItem, Interval, Kline, LimitUpPoolItem, MainOperationSegment, MarketDataRegistration, MarketDataRegistry, MarketDataService, MarketRouterService, NewsAggregator, NewsItem, OperatingEfficiency, Order, OrderRequest, OrderSide, OrderStatus, OrderType, Orderbook, OrderbookLevel, Position, PositionSide, ResearchReportItem, ShareholderItem, SplitItem, StockFundamentals, Ticker, TradeFill, TradeRegistration, TradeRegistry, TradeService, TradeTick, TradingNewsRegistry };
802
+ export { AccountBalance, AggregateNewsOptions, AggregateNewsResult, AuctionSnapshot, BuybackItem, CompanyProfile, CryptoFundamentals, DerivativesData, DerivativesHistory, DerivativesPoint, Disposable, DividendItem, DragonTigerItem, FinancialCell, FinancialIndicatorRow, FinancialReportGroup, FinancialReportMatrix, FlashFeedService, ForecastSummary, FundamentalsPackage, HolderNumSummary, InsiderTradeItem, InstitutionalHoldingItem, Interval, Kline, LimitUpPoolItem, MacroCalendarEntry, MacroFeedService, MacroRateEntry, MainOperationSegment, MarketDataRegistration, MarketDataRegistry, MarketDataService, MarketRouterService, NewsAggregator, NewsItem, OperatingEfficiency, Order, OrderRequest, OrderSide, OrderStatus, OrderType, Orderbook, OrderbookLevel, Position, PositionSide, ResearchReportItem, ShareholderItem, SplitItem, StockFundamentals, Ticker, TradeFill, TradeRegistration, TradeRegistry, TradeService, TradeTick, TradingNewsRegistry };
package/lib/index.d.ts CHANGED
@@ -8,16 +8,18 @@ declare const provider: SkillProvider;
8
8
  interface Config {
9
9
  dryRun: boolean;
10
10
  liveTrading: boolean;
11
- /** 角色预设按需收窄技能面;缺省保持全量捆绑目录。 */
12
- skills?: string[];
11
+ /** 角色预设按需收窄技能面;字段缺席保持全量捆绑目录,显式空数组才表示不下发任何技能。 */
12
+ skills?: string[] | null;
13
13
  }
14
14
  declare const Config: Schema<Config>;
15
15
  declare const inject: string[];
16
16
  declare const name = "dsh-trading-us-kit";
17
17
  /** 白名单视图:未知名 fail-fast 不静默缩面;白名单外的 get 拒绝分发。 */
18
- declare function providerForSkills(allowed?: readonly string[]): SkillProvider;
18
+ declare function providerForSkills(allowed?: readonly string[] | null): SkillProvider;
19
19
  declare function apply(ctx: Context, config: Config): void;
20
- declare function createGetNewsTool(): import("@deepseek-ai/dsh-tools").ToolDefinition;
20
+ declare function createGetNewsTool(toolOptions?: {
21
+ getSources?: () => readonly string[] | undefined;
22
+ }): import("@deepseek-ai/dsh-tools").ToolDefinition;
21
23
  declare function createGetFundamentalsTool(options?: {
22
24
  fetch?: typeof globalThis.fetch;
23
25
  }): import("@deepseek-ai/dsh-tools").ToolDefinition;
package/lib/index.js CHANGED
@@ -115,7 +115,7 @@ const provider = {
115
115
  const Config = Schema.object({
116
116
  dryRun: Schema.boolean().default(true),
117
117
  liveTrading: Schema.boolean().default(false),
118
- skills: Schema.array(Schema.string())
118
+ skills: Schema.union([Schema.array(Schema.string()), Schema.const(null)]).default(null)
119
119
  });
120
120
  const inject = ["skills", "tools"];
121
121
  const name = "dsh-trading-us-kit";
@@ -136,7 +136,9 @@ function providerForSkills(allowed) {
136
136
  }
137
137
  function apply(ctx, config) {
138
138
  ctx.skills.registerProvider(() => providerForSkills(config.skills));
139
- const newsTool = createGetNewsTool();
139
+ const routerCtx = ctx;
140
+ const readNewsSources = () => (routerCtx.get?.("tradingMarketRouter", false))?.newsSources?.("us");
141
+ const newsTool = createGetNewsTool({ getSources: readNewsSources });
140
142
  const fundamentalsTool = createGetFundamentalsTool();
141
143
  const tools = ctx.tools;
142
144
  const registerOnce = (tool) => {
@@ -165,7 +167,7 @@ const DEFAULT_NEWS_LIMIT = 20;
165
167
  function renderNewsItem(item) {
166
168
  return `[${item.source}] ${item.publishedAt} ${item.title}\n ${item.url}`;
167
169
  }
168
- function createGetNewsTool() {
170
+ function createGetNewsTool(toolOptions = {}) {
169
171
  return defineTool({
170
172
  name: "us_get_news",
171
173
  description: "Get recent US stock market news from Yahoo Finance RSS and CNBC RSS feeds. Aggregates and sorts newest-first; each item carries source name, publish time and a link for traceability. Optionally filter by symbol (e.g. AAPL, TSLA, NVDA) and by a time window. Source failures are tolerated and reported instead of failing the whole call. No credentials required.",
@@ -197,7 +199,8 @@ function createGetNewsTool() {
197
199
  const options = {
198
200
  symbol: typeof args.symbol === "string" ? args.symbol : void 0,
199
201
  windowHours: typeof args.windowHours === "number" ? args.windowHours : void 0,
200
- limit: typeof args.limit === "number" ? args.limit : void 0
202
+ limit: typeof args.limit === "number" ? args.limit : void 0,
203
+ sources: toolOptions.getSources?.()
201
204
  };
202
205
  const { items, unavailable } = await aggregateNews(options);
203
206
  if (items.length === 0 && unavailable.length === 0) return "us_get_news: no news items found within the requested window.";
package/lib/news.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * 铁律 #5:输出只带元数据(来源名/标题/链接/发布时间),不取正文,不缓存,不再分发。
10
10
  * 每源独立容错:单源失败不炸整体,失败源在 `unavailable` 中注明,fail-soft。
11
11
  */
12
- type NewsSource = 'yahoo' | 'googlenews';
12
+ type NewsSource = 'yahoo' | 'googlenews' | 'sec-edgar';
13
13
  interface NewsItem {
14
14
  /** 来源名(铁律 #5 的来源标注)。 */
15
15
  source: string;
@@ -31,6 +31,8 @@ interface AggregateNewsOptions {
31
31
  now?: number | undefined;
32
32
  /** CryptoPanic API token(桥面透传,us 聚合器忽略;对齐 api 契约形状)。 */
33
33
  cryptoPanicKey?: string | undefined;
34
+ /** 启用源 id 列表(issue #96 源配置化);缺省 = 全部默认源,空数组 = 显式关闭。 */
35
+ sources?: readonly string[] | undefined;
34
36
  }
35
37
  interface AggregateNewsResult {
36
38
  items: NewsItem[];
package/lib/news.js CHANGED
@@ -144,8 +144,12 @@ async function aggregateNews(options = {}) {
144
144
  const windowMs = clampNumber(options.windowHours, DEFAULT_WINDOW_HOURS, 1, 168) * 36e5;
145
145
  const limit = clampNumber(options.limit, DEFAULT_LIMIT, 1, MAX_LIMIT);
146
146
  const topic = options.symbol?.trim() || DEFAULT_QUERY_TOPIC;
147
- const fetchers = [fetchYahooNews(fetchImpl, topic, limit), fetchGooglenews(fetchImpl, topic, limit)];
148
- if (options.symbol && options.symbol.trim()) fetchers.push(fetchSecEdgarAnnouncements(fetchImpl, options.symbol, limit));
147
+ const enabled = options.sources;
148
+ const isEnabled = (id) => enabled === void 0 || enabled.includes(id);
149
+ const fetchers = [];
150
+ if (isEnabled("yahoo")) fetchers.push(fetchYahooNews(fetchImpl, topic, limit));
151
+ if (isEnabled("googlenews")) fetchers.push(fetchGooglenews(fetchImpl, topic, limit));
152
+ if (options.symbol && options.symbol.trim() && isEnabled("sec-edgar")) fetchers.push(fetchSecEdgarAnnouncements(fetchImpl, options.symbol, limit));
149
153
  const results = await Promise.allSettled(fetchers);
150
154
  const items = [];
151
155
  const unavailable = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dshtrading/kit-us",
3
3
  "description": "US market toolkit plugin for dsh-trading: US risk checklist skill provider and US news / fundamentals tools; runs as a us-trader preset row (session-scoped)",
4
- "version": "0.2.1",
4
+ "version": "0.4.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "./lib/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  ],
19
19
  "license": "PolyForm-Noncommercial-1.0.0",
20
20
  "dependencies": {
21
- "@dshtrading/indicators": "0.2.1",
22
- "@dshtrading/knowledge": "0.2.1"
21
+ "@dshtrading/indicators": "0.4.0",
22
+ "@dshtrading/knowledge": "0.4.0"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@deepseek-ai/cordis": ">=4.0.0",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "tsdown": "^0.22.0",
32
32
  "vitest": "^3.0.0",
33
- "@dshtrading/api": "0.2.1"
33
+ "@dshtrading/api": "0.4.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsdown",