stock-sdk 2.0.0-beta.0 → 2.0.0-beta.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.
Files changed (62) hide show
  1. package/README.md +5 -1
  2. package/dist/{adapters-C0s5bM8O.d.cts → adapters-BvE63CMd.d.cts} +16 -1
  3. package/dist/{adapters-C0s5bM8O.d.ts → adapters-BvE63CMd.d.ts} +16 -1
  4. package/dist/{addIndicators-TPEcddTW.d.cts → addIndicators-DwEr9RKK.d.cts} +207 -191
  5. package/dist/{addIndicators-TPEcddTW.d.ts → addIndicators-DwEr9RKK.d.ts} +207 -191
  6. package/dist/cache.cjs +1 -1
  7. package/dist/cache.js +1 -1
  8. package/dist/chunk-2PYGJ5I5.cjs +1 -0
  9. package/dist/chunk-3NSUE34F.cjs +1 -0
  10. package/dist/chunk-4PVVFEOQ.js +1 -0
  11. package/dist/chunk-C4CA7QBB.cjs +1 -0
  12. package/dist/chunk-D2MGPO3R.js +1 -0
  13. package/dist/{chunk-JYHHLB34.js → chunk-DU7MCVLJ.js} +1 -1
  14. package/dist/{chunk-SPLQXFFF.js → chunk-F3KZXCVO.js} +1 -1
  15. package/dist/chunk-G5KF73BW.js +1 -0
  16. package/dist/chunk-GBHWMR2O.js +1 -0
  17. package/dist/chunk-LCX5Q36O.js +1 -0
  18. package/dist/chunk-PMERLSCU.cjs +1 -0
  19. package/dist/{chunk-DOOAXFSS.cjs → chunk-TVIEKKDQ.cjs} +1 -1
  20. package/dist/{chunk-BGZ4ZUAF.cjs → chunk-WCBK5KYA.cjs} +1 -1
  21. package/dist/chunk-YR2SVSXB.cjs +1 -0
  22. package/dist/cli.cjs +17 -16
  23. package/dist/cli.js +17 -16
  24. package/dist/errors.d.cts +1 -1
  25. package/dist/errors.d.ts +1 -1
  26. package/dist/{index-B0PXWAkv.d.cts → index-mlzPfoON.d.cts} +12 -0
  27. package/dist/{index-B0PXWAkv.d.ts → index-mlzPfoON.d.ts} +12 -0
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.cts +6 -6
  30. package/dist/index.d.ts +6 -6
  31. package/dist/index.js +1 -1
  32. package/dist/indicators.cjs +1 -1
  33. package/dist/indicators.d.cts +55 -5
  34. package/dist/indicators.d.ts +55 -5
  35. package/dist/indicators.js +1 -1
  36. package/dist/mcp.cjs +5 -5
  37. package/dist/mcp.d.cts +3 -3
  38. package/dist/mcp.d.ts +3 -3
  39. package/dist/mcp.js +5 -5
  40. package/dist/screener.cjs +1 -1
  41. package/dist/screener.js +1 -1
  42. package/dist/{sdk-CGd_HgIM.d.ts → sdk-Cg_jTmTk.d.cts} +21 -527
  43. package/dist/{sdk-C_Agv5AV.d.cts → sdk-DOz03n_v.d.ts} +21 -527
  44. package/dist/signals.cjs +1 -1
  45. package/dist/signals.d.cts +1 -1
  46. package/dist/signals.d.ts +1 -1
  47. package/dist/signals.js +1 -1
  48. package/dist/symbols.cjs +1 -1
  49. package/dist/symbols.d.cts +2 -2
  50. package/dist/symbols.d.ts +2 -2
  51. package/dist/symbols.js +1 -1
  52. package/package.json +4 -8
  53. package/dist/chunk-333W3ADG.js +0 -1
  54. package/dist/chunk-4RR2H3DC.js +0 -1
  55. package/dist/chunk-66NWE54C.cjs +0 -1
  56. package/dist/chunk-6JEP4QK7.cjs +0 -1
  57. package/dist/chunk-HFN6G5M4.js +0 -1
  58. package/dist/chunk-LRE63M2C.js +0 -1
  59. package/dist/chunk-NMRUSAWS.cjs +0 -1
  60. package/dist/chunk-PVSDXLQP.cjs +0 -1
  61. package/dist/chunk-XVLG3G7T.cjs +0 -1
  62. package/dist/chunk-ZAQ7DTRY.js +0 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  无需 Python、无需后端服务,直接在 **浏览器或 Node.js** 中获取 **A 股 / 港股 / 美股 / 公募基金** 的实时行情与 K 线数据。还自带 **命令行工具** 与 **MCP server**,一条命令取行情或接入 AI。
