@dshtrading/kit-crypto 0.2.1 → 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 +4 -3
- package/lib/index.js +9 -3
- package/lib/news.d.ts +2 -0
- package/lib/news.js +10 -9
- package/package.json +4 -4
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
|
@@ -10,14 +10,14 @@ declare const provider: SkillProvider;
|
|
|
10
10
|
interface Config {
|
|
11
11
|
dryRun: boolean;
|
|
12
12
|
liveTrading: boolean;
|
|
13
|
-
/**
|
|
14
|
-
skills?: string[];
|
|
13
|
+
/** 角色预设按需收窄技能面;字段缺席保持全量捆绑目录,显式空数组才表示不下发任何技能。 */
|
|
14
|
+
skills?: string[] | null;
|
|
15
15
|
}
|
|
16
16
|
declare const Config: Schema<Config>;
|
|
17
17
|
declare const inject: string[];
|
|
18
18
|
declare const name = "dsh-trading-crypto-kit";
|
|
19
19
|
/** 白名单视图:未知名 fail-fast 不静默缩面;白名单外的 get 拒绝分发。 */
|
|
20
|
-
declare function providerForSkills(allowed?: readonly string[]): SkillProvider;
|
|
20
|
+
declare function providerForSkills(allowed?: readonly string[] | null): SkillProvider;
|
|
21
21
|
declare function apply(ctx: Context, config: Config): void;
|
|
22
22
|
declare function createGetDerivativesTool(options?: {
|
|
23
23
|
fetch?: typeof globalThis.fetch;
|
|
@@ -41,6 +41,7 @@ declare function createGetFundamentalsTool(options?: {
|
|
|
41
41
|
}): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
42
42
|
declare function createGetNewsTool(toolOptions?: {
|
|
43
43
|
cryptoPanicKey?: string;
|
|
44
|
+
getSources?: () => readonly string[] | undefined;
|
|
44
45
|
}): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
45
46
|
//#endregion
|
|
46
47
|
export { AggregateNewsOptions, AggregateNewsResult, Config, CryptoFundamentalsOptions, CryptoFundamentalsResult, DerivativesFetchOptions, DerivativesResult, NewsItem, NewsSource, aggregateNews, apply, createGetDerivativesHistoryTool, createGetDerivativesTool, createGetFundamentalsTool, createGetNewsTool, deriveSymbolTokens, extractBaseAsset, fetchCryptoDerivatives, fetchCryptoFundamentals, fetchCryptoFundamentalsPackage, inject, name, normalizeBinanceFuturesSymbol, parseCryptoPanic, parseRss2, provider, providerForSkills, renderCryptoFundamentals, renderDerivativesData };
|
package/lib/index.js
CHANGED
|
@@ -131,7 +131,7 @@ const provider = {
|
|
|
131
131
|
const Config = Schema.object({
|
|
132
132
|
dryRun: Schema.boolean().default(true),
|
|
133
133
|
liveTrading: Schema.boolean().default(false),
|
|
134
|
-
skills: Schema.array(Schema.string())
|
|
134
|
+
skills: Schema.union([Schema.array(Schema.string()), Schema.const(null)]).default(null)
|
|
135
135
|
});
|
|
136
136
|
const inject = ["skills", "tools"];
|
|
137
137
|
const name = "dsh-trading-crypto-kit";
|
|
@@ -219,7 +219,12 @@ function apply(ctx, config) {
|
|
|
219
219
|
};
|
|
220
220
|
registerOnce(fundingTool);
|
|
221
221
|
const router = ctx.get?.("tradingMarketRouter", false);
|
|
222
|
-
|
|
222
|
+
const routerCtx = ctx;
|
|
223
|
+
const readNewsSources = () => (routerCtx.get?.("tradingMarketRouter", false))?.newsSources?.("crypto");
|
|
224
|
+
registerOnce(createGetNewsTool({
|
|
225
|
+
cryptoPanicKey: router?.newsKey?.(),
|
|
226
|
+
getSources: readNewsSources
|
|
227
|
+
}));
|
|
223
228
|
registerOnce(createGetDerivativesTool());
|
|
224
229
|
registerOnce(createGetFundamentalsTool());
|
|
225
230
|
registerOnce(createGetDerivativesHistoryTool({ getRegistry: () => resolveCryptoMarketDataRegistry(ctx) }));
|
|
@@ -397,7 +402,8 @@ function createGetNewsTool(toolOptions = {}) {
|
|
|
397
402
|
symbol: typeof args.symbol === "string" ? args.symbol : void 0,
|
|
398
403
|
windowHours: typeof args.windowHours === "number" ? args.windowHours : void 0,
|
|
399
404
|
limit: typeof args.limit === "number" ? args.limit : void 0,
|
|
400
|
-
cryptoPanicKey: toolOptions.cryptoPanicKey
|
|
405
|
+
cryptoPanicKey: toolOptions.cryptoPanicKey,
|
|
406
|
+
sources: toolOptions.getSources?.()
|
|
401
407
|
};
|
|
402
408
|
const { items, unavailable } = await aggregateNews(options);
|
|
403
409
|
if (items.length === 0 && unavailable.length === 0) return "crypto_get_news: no news items found within the requested window.";
|
package/lib/news.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ interface AggregateNewsOptions {
|
|
|
34
34
|
now?: number | undefined;
|
|
35
35
|
/** WS2c:CryptoPanic API token。有值时加测 CryptoPanic 免费层(B 增强);无值 = 仅公共源。 */
|
|
36
36
|
cryptoPanicKey?: string | undefined;
|
|
37
|
+
/** 启用源 id 列表(issue #96 源配置化);缺省 = 全部默认源,空数组 = 显式关闭。 */
|
|
38
|
+
sources?: readonly string[] | undefined;
|
|
37
39
|
}
|
|
38
40
|
interface AggregateNewsResult {
|
|
39
41
|
items: NewsItem[];
|
package/lib/news.js
CHANGED
|
@@ -161,15 +161,16 @@ async function aggregateNews(options = {}) {
|
|
|
161
161
|
const windowMs = clampNumber(options.windowHours, DEFAULT_WINDOW_HOURS, 1, 168) * 36e5;
|
|
162
162
|
const limit = clampNumber(options.limit, DEFAULT_LIMIT, 1, MAX_LIMIT);
|
|
163
163
|
const tokens = deriveSymbolTokens(options.symbol);
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
164
|
+
const enabled = options.sources;
|
|
165
|
+
const isEnabled = (id) => enabled === void 0 || enabled.includes(id);
|
|
166
|
+
const fetchers = [];
|
|
167
|
+
if (isEnabled("binance")) fetchers.push(fetchBinanceNews(fetchImpl));
|
|
168
|
+
if (isEnabled("okx")) fetchers.push(fetchOkxNews(fetchImpl));
|
|
169
|
+
if (isEnabled("coindesk")) fetchers.push(fetchRssNews(fetchImpl, "coindesk", COINDESK_RSS_URL));
|
|
170
|
+
if (isEnabled("theblock")) fetchers.push(fetchRssNews(fetchImpl, "theblock", THEBLOCK_RSS_URL));
|
|
171
|
+
if (isEnabled("cointelegraph")) fetchers.push(fetchRssNews(fetchImpl, "cointelegraph", COINTELEGRAPH_RSS_URL));
|
|
172
|
+
if (isEnabled("decrypt")) fetchers.push(fetchRssNews(fetchImpl, "decrypt", DECRYPT_RSS_URL));
|
|
173
|
+
if (options.cryptoPanicKey && options.cryptoPanicKey.trim() && isEnabled("cryptopanic")) {
|
|
173
174
|
const currencies = [...new Set(tokens.map((t) => t.replace(/[-_]?(?:SWAP|PERP|FUTURES|DEFAULT)$/i, "")).map((t) => t.replace(/(?:USDT|USDC|BUSD|FDUSD|USD)$/i, "")))].filter(Boolean).join(",");
|
|
174
175
|
fetchers.push(fetchCryptoPanicNews(fetchImpl, options.cryptoPanicKey.trim(), currencies));
|
|
175
176
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/kit-crypto",
|
|
3
3
|
"description": "Crypto toolkit plugin for dsh-trading: market-specific tools and bundled trading skills (skill provider); runs as a crypto-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,8 +18,8 @@
|
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
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",
|