stock-sdk 2.2.2 → 2.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.
- package/README.md +7 -2
- package/dist/{adapters-BiH4keVd.d.cts → adapters-CZUNRbxi.d.cts} +29 -1
- package/dist/{adapters-BiH4keVd.d.ts → adapters-CZUNRbxi.d.ts} +29 -1
- package/dist/cache.cjs +1 -1
- package/dist/cache.d.cts +35 -3
- package/dist/cache.d.ts +35 -3
- package/dist/cache.js +1 -1
- package/dist/chip-BbA23rr1.d.cts +113 -0
- package/dist/chip-BbA23rr1.d.ts +113 -0
- package/dist/chunk-46ECBWOQ.cjs +1 -0
- package/dist/chunk-4RN7AVFQ.js +1 -0
- package/dist/chunk-6FZNYDNN.cjs +1 -0
- package/dist/chunk-6MCPZDKN.cjs +1 -0
- package/dist/chunk-H5FDXQRK.js +1 -0
- package/dist/chunk-HKREKO2F.js +1 -0
- package/dist/chunk-LDYRNH4X.cjs +1 -0
- package/dist/chunk-OPCBE3NR.js +1 -0
- package/dist/chunk-R7M3BHS4.cjs +1 -0
- package/dist/chunk-SMCYQ6NL.js +1 -0
- package/dist/chunk-USZUOBM2.cjs +1 -0
- package/dist/chunk-VKXPLWPL.js +1 -0
- package/dist/chunk-W625VPPB.js +1 -0
- package/dist/chunk-WJOFTWZL.cjs +1 -0
- package/dist/cli.cjs +16 -16
- package/dist/cli.js +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +1 -1
- package/dist/indicators.cjs +1 -1
- package/dist/indicators.d.cts +1 -0
- package/dist/indicators.d.ts +1 -0
- package/dist/indicators.js +1 -1
- package/dist/mcp.cjs +83 -5
- package/dist/mcp.d.cts +29 -2
- package/dist/mcp.d.ts +29 -2
- package/dist/mcp.js +83 -5
- package/dist/screener.cjs +1 -1
- package/dist/screener.d.cts +51 -16
- package/dist/screener.d.ts +51 -16
- package/dist/screener.js +1 -1
- package/dist/{sdk-CmYFd7V2.d.ts → sdk-DGgSDZRx.d.ts} +200 -21
- package/dist/{sdk-BOfyUDzu.d.cts → sdk-RzQ-drS4.d.cts} +200 -21
- package/dist/signals.d.cts +3 -42
- package/dist/signals.d.ts +3 -42
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.d.cts +2 -2
- package/dist/symbols.d.ts +2 -2
- package/dist/symbols.js +1 -1
- package/dist/types-7n5rSHbd.d.cts +42 -0
- package/dist/types-7n5rSHbd.d.ts +42 -0
- package/package.json +2 -1
- package/dist/chunk-3VUFYFFD.js +0 -1
- package/dist/chunk-6ZSZEHZW.js +0 -1
- package/dist/chunk-C4CA7QBB.cjs +0 -1
- package/dist/chunk-DU7MCVLJ.js +0 -1
- package/dist/chunk-EDUJJOAJ.js +0 -1
- package/dist/chunk-F3KZXCVO.js +0 -1
- package/dist/chunk-JP3ZPNWP.cjs +0 -1
- package/dist/chunk-KKGWFS2M.cjs +0 -1
- package/dist/chunk-LCX5Q36O.js +0 -1
- package/dist/chunk-T5CH7H3X.cjs +0 -1
- package/dist/chunk-TVIEKKDQ.cjs +0 -1
- package/dist/chunk-USK6JHLG.cjs +0 -1
- package/dist/chunk-WCBK5KYA.cjs +0 -1
- package/dist/chunk-ZZ2IBUMV.js +0 -1
package/dist/screener.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
interface ScreenerBuilder<T> {
|
|
2
2
|
/** 过滤:保留满足条件的项 */
|
|
3
3
|
where(predicate: (item: T) => boolean): ScreenerBuilder<T>;
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 排序:按数值选择器,默认降序。
|
|
6
|
+
* 字符串数值(原始行情 JSON 常见,如 `'999999'`)会经 `Number()` 归一后参与排序;
|
|
7
|
+
* null / undefined / NaN / 空串 / 非数值字符串统一沉底。
|
|
8
|
+
* direction 仅接受 `'asc'` / `'desc'`,其余取值抛 InvalidArgumentError。
|
|
9
|
+
*/
|
|
10
|
+
sortBy(selector: (item: T) => number | string | null | undefined, direction?: 'asc' | 'desc'): ScreenerBuilder<T>;
|
|
6
11
|
/** 取前 n 项并返回 */
|
|
7
12
|
top(n: number): T[];
|
|
8
13
|
/** 返回当前全部结果 */
|
|
@@ -21,48 +26,78 @@ interface ScreenerBuilder<T> {
|
|
|
21
26
|
*/
|
|
22
27
|
declare function screen<T>(items: readonly T[]): ScreenerBuilder<T>;
|
|
23
28
|
|
|
29
|
+
type StrategySignal = 'buy' | 'sell' | 'hold';
|
|
24
30
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
31
|
+
* 策略:对每根 K 线返回操作信号。
|
|
32
|
+
*
|
|
33
|
+
* ⚠️ 第三个参数 `series` 是**完整 K 线数组(含当前 bar 之后的未来数据)**,仅供
|
|
34
|
+
* 读取历史窗口(如 `series.slice(0, index + 1)`)。读取 `series[index + 1]` 及之后
|
|
35
|
+
* 的元素即引入前视偏差(look-ahead bias),回测结果会严重虚高且不可复现于实盘。
|
|
27
36
|
*/
|
|
28
|
-
type
|
|
29
|
-
/** 策略:对每根 K 线返回操作信号 */
|
|
30
|
-
type Strategy<T> = (bar: T, index: number, history: readonly T[]) => StrategySignal;
|
|
37
|
+
type Strategy<T> = (bar: T, index: number, series: readonly T[]) => StrategySignal;
|
|
31
38
|
interface Trade {
|
|
32
39
|
entryIndex: number;
|
|
40
|
+
/** 出场 bar 下标;强制平仓时指向**最后一根有效价 bar**(与 exitPrice 必然对应同一根) */
|
|
33
41
|
exitIndex: number;
|
|
34
42
|
entryPrice: number;
|
|
35
43
|
exitPrice: number;
|
|
36
|
-
/**
|
|
44
|
+
/** 本笔收益率(百分数,含双边费,相对本笔投入资金) */
|
|
37
45
|
returnPercent: number;
|
|
46
|
+
/**
|
|
47
|
+
* true = 数据走完时强制平仓(非策略意图出场),统计时可据此过滤。
|
|
48
|
+
* 尾部无效 bar 上挂起的 sell 视为策略意图 → forced=false(按最后有效价成交)。
|
|
49
|
+
*/
|
|
50
|
+
forced: boolean;
|
|
51
|
+
/** 入场 bar 日期(传入 getDate 时才有) */
|
|
52
|
+
entryDate?: string | number;
|
|
53
|
+
/** 出场 bar 日期(传入 getDate 时才有) */
|
|
54
|
+
exitDate?: string | number;
|
|
38
55
|
}
|
|
39
56
|
interface BacktestOptions<T> {
|
|
40
57
|
klines: readonly T[];
|
|
41
58
|
strategy: Strategy<T>;
|
|
42
|
-
/** 初始资金,默认 100000 */
|
|
59
|
+
/** 初始资金,默认 100000(须为正有限数) */
|
|
43
60
|
initialCapital?: number;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
/**
|
|
62
|
+
* 手续费率,默认 0。数字 = 买卖同费率;对象形式可表达买卖不对称
|
|
63
|
+
* (如 A 股卖出侧印花税:`{ buy: 0.0003, sell: 0.0013 }`)。取值须在 [0, 1)。
|
|
64
|
+
*/
|
|
65
|
+
fee?: number | {
|
|
66
|
+
buy: number;
|
|
67
|
+
sell: number;
|
|
68
|
+
};
|
|
69
|
+
/** 每次买入动用现金的比例,(0, 1],默认 1(全仓) */
|
|
70
|
+
positionSize?: number;
|
|
71
|
+
/** 取收盘价;默认读取 `bar.close`(分时数据字段是 price 而非 close,需自传) */
|
|
47
72
|
getClose?: (bar: T) => number | null;
|
|
73
|
+
/** 取 bar 日期(如 `bar.date`);传入后成交记录带 entryDate/exitDate */
|
|
74
|
+
getDate?: (bar: T) => string | number | null | undefined;
|
|
48
75
|
}
|
|
49
76
|
interface BacktestReport {
|
|
50
77
|
initialCapital: number;
|
|
51
78
|
finalEquity: number;
|
|
52
79
|
/** 总收益率(百分数) */
|
|
53
80
|
totalReturn: number;
|
|
54
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* 胜率(百分数)。按 `returnPercent > 0` 计胜:恰好 0(纯费差平局)与强制平仓单
|
|
83
|
+
* 均计入分母 —— 过滤强平单请用 `trades.filter(t => !t.forced)` 自行统计。
|
|
84
|
+
*/
|
|
55
85
|
winRate: number;
|
|
56
|
-
/**
|
|
86
|
+
/** 最大回撤(百分数,正数;以初始资金为起始基线) */
|
|
57
87
|
maxDrawdown: number;
|
|
88
|
+
/** 买入持有基准收益率(百分数,首根有效收盘 → 末根有效收盘,不含费) */
|
|
89
|
+
buyHoldReturn: number;
|
|
90
|
+
/** 有效价 bar 数。为 0 说明所有 bar 都取不到有效收盘价(如字段名不是 close) */
|
|
91
|
+
validBars: number;
|
|
58
92
|
tradeCount: number;
|
|
59
93
|
trades: Trade[];
|
|
60
94
|
/** 每根 K 线收盘后的权益 */
|
|
61
95
|
equityCurve: number[];
|
|
62
96
|
}
|
|
63
97
|
/**
|
|
64
|
-
* 执行回测。规则:`buy` 且空仓 →
|
|
65
|
-
*
|
|
98
|
+
* 执行回测。规则:`buy` 且空仓 → 按 positionSize 买入;`sell` 且持仓 → 全部卖出;
|
|
99
|
+
* 结束仍持仓则按最后有效收盘价强制平仓(Trade.forced = true)。
|
|
100
|
+
* 成交时点 / 无效价挂起 / 手数简化等契约见文件头注释。
|
|
66
101
|
*/
|
|
67
102
|
declare function backtest<T>(options: BacktestOptions<T>): BacktestReport;
|
|
68
103
|
|
package/dist/screener.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-OPCBE3NR.js";import"./chunk-UBIQBXQ7.js";import"./chunk-WOT6VMZA.js";export{b as backtest,a as screen};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { c as SdkErrorCode, R as RetryOptions, d as RateLimiterOptions, C as CircuitBreakerOptions, P as ProviderName, a as ProviderRequestPolicy, S as SdkError } from './index-mlzPfoON.js';
|
|
2
|
+
import { b as ChipDistributionOptions, d as ChipDistributionItem } from './chip-BbA23rr1.js';
|
|
2
3
|
import { n as MarketTz, v as TodayTimelineResponse, I as IndicatorOptions, H as HistoryKline, s as MinuteTimeline, t as MinuteKline, w as HKHistoryKline, y as HKMinuteTimeline, x as HKMinuteKline, U as USHistoryKline, E as USMinuteTimeline, z as USMinuteKline, K as KlineWithIndicators, A as AnyHistoryKline } from './addIndicators-_V3HEi0q.js';
|
|
4
|
+
import { a as Signal } from './types-7n5rSHbd.js';
|
|
3
5
|
|
|
4
6
|
interface HostHealthState {
|
|
5
7
|
host: string;
|
|
@@ -320,7 +322,8 @@ interface HKQuote {
|
|
|
320
322
|
totalMarketCap: number | null;
|
|
321
323
|
currency: string;
|
|
322
324
|
market: 'HK';
|
|
323
|
-
|
|
325
|
+
/** 命中特殊指数注册表(HSI/HSCEI/HSTECH)的行标 'index'(港股真码恒为数字,无碰撞面) */
|
|
326
|
+
assetType: 'stock' | 'index';
|
|
324
327
|
source: ProviderName;
|
|
325
328
|
}
|
|
326
329
|
/**
|
|
@@ -372,7 +375,8 @@ interface USQuote {
|
|
|
372
375
|
/** 52周最低价 */
|
|
373
376
|
low52w: number | null;
|
|
374
377
|
market: 'US';
|
|
375
|
-
|
|
378
|
+
/** 命中特殊指数注册表(DJI/INX/IXIC)的行标 'index',code 归一为注册表规范形 */
|
|
379
|
+
assetType: 'stock' | 'index';
|
|
376
380
|
source: ProviderName;
|
|
377
381
|
}
|
|
378
382
|
/**
|
|
@@ -1102,13 +1106,95 @@ interface StockChangeItem {
|
|
|
1102
1106
|
code: string;
|
|
1103
1107
|
/** 股票名称 */
|
|
1104
1108
|
name: string;
|
|
1105
|
-
/** 异动类型 */
|
|
1106
|
-
changeType: StockChangeType;
|
|
1107
|
-
/**
|
|
1109
|
+
/** 异动类型(由响应 t 码反查;服务端新增的未知码为 'unknown',原始码见 typeCode) */
|
|
1110
|
+
changeType: StockChangeType | 'unknown';
|
|
1111
|
+
/** 原始类型码(服务端 t 字段) */
|
|
1112
|
+
typeCode: string;
|
|
1113
|
+
/** 异动类型对应的中文标签(未知码为空串) */
|
|
1108
1114
|
changeTypeLabel: string;
|
|
1109
1115
|
/** 相关信息(来自原始接口) */
|
|
1110
1116
|
info: string;
|
|
1111
1117
|
}
|
|
1118
|
+
/**
|
|
1119
|
+
* 个股盘口异动事件(个股按日接口,字段比全市场接口更丰富)
|
|
1120
|
+
*/
|
|
1121
|
+
interface IndividualStockChangeItem {
|
|
1122
|
+
/** 发生时间 HH:MM:SS */
|
|
1123
|
+
time: string;
|
|
1124
|
+
/** 原始类型码(个股接口会返回 22 类之外的码,如 8219) */
|
|
1125
|
+
typeCode: string;
|
|
1126
|
+
/** 异动类型(未知码为 'unknown') */
|
|
1127
|
+
changeType: StockChangeType | 'unknown';
|
|
1128
|
+
/** 中文标签(未知码为空串) */
|
|
1129
|
+
changeTypeLabel: string;
|
|
1130
|
+
/** 触发价(元) */
|
|
1131
|
+
price: number | null;
|
|
1132
|
+
/** 触发时涨跌幅(%) */
|
|
1133
|
+
changePercent: number | null;
|
|
1134
|
+
/** 相关信息(来自原始接口,CSV 格式因类型而异) */
|
|
1135
|
+
info: string;
|
|
1136
|
+
/** 上游未文档化字段(疑似异动量级),原样透传 */
|
|
1137
|
+
v: number | null;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* 个股单个交易日的异动数据
|
|
1141
|
+
*/
|
|
1142
|
+
interface IndividualChangesDay {
|
|
1143
|
+
/** 交易日 YYYY-MM-DD */
|
|
1144
|
+
date: string;
|
|
1145
|
+
/**
|
|
1146
|
+
* 服务端该交易日是否有数据。false = 无数据(changes 恒为空),与
|
|
1147
|
+
* "当日无异动"(true + 空数组)区分。
|
|
1148
|
+
*
|
|
1149
|
+
* 注意:服务端仅保留约最近数周(实测 1 个月左右),且窗口**不保证连续**
|
|
1150
|
+
* ——实测存在个别日期空洞(更早的日期反而有数据)。永远以逐日返回的
|
|
1151
|
+
* available 为准,不要按固定天数推断。
|
|
1152
|
+
*/
|
|
1153
|
+
available: boolean;
|
|
1154
|
+
/** 股票代码 */
|
|
1155
|
+
code: string;
|
|
1156
|
+
/** 股票名称(超窗时为空串) */
|
|
1157
|
+
name: string;
|
|
1158
|
+
/** 异动事件流(服务端顺序,最新在前) */
|
|
1159
|
+
changes: IndividualStockChangeItem[];
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* 单个异动类型的计数(IndividualChangesHistory.stats 的值)
|
|
1163
|
+
*/
|
|
1164
|
+
interface ChangeTypeCount {
|
|
1165
|
+
/** 出现次数 */
|
|
1166
|
+
count: number;
|
|
1167
|
+
/** 中文标签(未知类型码为空串) */
|
|
1168
|
+
label: string;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* 个股近 N 天异动历史(逐交易日聚合)
|
|
1172
|
+
*/
|
|
1173
|
+
interface IndividualChangesHistory {
|
|
1174
|
+
/** 股票代码 */
|
|
1175
|
+
code: string;
|
|
1176
|
+
/** 股票名称 */
|
|
1177
|
+
name: string;
|
|
1178
|
+
/** 请求的自然日跨度 */
|
|
1179
|
+
requestedDays: number;
|
|
1180
|
+
/** 实际覆盖情况 */
|
|
1181
|
+
coverage: {
|
|
1182
|
+
/** 请求窗口起点(自然日)YYYY-MM-DD */
|
|
1183
|
+
from: string;
|
|
1184
|
+
/** 请求窗口终点(北京时间今天)YYYY-MM-DD */
|
|
1185
|
+
to: string;
|
|
1186
|
+
/** 窗口内首个有数据的交易日(其后仍可能有个别空洞日);全部无数据时为 null */
|
|
1187
|
+
availableFrom: string | null;
|
|
1188
|
+
};
|
|
1189
|
+
/** 逐交易日数据(按日期升序;available=false 表示服务端该日无数据) */
|
|
1190
|
+
days: IndividualChangesDay[];
|
|
1191
|
+
/**
|
|
1192
|
+
* 异动类型计数概览(仅统计 available 日)。
|
|
1193
|
+
* key 为**原始类型码**(typeCode,稳定、可跨会话程序化比较),
|
|
1194
|
+
* 中文标签见值内 label(未知码为空串)。
|
|
1195
|
+
*/
|
|
1196
|
+
stats: Record<string, ChangeTypeCount>;
|
|
1197
|
+
}
|
|
1112
1198
|
/**
|
|
1113
1199
|
* 板块异动项
|
|
1114
1200
|
*/
|
|
@@ -1488,8 +1574,11 @@ interface FundNavPoint {
|
|
|
1488
1574
|
date: string;
|
|
1489
1575
|
/** 净值日期对应的毫秒时间戳(数据源原值,UTC 当日 00:00) */
|
|
1490
1576
|
timestamp: number | null;
|
|
1491
|
-
/**
|
|
1492
|
-
|
|
1577
|
+
/**
|
|
1578
|
+
* 单位净值;上游该行净值缺失 / 非数值时为 `null`
|
|
1579
|
+
* (v2.4.0 起从 `number` 放宽,与 accNav / dailyReturn 的可空口径一致)
|
|
1580
|
+
*/
|
|
1581
|
+
nav: number | null;
|
|
1493
1582
|
/** 累计净值;与单位净值数组按 timestamp 对齐,无法对齐时为 `null` */
|
|
1494
1583
|
accNav: number | null;
|
|
1495
1584
|
/** 日增长率(%);无值时为 `null` */
|
|
@@ -1940,18 +2029,6 @@ interface GetUSCodeListOptions {
|
|
|
1940
2029
|
*/
|
|
1941
2030
|
type GetAllHKQuotesOptions = Omit<GetAllAShareQuotesOptions, 'market'>;
|
|
1942
2031
|
|
|
1943
|
-
/**
|
|
1944
|
-
* 腾讯 Smartbox 搜索接口
|
|
1945
|
-
* 支持浏览器(JSONP)和 Node.js(fetch)双端
|
|
1946
|
-
*/
|
|
1947
|
-
|
|
1948
|
-
/** 全局变量声明(浏览器环境)*/
|
|
1949
|
-
declare global {
|
|
1950
|
-
interface Window {
|
|
1951
|
-
v_hint?: string;
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
2032
|
/**
|
|
1956
2033
|
* 东方财富 - A 股 K 线
|
|
1957
2034
|
*/
|
|
@@ -2274,6 +2351,91 @@ interface KlineWithIndicatorsOptions {
|
|
|
2274
2351
|
* - 完整选项参见 `IndicatorOptions`
|
|
2275
2352
|
*/
|
|
2276
2353
|
indicators?: IndicatorOptions;
|
|
2354
|
+
/**
|
|
2355
|
+
* 窗口前额外保留的 bar 数(内部选项,信号闭环用;默认 0)。
|
|
2356
|
+
* `getKlineSignals` 传 1:交叉识别需要窗口首日的前一根做锚点,按**下标**多留
|
|
2357
|
+
* 一根已算好指标的 bar —— 对任意长度的停牌缺口都精确(区别于按天数回推的
|
|
2358
|
+
* 启发式)。仅 `startDate` 存在时生效;保留的 bar 日期早于 startDate。
|
|
2359
|
+
*/
|
|
2360
|
+
leadingBars?: number;
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* `getKlineSignals` 的请求参数。
|
|
2364
|
+
*
|
|
2365
|
+
* 复用 K 线的取数选项(market / period / adjust / startDate / endDate),
|
|
2366
|
+
* 额外用 `maFast` / `maSlow` 指定 MA 金叉/死叉的快慢线周期。其余信号族
|
|
2367
|
+
* (MACD / KDJ / RSI / BOLL / SAR)用固定的常用默认阈值,一次性全部识别。
|
|
2368
|
+
*/
|
|
2369
|
+
interface KlineSignalsOptions {
|
|
2370
|
+
/** 市场类型;不传由 `symbol` 自动识别(同 {@link KlineWithIndicatorsOptions.market}) */
|
|
2371
|
+
market?: MarketType;
|
|
2372
|
+
/** K 线周期,默认 `'daily'` */
|
|
2373
|
+
period?: 'daily' | 'weekly' | 'monthly';
|
|
2374
|
+
/** 复权方式:`''` 不复权 / `'qfq'` 前复权 / `'hfq'` 后复权 */
|
|
2375
|
+
adjust?: '' | 'qfq' | 'hfq';
|
|
2376
|
+
/**
|
|
2377
|
+
* 起始日期(`YYYYMMDD` 或 `YYYY-MM-DD`)。
|
|
2378
|
+
* 不传则在全部历史上识别信号;只关心近期请传起始日期收窄窗口。
|
|
2379
|
+
*/
|
|
2380
|
+
startDate?: string;
|
|
2381
|
+
/** 结束日期(`YYYYMMDD` 或 `YYYY-MM-DD`) */
|
|
2382
|
+
endDate?: string;
|
|
2383
|
+
/** MA 金叉/死叉快线周期,默认 5(须为正整数且小于 `maSlow`) */
|
|
2384
|
+
maFast?: number;
|
|
2385
|
+
/** MA 金叉/死叉慢线周期,默认 20(须为正整数且大于 `maFast`) */
|
|
2386
|
+
maSlow?: number;
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* 一条识别出的指标信号 —— 在原始 {@link Signal} 上补充**日期与收盘价**,
|
|
2390
|
+
* 让 LLM / 调用方无需回查 K 线即可解读(如「MACD 金叉 · 2026-06-15 · 收 1720」)。
|
|
2391
|
+
*/
|
|
2392
|
+
interface KlineSignal {
|
|
2393
|
+
/** 信号类型(14 种:MA/MACD/KDJ 金叉死叉、KDJ/RSI 超买超卖、BOLL 突破、SAR 反转) */
|
|
2394
|
+
type: Signal['type'];
|
|
2395
|
+
/** 信号发生 K 线的日期(原始 `date`,通常 `YYYY-MM-DD`) */
|
|
2396
|
+
date: string;
|
|
2397
|
+
/** 信号发生 K 线的时间戳(epoch 毫秒,= {@link Signal.at}) */
|
|
2398
|
+
timestamp: number;
|
|
2399
|
+
/** 信号发生 K 线的收盘价 */
|
|
2400
|
+
close: number | null;
|
|
2401
|
+
/** 附加信息(如金叉的快慢周期、超买超卖的指标值) */
|
|
2402
|
+
detail?: Record<string, number>;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* 筹码分布 Service:拉取对应市场日 K 线(含暖机段)→ 本地计算 → 裁剪返回。
|
|
2407
|
+
* 计算本体在 `src/indicators/chip.ts`(纯函数,零网络),本 service 只做编排。
|
|
2408
|
+
*/
|
|
2409
|
+
|
|
2410
|
+
/** `chips.cn / hk / us` 的请求参数 */
|
|
2411
|
+
interface ChipDistributionRequestOptions extends Pick<ChipDistributionOptions, 'range' | 'includeHistogram' | 'decimals'> {
|
|
2412
|
+
/**
|
|
2413
|
+
* 返回最近多少个交易日的筹码分布序列。
|
|
2414
|
+
* @default 90
|
|
2415
|
+
*/
|
|
2416
|
+
days?: number;
|
|
2417
|
+
/**
|
|
2418
|
+
* 复权方式(与对应市场 `kline.*` 一致,默认 `'qfq'` 前复权)。
|
|
2419
|
+
* 分布数值随复权口径变化;需对齐 akshare `stock_cyq_em` 默认输出时传 `''`。
|
|
2420
|
+
* @default 'qfq'
|
|
2421
|
+
*/
|
|
2422
|
+
adjust?: '' | 'qfq' | 'hfq';
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
/** `marketEvent.individualChanges` 的请求参数 */
|
|
2426
|
+
interface IndividualChangesOptions {
|
|
2427
|
+
/** 交易日 YYYYMMDD 或 YYYY-MM-DD;不传为北京时间今天 */
|
|
2428
|
+
date?: string;
|
|
2429
|
+
}
|
|
2430
|
+
/** `marketEvent.individualChangesHistory` 的请求参数 */
|
|
2431
|
+
interface IndividualChangesHistoryOptions {
|
|
2432
|
+
/**
|
|
2433
|
+
* 最近 N 个自然日(1~60)。内部按 A 股交易日历枚举其中的交易日逐日请求。
|
|
2434
|
+
* 注意服务端仅保留约最近数周(且可能存在个别日期空洞),
|
|
2435
|
+
* 无数据的日期返回 available: false。
|
|
2436
|
+
* @default 7
|
|
2437
|
+
*/
|
|
2438
|
+
days?: number;
|
|
2277
2439
|
}
|
|
2278
2440
|
|
|
2279
2441
|
/**
|
|
@@ -2356,6 +2518,7 @@ declare class StockSDK {
|
|
|
2356
2518
|
private readonly futuresService;
|
|
2357
2519
|
private readonly optionsService;
|
|
2358
2520
|
private readonly indicatorService;
|
|
2521
|
+
private readonly chipService;
|
|
2359
2522
|
private readonly fundFlowService;
|
|
2360
2523
|
private readonly northboundService;
|
|
2361
2524
|
private readonly marketEventService;
|
|
@@ -2369,6 +2532,13 @@ declare class StockSDK {
|
|
|
2369
2532
|
* 也可以通过 `providerPolicies` 为不同数据源覆盖请求治理策略而不影响既有 API。
|
|
2370
2533
|
*/
|
|
2371
2534
|
constructor(options?: RequestClientOptions);
|
|
2535
|
+
/**
|
|
2536
|
+
* 清空本实例的全部内部缓存(代码表 / 交易日历 / 板块名称映射 / us-secid 解析)。
|
|
2537
|
+
*
|
|
2538
|
+
* R7-11 起这些缓存按实例隔离,模块级 `clearSharedCaches()` 对它们不再生效
|
|
2539
|
+
* —— 长驻进程需要强刷时用本方法。
|
|
2540
|
+
*/
|
|
2541
|
+
clearCaches(): void;
|
|
2372
2542
|
private readonly _ns;
|
|
2373
2543
|
private memoNs;
|
|
2374
2544
|
/** 实时行情 */
|
|
@@ -2409,6 +2579,13 @@ declare class StockSDK {
|
|
|
2409
2579
|
us: (symbol: string, options?: USKlineOptions) => Promise<USHistoryKline[]>;
|
|
2410
2580
|
usMinute: (symbol: string, options?: USMinuteKlineOptions) => Promise<USMinuteTimeline[] | USMinuteKline[]>;
|
|
2411
2581
|
withIndicators: (symbol: string, options?: KlineWithIndicatorsOptions) => Promise<KlineWithIndicators<AnyHistoryKline>[]>;
|
|
2582
|
+
signals: (symbol: string, options?: KlineSignalsOptions) => Promise<KlineSignal[]>;
|
|
2583
|
+
};
|
|
2584
|
+
/** 筹码分布(A 股 / 港股 / 美股,基于日 K + 换手率本地计算) */
|
|
2585
|
+
get chips(): {
|
|
2586
|
+
cn: (symbol: string, options?: ChipDistributionRequestOptions) => Promise<ChipDistributionItem[]>;
|
|
2587
|
+
hk: (symbol: string, options?: ChipDistributionRequestOptions) => Promise<ChipDistributionItem[]>;
|
|
2588
|
+
us: (symbol: string, options?: ChipDistributionRequestOptions) => Promise<ChipDistributionItem[]>;
|
|
2412
2589
|
};
|
|
2413
2590
|
/** 板块(行业 / 概念) */
|
|
2414
2591
|
get board(): {
|
|
@@ -2477,8 +2654,10 @@ declare class StockSDK {
|
|
|
2477
2654
|
/** 涨停 / 盘口异动 */
|
|
2478
2655
|
get marketEvent(): {
|
|
2479
2656
|
ztPool: (type?: ZTPoolType, date?: string) => Promise<ZTPoolItem[]>;
|
|
2480
|
-
stockChanges: (type?: StockChangeType) => Promise<StockChangeItem[]>;
|
|
2657
|
+
stockChanges: (type?: StockChangeType | StockChangeType[] | "all") => Promise<StockChangeItem[]>;
|
|
2481
2658
|
boardChanges: () => Promise<BoardChangeItem[]>;
|
|
2659
|
+
individualChanges: (symbol: string, options?: IndividualChangesOptions) => Promise<IndividualStockChangeItem[]>;
|
|
2660
|
+
individualChangesHistory: (symbol: string, options?: IndividualChangesHistoryOptions) => Promise<IndividualChangesHistory>;
|
|
2482
2661
|
};
|
|
2483
2662
|
/** 龙虎榜 */
|
|
2484
2663
|
get dragonTiger(): {
|
|
@@ -2527,4 +2706,4 @@ declare class StockSDK {
|
|
|
2527
2706
|
search(keyword: string): Promise<SearchResult[]>;
|
|
2528
2707
|
}
|
|
2529
2708
|
|
|
2530
|
-
export { type
|
|
2709
|
+
export { type IndustryBoardKline as $, type AShareMarket as A, type NorthboundHistoryOptions as B, type ChipDistributionRequestOptions as C, type BlockTradeDateOptions as D, type ExternalLink as E, FundService as F, type GetAllAShareQuotesOptions as G, type HistoryKlineOptions as H, type IndividualChangesOptions as I, type DragonTigerDateOptions as J, type FullQuote as K, type SimpleQuote as L, type MarketType as M, type NorthboundHoldingRankOptions as N, type FundFlow as O, type PanelLargeOrder as P, type HKQuote as Q, type RequestClientOptions as R, StockSDK as S, TradingCalendarService as T, type USMarket as U, type USQuote as V, type FundQuote as W, type Quote as X, type IndustryBoard as Y, type IndustryBoardSpot as Z, type IndustryBoardConstituent as _, RequestClient as a, type FundNavPoint as a$, type IndustryBoardMinuteTimeline as a0, type IndustryBoardMinuteKline as a1, type ConceptBoard as a2, type ConceptBoardSpot as a3, type ConceptBoardConstituent as a4, type ConceptBoardKline as a5, type ConceptBoardMinuteTimeline as a6, type ConceptBoardMinuteKline as a7, type FuturesExchange as a8, type FuturesKline as a9, type NorthboundHistoryItem as aA, type NorthboundIndividualItem as aB, type ZTPoolType as aC, type ZTPoolItem as aD, type StockChangeType as aE, type StockChangeItem as aF, type IndividualStockChangeItem as aG, type IndividualChangesDay as aH, type ChangeTypeCount as aI, type IndividualChangesHistory as aJ, type BoardChangeItem as aK, type DragonTigerPeriod as aL, type DragonTigerDetailItem as aM, type DragonTigerStockStatItem as aN, type DragonTigerInstitutionItem as aO, type DragonTigerBranchItem as aP, type DragonTigerSeatItem as aQ, type BlockTradeMarketStatItem as aR, type BlockTradeDetailItem as aS, type BlockTradeDailyStatItem as aT, type MarginAccountItem as aU, type MarginTargetItem as aV, type FundDividendRank as aW, type FundSortDirection as aX, type FundDividendListOptions as aY, type FundDividend as aZ, type FundDividendListResult as a_, type GlobalFuturesQuote as aa, type FuturesInventorySymbol as ab, type FuturesInventory as ac, type ComexInventory as ad, type IndexOptionProduct as ae, type OptionTQuote as af, type OptionTQuoteResult as ag, type OptionKline as ah, type OptionMinute as ai, type ETFOptionMonth as aj, type ETFOptionExpireDay as ak, type ETFOptionCate as al, type CFFEXOptionQuote as am, type OptionLHBItem as an, type SearchResultType as ao, type DividendDetail as ap, type StockFundFlowDaily as aq, type FundFlowRankItem as ar, type SectorFundFlowItem as as, type MarketFundFlow as at, type NorthboundDirection as au, type NorthboundMarket as av, type NorthboundRankPeriod as aw, type NorthboundMinuteItem as ax, type NorthboundFlowSummary as ay, type NorthboundHoldingRankItem as az, type SearchResult as b, type FundNavHistory as b0, type FundEstimate as b1, type FundRankPoint as b2, type FundRankHistory as b3, type FundHolding as b4, type FundBondHolding as b5, type FundAssetAllocation as b6, type FundPositionPoint as b7, type FundManager as b8, type FundPerformanceEvaluation as b9, type FundHolderStructure as ba, type FundScaleChange as bb, type FundBuySedemption as bc, type FundStageReturns as bd, type FundSameTypePeer as be, type FundSameType as bf, type ThemeFundSort as bg, type ThemeFundOrder as bh, type ThemeCategory as bi, type GetThemeListOptions as bj, type GetHotThemesOptions as bk, type ThemeFundRankSort as bl, type GetThemeFundsOptions as bm, type ThemeFund as bn, type ThemeFundListResult as bo, type HotThemesResult as bp, type ThemeFundItem as bq, type ThemeFundItemList as br, type IndividualChangesHistoryOptions as c, type GetAShareCodeListOptions as d, type GetUSCodeListOptions as e, type GetAllUSQuotesOptions as f, type MarketStatus as g, type SupportedMarket as h, type FundProfile as i, type MinuteKlineOptions as j, type HKKlineOptions as k, type HKMinuteKlineOptions as l, type USKlineOptions as m, type USMinuteKlineOptions as n, type IndustryBoardKlineOptions as o, type IndustryBoardMinuteKlineOptions as p, type ConceptBoardKlineOptions as q, type ConceptBoardMinuteKlineOptions as r, type FuturesKlineOptions as s, type GlobalFuturesSpotOptions as t, type GlobalFuturesKlineOptions as u, type FuturesInventoryOptions as v, type ComexInventoryOptions as w, type CFFEXOptionQuotesOptions as x, type FundFlowOptions as y, type FundFlowRankOptions as z };
|