14
14
 
15
- **✨ 零依赖 | 🌐 Browser + Node.js | 📦 ESM + CJS + subpath | 🧠 完整 TypeScript 类型 | 🖥️ CLI | 🤖 MCP**
15
+ **✨ 零依赖、轻量发布包 | 🌐 Browser + Node.js | 📦 ESM + CJS + subpath | 🧠 完整 TypeScript 类型 | 🖥️ CLI | 🤖 MCP**
16
16
 
17
17
  > 🧪 **v2.0.0 Beta**:v2 是一次架构跃迁(命名空间 API、统一符号模型、`Quote` 可辨识联合、统一错误体系、CLI / MCP / subpath 导出)。
18
18
  > 安装 beta:`npm i stock-sdk@beta`。从 v1 升级请先读 [v1 → v2 迁移指南](https://stock-sdk-v2.linkdiary.cn/guide/migration-v1-to-v2)(**破坏性变更,无兼容别名**)。
@@ -216,6 +216,10 @@ try {
216
216
  只用纯计算(指标 / 符号 / 信号 / 选股)时,从 subpath 导入,bundle 不会拖入 `RequestClient` 与所有 provider:
217
217
 
218
218
  ```ts
219
+ // 14 个指标、共 17 个纯函数(MA 族含 calcSMA/calcEMA/calcWMA 三个变体):
220
+ // calcSMA / calcEMA / calcWMA / calcMA / calcMACD / calcBOLL / calcKDJ /
221
+ // calcRSI / calcWR / calcBIAS / calcCCI / calcATR / calcOBV / calcROC /
222
+ // calcDMI / calcSAR / calcKC
219
223
  import { calcMACD, calcKDJ } from 'stock-sdk/indicators';
220
224
  import { normalizeSymbol, toTencentSymbol } from 'stock-sdk/symbols';
221
225
  import { calcSignals } from 'stock-sdk/signals';
@@ -39,6 +39,15 @@ interface NormalizedSymbol {
39
39
  type SymbolInput = string | SymbolRef;
40
40
 
41
41
  declare function normalizeSymbol(input: SymbolInput, hint?: Partial<SymbolRef>): NormalizedSymbol;
42
+ /**
43
+ * 解析符号所属市场;解析失败返回 `undefined`,不抛错。
44
+ *
45
+ * F42: 收编 SDK(indicatorService.detectMarket)与 CLI(manifest.detectMarketTag)
46
+ * 各自 wrap normalizeSymbol + catch 的双实现。本函数**不**替调用方决定解析失败
47
+ * 时的兜底市场 —— "失败归 A 股"之类的 fallback 决策保留在各调用方(各一行),
48
+ * 避免把上层策略埋进共享符号层。
49
+ */
50
+ declare function marketOf(input: SymbolInput): Market | undefined;
42
51
 
43
52
  /**
44
53
  * Provider 符号适配器:NormalizedSymbol → 各数据源原生格式(纯函数)
@@ -48,6 +57,12 @@ declare function normalizeSymbol(input: SymbolInput, hint?: Partial<SymbolRef>):
48
57
  * 避免把海外期货误拼成美股 secid(105.xxx)这类隐蔽错误。
49
58
  */
50
59
 
60
+ /**
61
+ * 交易所 → 东财 secid 数字市场前缀(仅股票类)。
62
+ * F41: 导出供 providers 复用(tencent/batch 的美股代码列表按前缀过滤),
63
+ * 不再在各处重复声明 NASDAQ/NYSE/AMEX → 105/106/107 映射。
64
+ */
65
+ declare const EXCHANGE_TO_SECID_PREFIX: Record<string, string>;
51
66
  /**
52
67
  * → 腾讯行情格式:sh600519 / sz000001 / bj920819 / hk00700 / usAAPL
53
68
  */
@@ -59,4 +74,4 @@ declare function toEastmoneySecid(ns: NormalizedSymbol): string;
59
74
  /** → 纯代码(去前缀) */
60
75
  declare function toPlainCode(ns: NormalizedSymbol): string;
61
76
 
62
- export { type AssetType as A, type Exchange as E, type Market as M, type NormalizedSymbol as N, type SymbolRef as S, type SymbolInput as a, toEastmoneySecid as b, toPlainCode as c, normalizeSymbol as n, toTencentSymbol as t };
77
+ export { type AssetType as A, type Exchange as E, type Market as M, type NormalizedSymbol as N, type SymbolRef as S, type SymbolInput as a, toEastmoneySecid as b, toPlainCode as c, EXCHANGE_TO_SECID_PREFIX as d, marketOf as m, normalizeSymbol as n, toTencentSymbol as t };
@@ -39,6 +39,15 @@ interface NormalizedSymbol {
39
39
  type SymbolInput = string | SymbolRef;
40
40
 
41
41
  declare function normalizeSymbol(input: SymbolInput, hint?: Partial<SymbolRef>): NormalizedSymbol;
42
+ /**
43
+ * 解析符号所属市场;解析失败返回 `undefined`,不抛错。
44
+ *
45
+ * F42: 收编 SDK(indicatorService.detectMarket)与 CLI(manifest.detectMarketTag)
46
+ * 各自 wrap normalizeSymbol + catch 的双实现。本函数**不**替调用方决定解析失败
47
+ * 时的兜底市场 —— "失败归 A 股"之类的 fallback 决策保留在各调用方(各一行),
48
+ * 避免把上层策略埋进共享符号层。
49
+ */
50
+ declare function marketOf(input: SymbolInput): Market | undefined;
42
51
 
43
52
  /**
44
53
  * Provider 符号适配器:NormalizedSymbol → 各数据源原生格式(纯函数)
@@ -48,6 +57,12 @@ declare function normalizeSymbol(input: SymbolInput, hint?: Partial<SymbolRef>):
48
57
  * 避免把海外期货误拼成美股 secid(105.xxx)这类隐蔽错误。
49
58
  */
50
59
 
60
+ /**
61
+ * 交易所 → 东财 secid 数字市场前缀(仅股票类)。
62
+ * F41: 导出供 providers 复用(tencent/batch 的美股代码列表按前缀过滤),
63
+ * 不再在各处重复声明 NASDAQ/NYSE/AMEX → 105/106/107 映射。
64
+ */
65
+ declare const EXCHANGE_TO_SECID_PREFIX: Record<string, string>;
51
66
  /**
52
67
  * → 腾讯行情格式:sh600519 / sz000001 / bj920819 / hk00700 / usAAPL
53
68
  */
@@ -59,4 +74,4 @@ declare function toEastmoneySecid(ns: NormalizedSymbol): string;
59
74
  /** → 纯代码(去前缀) */
60
75
  declare function toPlainCode(ns: NormalizedSymbol): string;
61
76
 
62
- export { type AssetType as A, type Exchange as E, type Market as M, type NormalizedSymbol as N, type SymbolRef as S, type SymbolInput as a, toEastmoneySecid as b, toPlainCode as c, normalizeSymbol as n, toTencentSymbol as t };
77
+ export { type AssetType as A, type Exchange as E, type Market as M, type NormalizedSymbol as N, type SymbolRef as S, type SymbolInput as a, toEastmoneySecid as b, toPlainCode as c, EXCHANGE_TO_SECID_PREFIX as d, marketOf as m, normalizeSymbol as n, toTencentSymbol as t };
@@ -1,3 +1,195 @@
1
+ interface OHLCV {
2
+ open: number | null;
3
+ high: number | null;
4
+ low: number | null;
5
+ close: number | null;
6
+ volume?: number | null;
7
+ }
8
+ interface MAOptions {
9
+ /** 均线周期数组,默认 [5, 10, 20, 30, 60, 120, 250] */
10
+ periods?: number[];
11
+ /** 均线类型:'sma'(简单) | 'ema'(指数) | 'wma'(加权),默认 'sma' */
12
+ type?: 'sma' | 'ema' | 'wma';
13
+ }
14
+ interface MACDOptions {
15
+ /** 短期 EMA 周期,默认 12 */
16
+ short?: number;
17
+ /** 长期 EMA 周期,默认 26 */
18
+ long?: number;
19
+ /** 信号线 EMA 周期,默认 9 */
20
+ signal?: number;
21
+ }
22
+ interface BOLLOptions {
23
+ /** 均线周期,默认 20 */
24
+ period?: number;
25
+ /** 标准差倍数,默认 2 */
26
+ stdDev?: number;
27
+ }
28
+ interface KDJOptions {
29
+ /** RSV 周期,默认 9 */
30
+ period?: number;
31
+ /** K 值平滑周期,默认 3 */
32
+ kPeriod?: number;
33
+ /** D 值平滑周期,默认 3 */
34
+ dPeriod?: number;
35
+ }
36
+ interface RSIOptions {
37
+ /** RSI 周期数组,默认 [6, 12, 24] */
38
+ periods?: number[];
39
+ }
40
+ interface WROptions {
41
+ /** WR 周期数组,默认 [6, 10] */
42
+ periods?: number[];
43
+ }
44
+ interface BIASOptions {
45
+ /** BIAS 周期数组,默认 [6, 12, 24] */
46
+ periods?: number[];
47
+ }
48
+ interface CCIOptions {
49
+ /** CCI 周期,默认 14 */
50
+ period?: number;
51
+ }
52
+ interface ATROptions {
53
+ /** ATR 周期,默认 14 */
54
+ period?: number;
55
+ }
56
+ /**
57
+ * 周期型指标(periods 复数)的文档简写入参:
58
+ * - `[5, 20]` 等价于 `{ periods: [5, 20] }`
59
+ * - `{ period: 14 }` 等价于 `{ periods: [14] }`
60
+ * (文档与 JSDoc 示例即简写形式,registry.normalizeIndicatorOptions 在入口归一)
61
+ */
62
+ type PeriodsShorthand = number[] | {
63
+ period: number;
64
+ };
65
+ interface IndicatorOptions {
66
+ ma?: MAOptions | PeriodsShorthand | boolean;
67
+ macd?: MACDOptions | boolean;
68
+ boll?: BOLLOptions | boolean;
69
+ kdj?: KDJOptions | boolean;
70
+ rsi?: RSIOptions | PeriodsShorthand | boolean;
71
+ wr?: WROptions | PeriodsShorthand | boolean;
72
+ bias?: BIASOptions | PeriodsShorthand | boolean;
73
+ cci?: CCIOptions | boolean;
74
+ atr?: ATROptions | boolean;
75
+ obv?: OBVOptions | boolean;
76
+ roc?: ROCOptions | boolean;
77
+ dmi?: DMIOptions | boolean;
78
+ sar?: SAROptions | boolean;
79
+ kc?: KCOptions | boolean;
80
+ }
81
+ interface MAResult {
82
+ [key: string]: number | null;
83
+ }
84
+ interface MACDResult {
85
+ dif: number | null;
86
+ dea: number | null;
87
+ macd: number | null;
88
+ }
89
+ interface BOLLResult {
90
+ mid: number | null;
91
+ upper: number | null;
92
+ lower: number | null;
93
+ bandwidth: number | null;
94
+ }
95
+ interface KDJResult {
96
+ k: number | null;
97
+ d: number | null;
98
+ j: number | null;
99
+ }
100
+ interface RSIResult {
101
+ [key: string]: number | null;
102
+ }
103
+ interface WRResult {
104
+ [key: string]: number | null;
105
+ }
106
+ interface BIASResult {
107
+ [key: string]: number | null;
108
+ }
109
+ interface CCIResult {
110
+ cci: number | null;
111
+ }
112
+ interface ATRResult {
113
+ /** 真实波幅 */
114
+ tr: number | null;
115
+ /** 平均真实波幅 */
116
+ atr: number | null;
117
+ }
118
+ interface OBVOptions {
119
+ /** OBV 均线周期 */
120
+ maPeriod?: number;
121
+ }
122
+ interface OBVResult {
123
+ /** OBV 值 */
124
+ obv: number | null;
125
+ /** OBV 均线 */
126
+ obvMa: number | null;
127
+ }
128
+ interface ROCOptions {
129
+ /** ROC 周期,默认 12 */
130
+ period?: number;
131
+ /** 信号线周期 */
132
+ signalPeriod?: number;
133
+ }
134
+ interface ROCResult {
135
+ /** ROC 值(百分比) */
136
+ roc: number | null;
137
+ /** 信号线 */
138
+ signal: number | null;
139
+ }
140
+ interface DMIOptions {
141
+ /** 周期,默认 14 */
142
+ period?: number;
143
+ /** ADX 平滑周期 */
144
+ adxPeriod?: number;
145
+ }
146
+ interface DMIResult {
147
+ /** +DI 值 */
148
+ pdi: number | null;
149
+ /** -DI 值 */
150
+ mdi: number | null;
151
+ /** ADX 值 */
152
+ adx: number | null;
153
+ /** ADXR 值 */
154
+ adxr: number | null;
155
+ }
156
+ interface SAROptions {
157
+ /** 加速因子初始值,默认 0.02 */
158
+ afStart?: number;
159
+ /** 加速因子增量,默认 0.02 */
160
+ afIncrement?: number;
161
+ /** 加速因子最大值,默认 0.2 */
162
+ afMax?: number;
163
+ }
164
+ interface SARResult {
165
+ /** SAR 值 */
166
+ sar: number | null;
167
+ /** 趋势方向:1 上升,-1 下降 */
168
+ trend: 1 | -1 | null;
169
+ /** 极值点 */
170
+ ep: number | null;
171
+ /** 加速因子 */
172
+ af: number | null;
173
+ }
174
+ interface KCOptions {
175
+ /** EMA 周期,默认 20 */
176
+ emaPeriod?: number;
177
+ /** ATR 周期,默认 10 */
178
+ atrPeriod?: number;
179
+ /** ATR 倍数,默认 2 */
180
+ multiplier?: number;
181
+ }
182
+ interface KCResult {
183
+ /** 中轨(EMA) */
184
+ mid: number | null;
185
+ /** 上轨 */
186
+ upper: number | null;
187
+ /** 下轨 */
188
+ lower: number | null;
189
+ /** 通道宽度 */
190
+ width: number | null;
191
+ }
192
+
1
193
  /**
2
194
  * 时间元信息工具
3
195
  *
@@ -8,7 +200,8 @@
8
200
  * - 不引入第三方时区库 (SDK 零依赖),通过 `Intl.DateTimeFormat` 计算时区偏移。
9
201
  * - 兼容多种本地时间字符串格式 (yyyyMMddHHmmss / YYYY-MM-DD HH:mm:ss / YYYY-MM-DD HH:mm /
10
202
  * YYYY-MM-DD / yyyyMMdd / HH:mm 配 baseDate)。
11
- * - 解析失败/输入为空时 `timestamp` `NaN`,调用方可用 `Number.isNaN` 检测。
203
+ * - parseMarketTime 解析失败返回 `NaN`(内部中间值);对外 `TimeMeta.timestamp`
204
+ * 一律经 toNullableEpoch 归一为 `null`,消费方判 `=== null` 即可。
12
205
  */
13
206
  /**
14
207
  * 已支持的市场时区。沿用 IANA 时区名。
@@ -46,6 +239,12 @@ interface TimeMeta {
46
239
  * @param tz 市场时区 (使用 `MARKET_TZ`)
47
240
  */
48
241
  declare function parseMarketTime(local: string, tz: MarketTz): number;
242
+ /**
243
+ * 构造 `TimeMeta`。原始字符串无法解析时 `timestamp` 为 `null`。
244
+ *
245
+ * @param local 市场本地时间字符串
246
+ * @param tz 市场时区
247
+ */
49
248
  declare function buildTimeMeta(local: string, tz: MarketTz): TimeMeta;
50
249
  /**
51
250
  * 将"基础日期 (YYYY-MM-DD) + HH:mm 时间片"组合后构造 `TimeMeta`。
@@ -77,7 +276,7 @@ declare function formatInTz(epoch: number | null, tz: MarketTz): string;
77
276
  interface HistoryKline {
78
277
  /** 日期 YYYY-MM-DD (A 股时区) */
79
278
  date: string;
80
- /** 当日 00:00 (`Asia/Shanghai`) 的 UTC 毫秒时间戳;无法解析时为 `NaN` */
279
+ /** 当日 00:00 (`Asia/Shanghai`) 的 UTC 毫秒时间戳;无法解析时为 `null` */
81
280
  timestamp: number | null;
82
281
  /** 日期所属市场时区 (`Asia/Shanghai`) */
83
282
  tz: MarketTz;
@@ -110,7 +309,7 @@ interface HistoryKline {
110
309
  interface MinuteTimeline {
111
310
  /** 时间 YYYY-MM-DD HH:mm (A 股时区) */
112
311
  time: string;
113
- /** UTC 毫秒时间戳 (`Asia/Shanghai` 解释);无法解析时为 `NaN` */
312
+ /** UTC 毫秒时间戳 (`Asia/Shanghai` 解释);无法解析时为 `null` */
114
313
  timestamp: number | null;
115
314
  /** 时间所属市场时区 (`Asia/Shanghai`) */
116
315
  tz: MarketTz;
@@ -135,7 +334,7 @@ interface MinuteTimeline {
135
334
  interface MinuteKline {
136
335
  /** 时间 YYYY-MM-DD HH:mm (A 股时区) */
137
336
  time: string;
138
- /** UTC 毫秒时间戳 (`Asia/Shanghai` 解释);无法解析时为 `NaN` */
337
+ /** UTC 毫秒时间戳 (`Asia/Shanghai` 解释);无法解析时为 `null` */
139
338
  timestamp: number | null;
140
339
  /** 时间所属市场时区 (`Asia/Shanghai`) */
141
340
  tz: MarketTz;
@@ -168,7 +367,7 @@ interface TodayTimeline {
168
367
  time: string;
169
368
  /**
170
369
  * UTC 毫秒时间戳。由所属 `TodayTimelineResponse.date` 与 `time` 拼接后,
171
- * 按 `Asia/Shanghai` 解释得到;无法解析时为 `NaN`。
370
+ * 按 `Asia/Shanghai` 解释得到;无法解析时为 `null`。
172
371
  */
173
372
  timestamp: number | null;
174
373
  /** 时间所属市场时区 (`Asia/Shanghai`) */
@@ -190,7 +389,7 @@ interface TodayTimelineResponse {
190
389
  code: string;
191
390
  /** 交易日期 YYYY-MM-DD (A 股时区) */
192
391
  date: string;
193
- /** 交易日 00:00 (`Asia/Shanghai`) 的 UTC 毫秒时间戳;无法解析时为 `NaN` */
392
+ /** 交易日 00:00 (`Asia/Shanghai`) 的 UTC 毫秒时间戳;无法解析时为 `null` */
194
393
  timestamp: number | null;
195
394
  /** 日期所属市场时区 (`Asia/Shanghai`) */
196
395
  tz: MarketTz;
@@ -212,7 +411,7 @@ interface TodayTimelineResponse {
212
411
  interface ForeignHistoryKlineBase {
213
412
  /** 日期 YYYY-MM-DD (市场本地时区) */
214
413
  date: string;
215
- /** UTC 毫秒时间戳;无法解析时为 `NaN` */
414
+ /** UTC 毫秒时间戳;无法解析时为 `null` */
216
415
  timestamp: number | null;
217
416
  /** 股票代码 */
218
417
  code: string;
@@ -314,189 +513,6 @@ interface USMinuteTimeline extends Omit<MinuteTimeline, 'tz'> {
314
513
  code: string;
315
514
  }
316
515
 
317
- interface OHLCV {
318
- open: number | null;
319
- high: number | null;
320
- low: number | null;
321
- close: number | null;
322
- volume?: number | null;
323
- }
324
- interface MAOptions {
325
- /** 均线周期数组,默认 [5, 10, 20, 30, 60, 120, 250] */
326
- periods?: number[];
327
- /** 均线类型:'sma'(简单) | 'ema'(指数) | 'wma'(加权),默认 'sma' */
328
- type?: 'sma' | 'ema' | 'wma';
329
- }
330
- interface MACDOptions {
331
- /** 短期 EMA 周期,默认 12 */
332
- short?: number;
333
- /** 长期 EMA 周期,默认 26 */
334
- long?: number;
335
- /** 信号线 EMA 周期,默认 9 */
336
- signal?: number;
337
- }
338
- interface BOLLOptions {
339
- /** 均线周期,默认 20 */
340
- period?: number;
341
- /** 标准差倍数,默认 2 */
342
- stdDev?: number;
343
- }
344
- interface KDJOptions {
345
- /** RSV 周期,默认 9 */
346
- period?: number;
347
- /** K 值平滑周期,默认 3 */
348
- kPeriod?: number;
349
- /** D 值平滑周期,默认 3 */
350
- dPeriod?: number;
351
- }
352
- interface RSIOptions {
353
- /** RSI 周期数组,默认 [6, 12, 24] */
354
- periods?: number[];
355
- }
356
- interface WROptions {
357
- /** WR 周期数组,默认 [6, 10] */
358
- periods?: number[];
359
- }
360
- interface BIASOptions {
361
- /** BIAS 周期数组,默认 [6, 12, 24] */
362
- periods?: number[];
363
- }
364
- interface CCIOptions {
365
- /** CCI 周期,默认 14 */
366
- period?: number;
367
- }
368
- interface ATROptions {
369
- /** ATR 周期,默认 14 */
370
- period?: number;
371
- }
372
- interface IndicatorOptions {
373
- ma?: MAOptions | boolean;
374
- macd?: MACDOptions | boolean;
375
- boll?: BOLLOptions | boolean;
376
- kdj?: KDJOptions | boolean;
377
- rsi?: RSIOptions | boolean;
378
- wr?: WROptions | boolean;
379
- bias?: BIASOptions | boolean;
380
- cci?: CCIOptions | boolean;
381
- atr?: ATROptions | boolean;
382
- obv?: OBVOptions | boolean;
383
- roc?: ROCOptions | boolean;
384
- dmi?: DMIOptions | boolean;
385
- sar?: SAROptions | boolean;
386
- kc?: KCOptions | boolean;
387
- }
388
- interface MAResult {
389
- [key: string]: number | null;
390
- }
391
- interface MACDResult {
392
- dif: number | null;
393
- dea: number | null;
394
- macd: number | null;
395
- }
396
- interface BOLLResult {
397
- mid: number | null;
398
- upper: number | null;
399
- lower: number | null;
400
- bandwidth: number | null;
401
- }
402
- interface KDJResult {
403
- k: number | null;
404
- d: number | null;
405
- j: number | null;
406
- }
407
- interface RSIResult {
408
- [key: string]: number | null;
409
- }
410
- interface WRResult {
411
- [key: string]: number | null;
412
- }
413
- interface BIASResult {
414
- [key: string]: number | null;
415
- }
416
- interface CCIResult {
417
- cci: number | null;
418
- }
419
- interface ATRResult {
420
- /** 真实波幅 */
421
- tr: number | null;
422
- /** 平均真实波幅 */
423
- atr: number | null;
424
- }
425
- interface OBVOptions {
426
- /** OBV 均线周期 */
427
- maPeriod?: number;
428
- }
429
- interface OBVResult {
430
- /** OBV 值 */
431
- obv: number | null;
432
- /** OBV 均线 */
433
- obvMa: number | null;
434
- }
435
- interface ROCOptions {
436
- /** ROC 周期,默认 12 */
437
- period?: number;
438
- /** 信号线周期 */
439
- signalPeriod?: number;
440
- }
441
- interface ROCResult {
442
- /** ROC 值(百分比) */
443
- roc: number | null;
444
- /** 信号线 */
445
- signal: number | null;
446
- }
447
- interface DMIOptions {
448
- /** 周期,默认 14 */
449
- period?: number;
450
- /** ADX 平滑周期 */
451
- adxPeriod?: number;
452
- }
453
- interface DMIResult {
454
- /** +DI 值 */
455
- pdi: number | null;
456
- /** -DI 值 */
457
- mdi: number | null;
458
- /** ADX 值 */
459
- adx: number | null;
460
- /** ADXR 值 */
461
- adxr: number | null;
462
- }
463
- interface SAROptions {
464
- /** 加速因子初始值,默认 0.02 */
465
- afStart?: number;
466
- /** 加速因子增量,默认 0.02 */
467
- afIncrement?: number;
468
- /** 加速因子最大值,默认 0.2 */
469
- afMax?: number;
470
- }
471
- interface SARResult {
472
- /** SAR 值 */
473
- sar: number | null;
474
- /** 趋势方向:1 上升,-1 下降 */
475
- trend: 1 | -1 | null;
476
- /** 极值点 */
477
- ep: number | null;
478
- /** 加速因子 */
479
- af: number | null;
480
- }
481
- interface KCOptions {
482
- /** EMA 周期,默认 20 */
483
- emaPeriod?: number;
484
- /** ATR 周期,默认 10 */
485
- atrPeriod?: number;
486
- /** ATR 倍数,默认 2 */
487
- multiplier?: number;
488
- }
489
- interface KCResult {
490
- /** 中轨(EMA) */
491
- mid: number | null;
492
- /** 上轨 */
493
- upper: number | null;
494
- /** 下轨 */
495
- lower: number | null;
496
- /** 通道宽度 */
497
- width: number | null;
498
- }
499
-
500
516
  /**
501
517
  * 带技术指标的 K 线数据
502
518
  */
@@ -521,4 +537,4 @@ type KlineWithIndicators<T extends AnyHistoryKline> = T & {
521
537
  */
522
538
  declare function addIndicators<T extends AnyHistoryKline>(klines: T[], options?: IndicatorOptions): KlineWithIndicators<T>[];
523
539
 
524
- export { type AnyHistoryKline as A, type BOLLOptions as B, type CCIOptions as C, type DMIOptions as D, type USMinuteTimeline as E, type MAResult as F, type MACDResult as G, type HistoryKline as H, type IndicatorOptions as I, type BOLLResult as J, type KlineWithIndicators as K, type OHLCV as L, type MAOptions as M, type KDJResult as N, type OBVOptions as O, type RSIResult as P, type WRResult as Q, type RSIOptions as R, type SAROptions as S, type TimeMeta as T, type USHistoryKline as U, type BIASResult as V, type WROptions as W, type CCIResult as X, type ATRResult as Y, addIndicators as a, type MACDOptions as b, type KDJOptions as c, type BIASOptions as d, type ATROptions as e, type OBVResult as f, type ROCOptions as g, type ROCResult as h, type DMIResult as i, type SARResult as j, type KCOptions as k, type KCResult as l, MARKET_TZ as m, type MarketTz as n, buildTimeMeta as o, parseMarketTime as p, buildTimeMetaFromDateAndTime as q, formatInTz as r, type MinuteTimeline as s, type MinuteKline as t, type TodayTimeline as u, type TodayTimelineResponse as v, type HKHistoryKline as w, type HKMinuteKline as x, type HKMinuteTimeline as y, type USMinuteKline as z };
540
+ export { type AnyHistoryKline as A, type BOLLOptions as B, type CCIOptions as C, type DMIOptions as D, type USMinuteTimeline as E, type MAResult as F, type MACDResult as G, type HistoryKline as H, type IndicatorOptions as I, type BOLLResult as J, type KlineWithIndicators as K, type OHLCV as L, type MAOptions as M, type KDJResult as N, type OBVOptions as O, type RSIResult as P, type WRResult as Q, type RSIOptions as R, type SAROptions as S, type TimeMeta as T, type USHistoryKline as U, type BIASResult as V, type WROptions as W, type CCIResult as X, type ATRResult as Y, type PeriodsShorthand as Z, addIndicators as a, type MACDOptions as b, type KDJOptions as c, type BIASOptions as d, type ATROptions as e, type OBVResult as f, type ROCOptions as g, type ROCResult as h, type DMIResult as i, type SARResult as j, type KCOptions as k, type KCResult as l, MARKET_TZ as m, type MarketTz as n, buildTimeMeta as o, parseMarketTime as p, buildTimeMetaFromDateAndTime as q, formatInTz as r, type MinuteTimeline as s, type MinuteKline as t, type TodayTimeline as u, type TodayTimelineResponse as v, type HKHistoryKline as w, type HKMinuteKline as x, type HKMinuteTimeline as y, type USMinuteKline as z };