@dshtrading/kit-hk 0.2.0 → 0.3.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.
- package/lib/api/lib/index.d.ts +37 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.js +7 -4
- package/lib/news.d.ts +2 -0
- package/lib/news.js +6 -3
- package/package.json +6 -6
package/lib/api/lib/index.d.ts
CHANGED
|
@@ -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,8 @@ declare module '@deepseek-ai/cordis' {
|
|
|
614
618
|
* 各市场 Kit apply 时注册 aggregateNews 纯函数,GUI 行情桥按市场获取。
|
|
615
619
|
*/
|
|
616
620
|
tradingNewsRegistry: TradingNewsRegistry;
|
|
621
|
+
/** 跨市场快讯源(@dshtrading/connector-jin10 提供;缺席 = 未安装快讯连接器)。 */
|
|
622
|
+
tradingFlashFeed: FlashFeedService;
|
|
617
623
|
}
|
|
618
624
|
}
|
|
619
625
|
/**
|
|
@@ -689,6 +695,8 @@ interface NewsItem {
|
|
|
689
695
|
readonly publishedAt: string;
|
|
690
696
|
/** 关联标的代码(可选,格式随源不同)。 */
|
|
691
697
|
readonly relatedCodes?: readonly string[];
|
|
698
|
+
/** 热度等级(可选;金十快讯网页版 火/热/沸/爆,其他源不填)。 */
|
|
699
|
+
readonly hot?: string;
|
|
692
700
|
}
|
|
693
701
|
/** 新闻聚合请求选项。 */
|
|
694
702
|
interface AggregateNewsOptions {
|
|
@@ -700,6 +708,11 @@ interface AggregateNewsOptions {
|
|
|
700
708
|
symbol?: string | undefined;
|
|
701
709
|
/** CryptoPanic API token(仅 crypto 市场使用,可选)。 */
|
|
702
710
|
cryptoPanicKey?: string | undefined;
|
|
711
|
+
/**
|
|
712
|
+
* 启用的新闻/公告源 id 列表(issue #96 源配置化;各 kit 的 NewsSource 词汇)。
|
|
713
|
+
* 缺省 = 该市场全部默认源;空数组 = 显式关闭(返回空结果)。
|
|
714
|
+
*/
|
|
715
|
+
sources?: readonly string[] | undefined;
|
|
703
716
|
}
|
|
704
717
|
/** 新闻聚合结果。 */
|
|
705
718
|
interface AggregateNewsResult {
|
|
@@ -710,6 +723,29 @@ interface AggregateNewsResult {
|
|
|
710
723
|
}
|
|
711
724
|
/** 新闻聚合器函数签名(各 Kit 导出的 aggregateNews 符合此形状)。 */
|
|
712
725
|
type NewsAggregator = (options?: AggregateNewsOptions) => Promise<AggregateNewsResult>;
|
|
726
|
+
/**
|
|
727
|
+
* 跨市场快讯源契约(2026-09-13 金十接入):host 平面由快讯连接器 provide
|
|
728
|
+
* tradingFlashFeed,GUI 快讯面板(桥 /dshtrading/api/flash)与 agent 快讯工具
|
|
729
|
+
* 共用同一取数实现;服务缺席 = 未安装/未启用该数据源 → 消费方报
|
|
730
|
+
* TRADING_NOT_IMPLEMENTED,绝不把「没有数据源」伪装成「没有快讯」。
|
|
731
|
+
*/
|
|
732
|
+
interface FlashFeedService {
|
|
733
|
+
/**
|
|
734
|
+
* 最新快讯流(cursor 翻页);条目只含元数据(标题/时间/链接)。
|
|
735
|
+
* `hot` 非空时按热度等级服务端过滤(金十网页版 火/热/沸/爆)。
|
|
736
|
+
*/
|
|
737
|
+
listFlash(options?: {
|
|
738
|
+
cursor?: string | undefined;
|
|
739
|
+
limit?: number | undefined;
|
|
740
|
+
hot?: readonly string[] | undefined;
|
|
741
|
+
}): Promise<{
|
|
742
|
+
readonly items: readonly NewsItem[];
|
|
743
|
+
readonly nextCursor?: string | undefined;
|
|
744
|
+
readonly hasMore: boolean;
|
|
745
|
+
}>;
|
|
746
|
+
/** 关键词搜快讯(上游一次性返回、不支持翻页)。 */
|
|
747
|
+
searchFlash(keyword: string, limit?: number | undefined): Promise<readonly NewsItem[]>;
|
|
748
|
+
}
|
|
713
749
|
/** 新闻聚合器注册表契约(Issue #37,router 插件提供)。 */
|
|
714
750
|
interface TradingNewsRegistry {
|
|
715
751
|
register(market: string, aggregator: NewsAggregator): () => void;
|
|
@@ -717,4 +753,4 @@ interface TradingNewsRegistry {
|
|
|
717
753
|
markets(): string[];
|
|
718
754
|
}
|
|
719
755
|
//#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 };
|
|
756
|
+
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, 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-hk-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(
|
|
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-hk-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
|
|
139
|
+
const routerCtx = ctx;
|
|
140
|
+
const readNewsSources = () => (routerCtx.get?.("tradingMarketRouter", false))?.newsSources?.("hk");
|
|
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: "hk_get_news",
|
|
171
173
|
description: "Get recent Hong Kong stock market news, derived from Eastmoney financial fast-news (HK column) filtered to HK-relevant items (HKEX-listed marketId=116 codes or HK keywords). DEGRADED SOURCE — Eastmoney is a unified CN financial feed; HK coverage is PARTIAL (HK news without an HK-listed code or HK keyword is not captured; not a dedicated HK news source). Each item carries source name (东方财富), publish time and a link for traceability; fetches metadata only, never redistributes article bodies. Optionally filter by symbol (HK code, e.g. 00700 / 00700.HK) and by a time window. 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 "hk_get_news: no news items found within the requested window (degraded source: Eastmoney HK column may have no HK-relevant items in-window).";
|
package/lib/news.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ interface AggregateNewsOptions {
|
|
|
31
31
|
now?: number | undefined;
|
|
32
32
|
/** CryptoPanic API token(桥面透传,hk 聚合器忽略;对齐 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
|
@@ -459,10 +459,13 @@ async function aggregateNews(options = {}) {
|
|
|
459
459
|
const now = options.now ?? Date.now();
|
|
460
460
|
const windowMs = clampNumber(options.windowHours, DEFAULT_WINDOW_HOURS, 1, 168) * 36e5;
|
|
461
461
|
const limit = clampNumber(options.limit, DEFAULT_LIMIT, 1, MAX_LIMIT);
|
|
462
|
-
const
|
|
462
|
+
const enabled = options.sources;
|
|
463
|
+
const isEnabled = (id) => enabled === void 0 || enabled.includes(id);
|
|
464
|
+
const fetchers = [];
|
|
465
|
+
if (isEnabled("eastmoney")) fetchers.push(fetchEastmoneyHk(fetchImpl, limit));
|
|
463
466
|
if (options.symbol && options.symbol.trim()) {
|
|
464
|
-
fetchers.push(fetchEastmoneyHkAnnouncements(fetchImpl, options.symbol, limit));
|
|
465
|
-
fetchers.push(fetchHkexAnnouncements(fetchImpl, options.symbol, limit, now));
|
|
467
|
+
if (isEnabled("eastmoney-announcement")) fetchers.push(fetchEastmoneyHkAnnouncements(fetchImpl, options.symbol, limit));
|
|
468
|
+
if (isEnabled("hkex-announcement")) fetchers.push(fetchHkexAnnouncements(fetchImpl, options.symbol, limit, now));
|
|
466
469
|
}
|
|
467
470
|
const results = await Promise.allSettled(fetchers);
|
|
468
471
|
const items = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/kit-hk",
|
|
3
3
|
"description": "Hong Kong market toolkit plugin for dsh-trading: HK risk checklist skill provider and HK fast-news (degraded) / fundamentals tools; runs as an hk-trader preset row (session-scoped)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dshtrading/
|
|
22
|
-
"@dshtrading/
|
|
21
|
+
"@dshtrading/indicators": "0.3.0",
|
|
22
|
+
"@dshtrading/knowledge": "0.3.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@deepseek-ai/cordis": ">=4.0.0",
|
|
26
|
-
"@deepseek-ai/dsh-skill": ">=0.1.
|
|
27
|
-
"@deepseek-ai/dsh-tools": ">=0.1.
|
|
26
|
+
"@deepseek-ai/dsh-skill": ">=0.1.5-rc.1",
|
|
27
|
+
"@deepseek-ai/dsh-tools": ">=0.1.5-rc.1",
|
|
28
28
|
"@deepseek-ai/schemastery": ">=3.18.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsdown": "^0.22.0",
|
|
32
32
|
"vitest": "^3.0.0",
|
|
33
|
-
"@dshtrading/api": "0.
|
|
33
|
+
"@dshtrading/api": "0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsdown",
|