kline-charts-react 0.0.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.
- package/LICENSE +21 -0
- package/README.md +388 -0
- package/dist/KLineChart.d.ts +5 -0
- package/dist/components/IndicatorDisplay/IndicatorDisplay.d.ts +12 -0
- package/dist/components/IndicatorDisplay/index.d.ts +1 -0
- package/dist/components/IndicatorSelector/IndicatorSelector.d.ts +12 -0
- package/dist/components/IndicatorSelector/index.d.ts +1 -0
- package/dist/components/Loading/Loading.d.ts +8 -0
- package/dist/components/Loading/index.d.ts +1 -0
- package/dist/components/MADisplay/MADisplay.d.ts +10 -0
- package/dist/components/MADisplay/index.d.ts +1 -0
- package/dist/components/PeriodSelector/PeriodSelector.d.ts +10 -0
- package/dist/components/PeriodSelector/index.d.ts +1 -0
- package/dist/components/SubPaneTitle/SubPaneTitle.d.ts +13 -0
- package/dist/components/SubPaneTitle/index.d.ts +1 -0
- package/dist/components/Toolbar/Toolbar.d.ts +20 -0
- package/dist/components/Toolbar/index.d.ts +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useEcharts.d.ts +26 -0
- package/dist/hooks/useKlineData.d.ts +24 -0
- package/dist/hooks/useZoomHistory.d.ts +18 -0
- package/dist/index.cjs +51 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +26563 -0
- package/dist/index.umd.js +51 -0
- package/dist/kline-charts-react.css +1 -0
- package/dist/types/data.d.ts +207 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/props.d.ts +279 -0
- package/dist/types/theme.d.ts +47 -0
- package/dist/utils/cache.d.ts +56 -0
- package/dist/utils/formatters.d.ts +115 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/indicators.d.ts +109 -0
- package/dist/utils/optionBuilder.d.ts +32 -0
- package/dist/utils/timelineBuilder.d.ts +11 -0
- package/package.json +95 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_119o2_1{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:200px;gap:12px}._spinner_119o2_11{display:flex;gap:6px}._dot_119o2_16{width:8px;height:8px;background-color:#1890ff;border-radius:50%;animation:_bounce_119o2_1 .6s infinite alternate}._dot_119o2_16:nth-child(2){animation-delay:.2s}._dot_119o2_16:nth-child(3){animation-delay:.4s}@keyframes _bounce_119o2_1{0%{transform:translateY(0);opacity:.4}to{transform:translateY(-10px);opacity:1}}._text_119o2_43{color:#999;font-size:13px}._container_1xu4v_1{display:flex;align-items:center;gap:16px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff)}._group_1xu4v_10{display:flex;gap:4px}._button_1xu4v_15{padding:4px 10px;font-size:13px;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._button_1xu4v_15:hover{background:var(--kline-hover-bg, #f5f5f5)}._button_1xu4v_15._active_1xu4v_30{color:#fff;background:var(--kline-active-color, #1890ff)}._container_1fbmi_1{display:flex;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid var(--kline-border-color, #e8e8e8);background:var(--kline-bg-color, #fff);flex-wrap:wrap}._button_1fbmi_11{padding:4px 12px;font-size:12px;color:var(--kline-text-secondary, #666);background:var(--kline-tag-bg, #f0f0f0);border:1px solid transparent;border-radius:4px;cursor:pointer;transition:all .2s}._button_1fbmi_11:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._button_1fbmi_11._active_1fbmi_27{color:var(--kline-active-color, #1890ff);background:#1890ff1a;border-color:var(--kline-active-color, #1890ff)}._divider_1fbmi_33{width:1px;height:20px;background:var(--kline-border-color, #e8e8e8);margin:0 4px}._container_2tswg_1{display:flex;align-items:center;gap:4px;padding:6px 12px;background:var(--kline-bg-color, #fff);border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._group_2tswg_10{display:flex;align-items:center;gap:2px}._divider_2tswg_16{width:1px;height:16px;margin:0 8px;background:var(--kline-border-color, #e8e8e8)}._spacer_2tswg_23{flex:1}._iconButton_2tswg_27{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;color:var(--kline-text-color, #333);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._iconButton_2tswg_27:hover:not(:disabled){background:var(--kline-hover-bg, #f5f5f5)}._iconButton_2tswg_27:disabled{color:var(--kline-text-disabled, #ccc);cursor:not-allowed}._textButton_2tswg_51{padding:4px 8px;font-size:12px;color:var(--kline-text-secondary, #666);background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .2s}._textButton_2tswg_51:hover{background:var(--kline-hover-bg, #f5f5f5);color:var(--kline-text-color, #333)}._textButton_2tswg_51._active_2tswg_67{color:var(--kline-active-color, #1890ff);background:#1890ff1a}._container_1vdme_1{display:flex;align-items:center;gap:16px;padding:4px 8px;font-size:12px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;flex-wrap:wrap}._group_1vdme_11{display:flex;align-items:center;gap:12px;flex-wrap:wrap}._item_1vdme_18{font-weight:500;white-space:nowrap}._title_p093j_1{position:absolute;left:8px;z-index:10;display:flex;align-items:center;gap:8px;font-size:11px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;pointer-events:none;background:var(--kline-bg-color, rgba(255, 255, 255, .9));padding:2px 6px;border-radius:2px}._label_p093j_16{font-weight:600;color:var(--kline-text-color, #333)}._value_p093j_21{color:var(--kline-text-secondary, #666)}._container_o8wlo_1{display:flex;flex-direction:column;background:var(--kline-bg-color, #fff);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}._fullscreen_o8wlo_12{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;border-radius:0;border:none}._chartWrapper_o8wlo_23{flex:1;position:relative;min-height:200px}._chart_o8wlo_23{width:100%;height:100%}._error_o8wlo_34{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--kline-text-secondary, #999);font-size:14px}._error_o8wlo_34 button{padding:6px 16px;font-size:13px;color:#fff;background:var(--kline-active-color, #1890ff);border:none;border-radius:4px;cursor:pointer;transition:opacity .2s}._error_o8wlo_34 button:hover{opacity:.85}._timelineToolbar_o8wlo_63{display:flex;align-items:center;gap:12px;padding:8px 12px;border-bottom:1px solid var(--kline-border-color, #e8e8e8)}._timelineLabel_o8wlo_71{font-size:14px;font-weight:500;color:var(--kline-text-color, #333)}._refreshButton_o8wlo_77,._fullscreenButton_o8wlo_78{padding:4px 12px;font-size:12px;color:var(--kline-text-color, #333);background:var(--kline-tag-bg, #f0f0f0);border:1px solid var(--kline-border-color, #e8e8e8);border-radius:4px;cursor:pointer;transition:all .2s}._refreshButton_o8wlo_77:hover,._fullscreenButton_o8wlo_78:hover{background:var(--kline-hover-bg, #f5f5f5)}._refreshButton_o8wlo_77:disabled{opacity:.5;cursor:not-allowed}._refreshButton_o8wlo_77:not(:disabled):hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}._fullscreenButton_o8wlo_78:hover{border-color:var(--kline-active-color, #1890ff);color:var(--kline-active-color, #1890ff)}:root{--kline-bg-color: #ffffff;--kline-text-color: #333333;--kline-text-secondary: #999999;--kline-border-color: #e8e8e8;--kline-active-color: #1890ff;--kline-hover-bg: #f5f5f5;--kline-tag-bg: #f0f0f0;--kline-text-disabled: #cccccc;--kline-up-color: #f5222d;--kline-down-color: #52c41a}.kline-dark{--kline-bg-color: #1a1a1a;--kline-text-color: #d1d1d1;--kline-text-secondary: #666666;--kline-border-color: #333333;--kline-hover-bg: #2a2a2a;--kline-tag-bg: #2a2a2a;--kline-text-disabled: #444444}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K 线数据结构
|
|
3
|
+
*/
|
|
4
|
+
export interface KlineData {
|
|
5
|
+
/** 日期/时间 */
|
|
6
|
+
date: string;
|
|
7
|
+
/** 股票代码 */
|
|
8
|
+
code?: string;
|
|
9
|
+
/** 股票名称 */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** 开盘价 */
|
|
12
|
+
open: number | null;
|
|
13
|
+
/** 收盘价 */
|
|
14
|
+
close: number | null;
|
|
15
|
+
/** 最高价 */
|
|
16
|
+
high: number | null;
|
|
17
|
+
/** 最低价 */
|
|
18
|
+
low: number | null;
|
|
19
|
+
/** 成交量 */
|
|
20
|
+
volume: number | null;
|
|
21
|
+
/** 成交额 */
|
|
22
|
+
amount: number | null;
|
|
23
|
+
/** 涨跌幅 */
|
|
24
|
+
changePercent?: number | null;
|
|
25
|
+
/** 涨跌额 */
|
|
26
|
+
change?: number | null;
|
|
27
|
+
/** 振幅 */
|
|
28
|
+
amplitude?: number | null;
|
|
29
|
+
/** 换手率 */
|
|
30
|
+
turnoverRate?: number | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 分时数据结构
|
|
34
|
+
*/
|
|
35
|
+
export interface TimelineData {
|
|
36
|
+
/** 时间 HH:mm */
|
|
37
|
+
time: string;
|
|
38
|
+
/** 价格 */
|
|
39
|
+
price: number;
|
|
40
|
+
/** 成交量(累计) */
|
|
41
|
+
volume: number;
|
|
42
|
+
/** 成交额(累计) */
|
|
43
|
+
amount: number;
|
|
44
|
+
/** 均价 */
|
|
45
|
+
avgPrice: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 带指标的 K 线数据
|
|
49
|
+
*/
|
|
50
|
+
export interface KlineWithIndicators extends KlineData {
|
|
51
|
+
/** MA 指标 */
|
|
52
|
+
ma?: MAResult;
|
|
53
|
+
/** MACD 指标 */
|
|
54
|
+
macd?: MACDResult;
|
|
55
|
+
/** BOLL 指标 */
|
|
56
|
+
boll?: BOLLResult;
|
|
57
|
+
/** KDJ 指标 */
|
|
58
|
+
kdj?: KDJResult;
|
|
59
|
+
/** RSI 指标 */
|
|
60
|
+
rsi?: RSIResult;
|
|
61
|
+
/** WR 指标 */
|
|
62
|
+
wr?: WRResult;
|
|
63
|
+
/** BIAS 指标 */
|
|
64
|
+
bias?: BIASResult;
|
|
65
|
+
/** CCI 指标 */
|
|
66
|
+
cci?: CCIResult;
|
|
67
|
+
/** ATR 指标 */
|
|
68
|
+
atr?: ATRResult;
|
|
69
|
+
/** OBV 指标(能量潮) */
|
|
70
|
+
obv?: OBVResult;
|
|
71
|
+
/** ROC 指标(变动率) */
|
|
72
|
+
roc?: ROCResult;
|
|
73
|
+
/** DMI 指标(趋向指标) */
|
|
74
|
+
dmi?: DMIResult;
|
|
75
|
+
/** SAR 指标(抛物线转向) */
|
|
76
|
+
sar?: SARResult;
|
|
77
|
+
/** KC 指标(肯特纳通道) */
|
|
78
|
+
kc?: KCResult;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* MA 指标结果
|
|
82
|
+
*/
|
|
83
|
+
export interface MAResult {
|
|
84
|
+
ma5?: number | null;
|
|
85
|
+
ma10?: number | null;
|
|
86
|
+
ma20?: number | null;
|
|
87
|
+
ma30?: number | null;
|
|
88
|
+
ma60?: number | null;
|
|
89
|
+
ma120?: number | null;
|
|
90
|
+
ma250?: number | null;
|
|
91
|
+
[key: string]: number | null | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* MACD 指标结果
|
|
95
|
+
*/
|
|
96
|
+
export interface MACDResult {
|
|
97
|
+
dif: number | null;
|
|
98
|
+
dea: number | null;
|
|
99
|
+
macd: number | null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* BOLL 指标结果
|
|
103
|
+
*/
|
|
104
|
+
export interface BOLLResult {
|
|
105
|
+
mid: number | null;
|
|
106
|
+
upper: number | null;
|
|
107
|
+
lower: number | null;
|
|
108
|
+
bandwidth?: number | null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* KDJ 指标结果
|
|
112
|
+
*/
|
|
113
|
+
export interface KDJResult {
|
|
114
|
+
k: number | null;
|
|
115
|
+
d: number | null;
|
|
116
|
+
j: number | null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* RSI 指标结果
|
|
120
|
+
*/
|
|
121
|
+
export interface RSIResult {
|
|
122
|
+
rsi6?: number | null;
|
|
123
|
+
rsi12?: number | null;
|
|
124
|
+
rsi24?: number | null;
|
|
125
|
+
[key: string]: number | null | undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* WR 指标结果
|
|
129
|
+
*/
|
|
130
|
+
export interface WRResult {
|
|
131
|
+
wr6?: number | null;
|
|
132
|
+
wr10?: number | null;
|
|
133
|
+
[key: string]: number | null | undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* BIAS 指标结果
|
|
137
|
+
*/
|
|
138
|
+
export interface BIASResult {
|
|
139
|
+
bias6?: number | null;
|
|
140
|
+
bias12?: number | null;
|
|
141
|
+
bias24?: number | null;
|
|
142
|
+
[key: string]: number | null | undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* CCI 指标结果
|
|
146
|
+
*/
|
|
147
|
+
export interface CCIResult {
|
|
148
|
+
cci: number | null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* ATR 指标结果
|
|
152
|
+
*/
|
|
153
|
+
export interface ATRResult {
|
|
154
|
+
tr?: number | null;
|
|
155
|
+
atr: number | null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* OBV 指标结果(能量潮)
|
|
159
|
+
*/
|
|
160
|
+
export interface OBVResult {
|
|
161
|
+
obv: number | null;
|
|
162
|
+
obvMa: number | null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* ROC 指标结果(变动率)
|
|
166
|
+
*/
|
|
167
|
+
export interface ROCResult {
|
|
168
|
+
roc: number | null;
|
|
169
|
+
signal: number | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* DMI 指标结果(趋向指标)
|
|
173
|
+
*/
|
|
174
|
+
export interface DMIResult {
|
|
175
|
+
pdi: number | null;
|
|
176
|
+
mdi: number | null;
|
|
177
|
+
adx: number | null;
|
|
178
|
+
adxr: number | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* SAR 指标结果(抛物线转向)
|
|
182
|
+
*/
|
|
183
|
+
export interface SARResult {
|
|
184
|
+
sar: number | null;
|
|
185
|
+
trend: 1 | -1 | null;
|
|
186
|
+
ep: number | null;
|
|
187
|
+
af: number | null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* KC 指标结果(肯特纳通道)
|
|
191
|
+
*/
|
|
192
|
+
export interface KCResult {
|
|
193
|
+
mid: number | null;
|
|
194
|
+
upper: number | null;
|
|
195
|
+
lower: number | null;
|
|
196
|
+
width: number | null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* OHLCV 数据(用于指标计算)
|
|
200
|
+
*/
|
|
201
|
+
export interface OHLCV {
|
|
202
|
+
open: number | null;
|
|
203
|
+
high: number | null;
|
|
204
|
+
low: number | null;
|
|
205
|
+
close: number | null;
|
|
206
|
+
volume?: number | null;
|
|
207
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { EChartsOption } from 'echarts';
|
|
3
|
+
import { KlineData, TimelineData } from './data';
|
|
4
|
+
import { ThemeConfig } from './theme';
|
|
5
|
+
/**
|
|
6
|
+
* 周期类型
|
|
7
|
+
*/
|
|
8
|
+
export type PeriodType = 'timeline' | 'timeline5' | '1' | '5' | '15' | '30' | '60' | 'daily' | 'weekly' | 'monthly';
|
|
9
|
+
/**
|
|
10
|
+
* 市场类型
|
|
11
|
+
*/
|
|
12
|
+
export type MarketType = 'A' | 'HK' | 'US';
|
|
13
|
+
/**
|
|
14
|
+
* 复权类型
|
|
15
|
+
*/
|
|
16
|
+
export type AdjustType = '' | 'qfq' | 'hfq';
|
|
17
|
+
/**
|
|
18
|
+
* 指标类型
|
|
19
|
+
*/
|
|
20
|
+
export type IndicatorType = 'ma' | 'macd' | 'boll' | 'kdj' | 'rsi' | 'wr' | 'bias' | 'cci' | 'atr' | 'obv' | 'roc' | 'dmi' | 'sar' | 'kc' | 'volume';
|
|
21
|
+
/**
|
|
22
|
+
* MA 指标配置
|
|
23
|
+
*/
|
|
24
|
+
export interface MAOptions {
|
|
25
|
+
periods?: number[];
|
|
26
|
+
type?: 'sma' | 'ema' | 'wma';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* MACD 指标配置
|
|
30
|
+
*/
|
|
31
|
+
export interface MACDOptions {
|
|
32
|
+
short?: number;
|
|
33
|
+
long?: number;
|
|
34
|
+
signal?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* BOLL 指标配置
|
|
38
|
+
*/
|
|
39
|
+
export interface BOLLOptions {
|
|
40
|
+
period?: number;
|
|
41
|
+
stdDev?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* KDJ 指标配置
|
|
45
|
+
*/
|
|
46
|
+
export interface KDJOptions {
|
|
47
|
+
period?: number;
|
|
48
|
+
kPeriod?: number;
|
|
49
|
+
dPeriod?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* RSI 指标配置
|
|
53
|
+
*/
|
|
54
|
+
export interface RSIOptions {
|
|
55
|
+
periods?: number[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* WR 指标配置
|
|
59
|
+
*/
|
|
60
|
+
export interface WROptions {
|
|
61
|
+
periods?: number[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* BIAS 指标配置
|
|
65
|
+
*/
|
|
66
|
+
export interface BIASOptions {
|
|
67
|
+
periods?: number[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* CCI 指标配置
|
|
71
|
+
*/
|
|
72
|
+
export interface CCIOptions {
|
|
73
|
+
period?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* ATR 指标配置
|
|
77
|
+
*/
|
|
78
|
+
export interface ATROptions {
|
|
79
|
+
period?: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* OBV 指标配置(能量潮)
|
|
83
|
+
*/
|
|
84
|
+
export interface OBVOptions {
|
|
85
|
+
maPeriod?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* ROC 指标配置(变动率)
|
|
89
|
+
*/
|
|
90
|
+
export interface ROCOptions {
|
|
91
|
+
period?: number;
|
|
92
|
+
signalPeriod?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* DMI 指标配置(趋向指标)
|
|
96
|
+
*/
|
|
97
|
+
export interface DMIOptions {
|
|
98
|
+
period?: number;
|
|
99
|
+
adxPeriod?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* SAR 指标配置(抛物线转向)
|
|
103
|
+
*/
|
|
104
|
+
export interface SAROptions {
|
|
105
|
+
afStart?: number;
|
|
106
|
+
afIncrement?: number;
|
|
107
|
+
afMax?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* KC 指标配置(肯特纳通道)
|
|
111
|
+
*/
|
|
112
|
+
export interface KCOptions {
|
|
113
|
+
emaPeriod?: number;
|
|
114
|
+
atrPeriod?: number;
|
|
115
|
+
multiplier?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 指标参数配置
|
|
119
|
+
*/
|
|
120
|
+
export interface IndicatorOptions {
|
|
121
|
+
ma?: MAOptions | boolean;
|
|
122
|
+
macd?: MACDOptions | boolean;
|
|
123
|
+
boll?: BOLLOptions | boolean;
|
|
124
|
+
kdj?: KDJOptions | boolean;
|
|
125
|
+
rsi?: RSIOptions | boolean;
|
|
126
|
+
wr?: WROptions | boolean;
|
|
127
|
+
bias?: BIASOptions | boolean;
|
|
128
|
+
cci?: CCIOptions | boolean;
|
|
129
|
+
atr?: ATROptions | boolean;
|
|
130
|
+
obv?: OBVOptions | boolean;
|
|
131
|
+
roc?: ROCOptions | boolean;
|
|
132
|
+
dmi?: DMIOptions | boolean;
|
|
133
|
+
sar?: SAROptions | boolean;
|
|
134
|
+
kc?: KCOptions | boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 获取 K 线数据参数
|
|
138
|
+
*/
|
|
139
|
+
export interface GetKlineParams {
|
|
140
|
+
symbol: string;
|
|
141
|
+
market: MarketType;
|
|
142
|
+
period: PeriodType;
|
|
143
|
+
adjust: AdjustType;
|
|
144
|
+
cursor?: string | number;
|
|
145
|
+
limit?: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 获取分时数据参数
|
|
149
|
+
*/
|
|
150
|
+
export interface GetTimelineParams {
|
|
151
|
+
symbol: string;
|
|
152
|
+
market: MarketType;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 数据源提供者
|
|
156
|
+
*/
|
|
157
|
+
export interface KLineDataProvider {
|
|
158
|
+
getKline: (params: GetKlineParams, signal?: AbortSignal) => Promise<KlineData[]>;
|
|
159
|
+
getTimeline?: (params: GetTimelineParams, signal?: AbortSignal) => Promise<TimelineData[]>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 请求配置
|
|
163
|
+
*/
|
|
164
|
+
export interface RequestOptions {
|
|
165
|
+
debounceMs?: number;
|
|
166
|
+
abortOnChange?: boolean;
|
|
167
|
+
dedupe?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 自动刷新配置
|
|
171
|
+
*/
|
|
172
|
+
export interface AutoRefreshOptions {
|
|
173
|
+
intervalMs?: number;
|
|
174
|
+
onlyTradingTime?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* 时间轴配置
|
|
178
|
+
*/
|
|
179
|
+
export type TimeAxisOptions = {
|
|
180
|
+
mode: 'trading';
|
|
181
|
+
sessionCompression?: boolean;
|
|
182
|
+
} | {
|
|
183
|
+
mode: 'continuous';
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* ECharts Option 合并配置
|
|
187
|
+
*/
|
|
188
|
+
export interface EChartsOptionMergeOptions {
|
|
189
|
+
mode?: 'safeMerge' | 'replace';
|
|
190
|
+
replaceMerge?: string[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 面板配置
|
|
194
|
+
*/
|
|
195
|
+
export interface PaneConfig {
|
|
196
|
+
id: string;
|
|
197
|
+
height?: number | string;
|
|
198
|
+
indicators: IndicatorType[];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* SDK 配置
|
|
202
|
+
*/
|
|
203
|
+
export interface SDKOptions {
|
|
204
|
+
baseUrl?: string;
|
|
205
|
+
timeout?: number;
|
|
206
|
+
headers?: Record<string, string>;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* KLineChart 组件 Props
|
|
210
|
+
*/
|
|
211
|
+
export interface KLineChartProps {
|
|
212
|
+
/** 股票代码(必填) */
|
|
213
|
+
symbol: string;
|
|
214
|
+
/** 市场类型 */
|
|
215
|
+
market?: MarketType;
|
|
216
|
+
/** K 线周期 */
|
|
217
|
+
period?: PeriodType;
|
|
218
|
+
/** 复权类型 */
|
|
219
|
+
adjust?: AdjustType;
|
|
220
|
+
/** 图表高度 */
|
|
221
|
+
height?: number | string;
|
|
222
|
+
/** 图表宽度 */
|
|
223
|
+
width?: number | string;
|
|
224
|
+
/** 主题 */
|
|
225
|
+
theme?: 'light' | 'dark' | ThemeConfig;
|
|
226
|
+
/** 启用的技术指标 */
|
|
227
|
+
indicators?: IndicatorType[];
|
|
228
|
+
/** 指标参数配置 */
|
|
229
|
+
indicatorOptions?: IndicatorOptions;
|
|
230
|
+
/** 是否显示工具栏 */
|
|
231
|
+
showToolbar?: boolean;
|
|
232
|
+
/** 是否显示周期切换 */
|
|
233
|
+
showPeriodSelector?: boolean;
|
|
234
|
+
/** 是否显示指标切换 */
|
|
235
|
+
showIndicatorSelector?: boolean;
|
|
236
|
+
/** 最多显示几个副图,默认 3,最大 3,传入 0 表示不显示副图 */
|
|
237
|
+
maxSubPanes?: number;
|
|
238
|
+
/** 初始可见 K 线数量 */
|
|
239
|
+
visibleCount?: number;
|
|
240
|
+
/** 数据加载回调 */
|
|
241
|
+
onDataLoad?: (data: KlineData[]) => void;
|
|
242
|
+
/** 周期切换回调 */
|
|
243
|
+
onPeriodChange?: (period: PeriodType) => void;
|
|
244
|
+
/** 错误回调 */
|
|
245
|
+
onError?: (error: Error) => void;
|
|
246
|
+
/** 数据源提供者 */
|
|
247
|
+
dataProvider?: KLineDataProvider;
|
|
248
|
+
/** stock-sdk 配置 */
|
|
249
|
+
sdkOptions?: SDKOptions;
|
|
250
|
+
/** 请求配置 */
|
|
251
|
+
requestOptions?: RequestOptions;
|
|
252
|
+
/** 自动刷新配置 */
|
|
253
|
+
autoRefresh?: boolean | AutoRefreshOptions;
|
|
254
|
+
/** 时间轴配置 */
|
|
255
|
+
timeAxis?: TimeAxisOptions;
|
|
256
|
+
/** 自定义 ECharts 配置 */
|
|
257
|
+
echartsOption?: EChartsOption;
|
|
258
|
+
/** ECharts Option 合并策略 */
|
|
259
|
+
echartsOptionMerge?: EChartsOptionMergeOptions;
|
|
260
|
+
/** 面板配置 */
|
|
261
|
+
panes?: PaneConfig[];
|
|
262
|
+
/** 类名 */
|
|
263
|
+
className?: string;
|
|
264
|
+
/** 样式 */
|
|
265
|
+
style?: CSSProperties;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* KLineChart Ref 方法
|
|
269
|
+
*/
|
|
270
|
+
export interface KLineChartRef {
|
|
271
|
+
refresh(): Promise<void>;
|
|
272
|
+
setPeriod(period: PeriodType): void;
|
|
273
|
+
setIndicators(indicators: IndicatorType[]): void;
|
|
274
|
+
zoomTo(start: number, end: number): void;
|
|
275
|
+
resetZoom(): void;
|
|
276
|
+
getEchartsInstance(): unknown | null;
|
|
277
|
+
exportImage(type?: 'png' | 'jpeg'): string;
|
|
278
|
+
getData(): KlineData[];
|
|
279
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题配置
|
|
3
|
+
*/
|
|
4
|
+
export interface ThemeConfig {
|
|
5
|
+
/** 背景色 */
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
/** 文字颜色 */
|
|
8
|
+
textColor: string;
|
|
9
|
+
/** 次要文字颜色 */
|
|
10
|
+
textColorSecondary: string;
|
|
11
|
+
/** 网格线颜色 */
|
|
12
|
+
gridLineColor: string;
|
|
13
|
+
/** 上涨颜色 */
|
|
14
|
+
upColor: string;
|
|
15
|
+
/** 下跌颜色 */
|
|
16
|
+
downColor: string;
|
|
17
|
+
/** 均线颜色(按周期顺序) */
|
|
18
|
+
maColors: string[];
|
|
19
|
+
/** 成交量上涨颜色 */
|
|
20
|
+
volumeUpColor: string;
|
|
21
|
+
/** 成交量下跌颜色 */
|
|
22
|
+
volumeDownColor: string;
|
|
23
|
+
/** 十字准线颜色 */
|
|
24
|
+
crosshairColor: string;
|
|
25
|
+
/** Tooltip 背景色 */
|
|
26
|
+
tooltipBgColor: string;
|
|
27
|
+
/** Tooltip 边框颜色 */
|
|
28
|
+
tooltipBorderColor: string;
|
|
29
|
+
/** 分割线颜色 */
|
|
30
|
+
splitLineColor: string;
|
|
31
|
+
/** 区域填充颜色(分时图下方) */
|
|
32
|
+
areaColor: string;
|
|
33
|
+
/** 选中高亮色 */
|
|
34
|
+
activeColor: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 浅色主题
|
|
38
|
+
*/
|
|
39
|
+
export declare const lightTheme: ThemeConfig;
|
|
40
|
+
/**
|
|
41
|
+
* 深色主题
|
|
42
|
+
*/
|
|
43
|
+
export declare const darkTheme: ThemeConfig;
|
|
44
|
+
/**
|
|
45
|
+
* 获取主题配置
|
|
46
|
+
*/
|
|
47
|
+
export declare function getTheme(theme: 'light' | 'dark' | ThemeConfig): ThemeConfig;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
interface CacheConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
ttl: number;
|
|
4
|
+
maxSize: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 根据周期类型获取推荐的缓存 TTL
|
|
8
|
+
* - 分时数据:30 秒(需要较实时的数据)
|
|
9
|
+
* - 分钟 K 线:2 分钟
|
|
10
|
+
* - 日/周/月 K 线:10 分钟(历史数据变化慢)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTTLByPeriod(period: string): number;
|
|
13
|
+
/**
|
|
14
|
+
* 简单的内存缓存
|
|
15
|
+
*/
|
|
16
|
+
export declare class DataCache<T> {
|
|
17
|
+
private cache;
|
|
18
|
+
private config;
|
|
19
|
+
constructor(config?: Partial<CacheConfig>);
|
|
20
|
+
/**
|
|
21
|
+
* 生成缓存 key
|
|
22
|
+
*/
|
|
23
|
+
static buildKey(params: Record<string, unknown>): string;
|
|
24
|
+
/**
|
|
25
|
+
* 获取缓存
|
|
26
|
+
*/
|
|
27
|
+
get(key: string): T | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* 设置缓存
|
|
30
|
+
* @param key 缓存键
|
|
31
|
+
* @param data 缓存数据
|
|
32
|
+
* @param ttl 可选的自定义 TTL(毫秒)
|
|
33
|
+
*/
|
|
34
|
+
set(key: string, data: T, ttl?: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* 清理过期缓存
|
|
37
|
+
*/
|
|
38
|
+
cleanup(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 删除缓存
|
|
41
|
+
*/
|
|
42
|
+
delete(key: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 清空缓存
|
|
45
|
+
*/
|
|
46
|
+
clear(): void;
|
|
47
|
+
/**
|
|
48
|
+
* 获取缓存大小
|
|
49
|
+
*/
|
|
50
|
+
size(): number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 全局数据缓存实例
|
|
54
|
+
*/
|
|
55
|
+
export declare const dataCache: DataCache<unknown>;
|
|
56
|
+
export {};
|