@pradeepjadhav/trading-reload-chart 1.0.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.
Files changed (60) hide show
  1. package/LICENSE +87 -0
  2. package/README.md +256 -0
  3. package/dist/canvas/layers/AxisLayerX/AxisLayerX.d.ts +27 -0
  4. package/dist/canvas/layers/AxisLayerX/AxisLayerX.helpers.d.ts +32 -0
  5. package/dist/canvas/layers/AxisLayerX/AxisLayerX.types.d.ts +10 -0
  6. package/dist/canvas/layers/AxisLayerY/AxisLayerY.d.ts +23 -0
  7. package/dist/canvas/layers/AxisLayerY/AxisLayerY.helpers.d.ts +4 -0
  8. package/dist/canvas/layers/AxisLayerY/AxisLayerY.types.d.ts +8 -0
  9. package/dist/canvas/layers/CrosshairLayer.d.ts +23 -0
  10. package/dist/canvas/layers/CrosshairLayer.types.d.ts +10 -0
  11. package/dist/canvas/layers/ExistingCandlesLayer.d.ts +107 -0
  12. package/dist/canvas/layers/ExistingCandlesLayer.types.d.ts +56 -0
  13. package/dist/canvas/layers/PdhPdlLayer.d.ts +24 -0
  14. package/dist/canvas/layers/ShapesLayer/FibRetracementShape.d.ts +28 -0
  15. package/dist/canvas/layers/ShapesLayer/LineShape.d.ts +27 -0
  16. package/dist/canvas/layers/ShapesLayer/PathShape.d.ts +29 -0
  17. package/dist/canvas/layers/ShapesLayer/RectangleShape.d.ts +28 -0
  18. package/dist/canvas/layers/ShapesLayer/ShapesLayer.d.ts +70 -0
  19. package/dist/canvas/layers/ShapesLayer/ShapesLayer.helpers.d.ts +47 -0
  20. package/dist/canvas/layers/ShapesLayer/ShapesLayer.types.d.ts +470 -0
  21. package/dist/canvas/layers/ShapesLayer/ShortLongPosition.d.ts +40 -0
  22. package/dist/canvas/layers/ShapesLayer/ShortLongPosition.types.d.ts +11 -0
  23. package/dist/canvas/layers/TradeLayer/TradeLayer.d.ts +152 -0
  24. package/dist/canvas/layers/TradeLayer/TradeLayer.helpers.d.ts +3 -0
  25. package/dist/canvas/layers/TradeLayer/TradeLayer.types.d.ts +261 -0
  26. package/dist/canvas/layers/TradeLayer/TradeLayerEvents.d.ts +68 -0
  27. package/dist/canvas/layers/TradeLayer/TradeLayerEvents.types.d.ts +12 -0
  28. package/dist/canvas/layers/VolumeLayer/VolumeLayer.d.ts +28 -0
  29. package/dist/canvas/layers/VolumeLayer/VolumeLayer.types.d.ts +25 -0
  30. package/dist/canvas/layers/helpers/LayerHelpers.d.ts +29 -0
  31. package/dist/chart/ChartController.d.ts +8 -0
  32. package/dist/chart/ChartController.types.d.ts +224 -0
  33. package/dist/chart/createChartDom.d.ts +2 -0
  34. package/dist/chart/createChartDom.types.d.ts +13 -0
  35. package/dist/chart/utils/deepPartial.types.d.ts +14 -0
  36. package/dist/chart/utils/getCanvasPoint.d.ts +2 -0
  37. package/dist/chart/utils/getCanvasPoint.types.d.ts +10 -0
  38. package/dist/chart/utils/mergeChartConfig.d.ts +3 -0
  39. package/dist/chart/utils/normalizeCandleTime.d.ts +2 -0
  40. package/dist/chart/utils/updateTradeTPSL.d.ts +8 -0
  41. package/dist/config/ChartShapeConfig/chartShapeConfig.d.ts +2 -0
  42. package/dist/config/chartConfig.d.ts +20 -0
  43. package/dist/config/chartConfig.types.d.ts +642 -0
  44. package/dist/config/colors.d.ts +19 -0
  45. package/dist/config/pairs.d.ts +3 -0
  46. package/dist/core/CoordinateSystem.d.ts +10 -0
  47. package/dist/favicon.svg +1 -0
  48. package/dist/helpers/math.d.ts +1 -0
  49. package/dist/icons.svg +24 -0
  50. package/dist/index.d.ts +14 -0
  51. package/dist/models/Candle.types.d.ts +67 -0
  52. package/dist/models/ChartViewport.types.d.ts +30 -0
  53. package/dist/models/Point.types.d.ts +12 -0
  54. package/dist/models/Trade.types.d.ts +151 -0
  55. package/dist/models/VisibleRange.types.d.ts +15 -0
  56. package/dist/react/TradingReload.d.ts +28 -0
  57. package/dist/react/TradingReload.types.d.ts +74 -0
  58. package/dist/trading-reload-chart.css +2 -0
  59. package/dist/trading-reload-chart.js +3503 -0
  60. package/package.json +74 -0
@@ -0,0 +1,10 @@
1
+ import { Point2D } from '../../models/Point.types';
2
+ /**
3
+ * Point in chart canvas coordinates.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const point: CanvasPoint = { x: 320, y: 180 };
8
+ * ```
9
+ */
10
+ export type CanvasPoint = Point2D;
@@ -0,0 +1,3 @@
1
+ import { ChartConfig } from '../../config/chartConfig.types';
2
+ import { DeepPartial } from './deepPartial.types';
3
+ export declare const mergeChartConfig: (partial?: DeepPartial<ChartConfig>) => ChartConfig;
@@ -0,0 +1,2 @@
1
+ import { Candle } from '../../models/Candle.types';
2
+ export declare const normalizeCandleTime: (candle: Candle, brokerTimezoneOffsetMs?: number) => Candle;
@@ -0,0 +1,8 @@
1
+ import { TradeHandleType } from '../../canvas/layers/TradeLayer/TradeLayer.types';
2
+ import { OpenTrade } from '../../models/Trade.types';
3
+ export declare const updateTradeTPSL: ({ currentTrade, targetTrade, type, price, }: {
4
+ currentTrade: OpenTrade;
5
+ targetTrade: OpenTrade;
6
+ type: TradeHandleType;
7
+ price: number;
8
+ }) => OpenTrade;
@@ -0,0 +1,2 @@
1
+ import { PartialShapeConfig } from '../../canvas/layers/ShapesLayer/ShapesLayer.types';
2
+ export declare const CHART_SHAPE_CONFIG: PartialShapeConfig;
@@ -0,0 +1,20 @@
1
+ import { ChartConfig } from './chartConfig.types';
2
+ /**
3
+ * Default chart configuration used when the consumer does not provide a custom
4
+ * `config` prop.
5
+ *
6
+ * Pass a partial override through `TradingReload` to change only the keys you
7
+ * care about.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * <TradingReload
12
+ * {...props}
13
+ * config={{
14
+ * colors: { background: "#0d1117" },
15
+ * candles: { defaultWidth: 10 },
16
+ * }}
17
+ * />
18
+ * ```
19
+ */
20
+ export declare const CHART_CONFIG: ChartConfig;
@@ -0,0 +1,642 @@
1
+ import { PartialShapeConfig } from '../canvas/layers/ShapesLayer/ShapesLayer.types';
2
+ export type { PartialShapeConfig };
3
+ /**
4
+ * Horizontal zoom behavior for wheel interactions.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const zoomX: HorizontalZoomConfig = { speed: 0.05, min: 0.03, max: 20 };
9
+ * ```
10
+ */
11
+ export type HorizontalZoomConfig = {
12
+ speed: number;
13
+ min: number;
14
+ max: number;
15
+ };
16
+ /**
17
+ * Vertical zoom behavior used for Ctrl + wheel interactions.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const zoomY: VerticalZoomConfig = { speed: 0.1, min: 10, max: 500 };
22
+ * ```
23
+ */
24
+ export type VerticalZoomConfig = {
25
+ speed: number;
26
+ min: number;
27
+ max: number;
28
+ };
29
+ /**
30
+ * Zoom settings for both axes.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const zoom: ZoomConfig = {
35
+ * x: { speed: 0.05, min: 0.03, max: 20 },
36
+ * y: { speed: 0.1, min: 10, max: 500 },
37
+ * };
38
+ * ```
39
+ */
40
+ export type ZoomConfig = {
41
+ x: HorizontalZoomConfig;
42
+ y: VerticalZoomConfig;
43
+ };
44
+ /**
45
+ * Style for the live bid or ask price line.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const line: LivePriceLineConfig = {
50
+ * visible: true,
51
+ * width: 1,
52
+ * opacity: 0.7,
53
+ * dash: [4, 4],
54
+ * bullishColor: "#22c55e",
55
+ * bearishColor: "#ef4444",
56
+ * };
57
+ * ```
58
+ */
59
+ export type LivePriceLineConfig = {
60
+ visible: boolean;
61
+ width: number;
62
+ opacity: number;
63
+ dash: number[];
64
+ bullishColor: string;
65
+ bearishColor: string;
66
+ };
67
+ /**
68
+ * Candle rendering behavior and live price settings.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const candles: CandlesConfig = {
73
+ * defaultWidth: 8,
74
+ * defaultGap: 2,
75
+ * minBodyHeight: 1,
76
+ * autoFollowLatestCandle: true,
77
+ * autoFollowThresholdCandles: 10,
78
+ * rightOffsetCandles: 15,
79
+ * liveBidPriceLine: { visible: true, width: 1, opacity: 0.7, dash: [4, 4], bullishColor: "#22c55e", bearishColor: "#ef4444" },
80
+ * liveAskPriceLine: { visible: true, width: 1, opacity: 0.7, dash: [4, 6], bullishColor: "#a855f7", bearishColor: "#a855f7" },
81
+ * };
82
+ * ```
83
+ */
84
+ export type CandlesConfig = {
85
+ defaultWidth: number;
86
+ defaultGap: number;
87
+ minBodyHeight: number;
88
+ autoFollowLatestCandle: boolean;
89
+ autoFollowThresholdCandles: number;
90
+ rightOffsetCandles: number;
91
+ liveBidPriceLine: LivePriceLineConfig;
92
+ liveAskPriceLine: LivePriceLineConfig;
93
+ };
94
+ /**
95
+ * Volume layer appearance and sizing.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const volume: VolumeConfig = {
100
+ * visible: true,
101
+ * bullishColor: "#22c55e",
102
+ * bearishColor: "#ef4444",
103
+ * opacity: 0.35,
104
+ * height: 200,
105
+ * bottomOffset: 0,
106
+ * minBarHeight: 1,
107
+ * };
108
+ * ```
109
+ */
110
+ export type VolumeConfig = {
111
+ visible: boolean;
112
+ bullishColor: string;
113
+ bearishColor: string;
114
+ opacity: number;
115
+ height: number;
116
+ bottomOffset: number;
117
+ minBarHeight: number;
118
+ };
119
+ /**
120
+ * Crosshair line style.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const crosshair: CrosshairConfig = {
125
+ * color: "rgba(255,255,255,0.35)",
126
+ * thickness: 1,
127
+ * style: "dashed",
128
+ * };
129
+ * ```
130
+ */
131
+ export type CrosshairConfig = {
132
+ color: string;
133
+ thickness: number;
134
+ style: "solid" | "dashed" | "dotted";
135
+ };
136
+ /**
137
+ * Placement for trade handles relative to the price line.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const position: TradeHandlePositionConfig = {
142
+ * placement: "left",
143
+ * margin: 100,
144
+ * };
145
+ * ```
146
+ */
147
+ export type TradeHandlePositionConfig = {
148
+ placement: "left" | "center" | "right";
149
+ margin?: number;
150
+ };
151
+ /**
152
+ * Line styling used by trade handles and connector lines.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * const line: TradeHandleLineConfig = {
157
+ * width: 1,
158
+ * color: "#22c55e",
159
+ * opacity: 0.9,
160
+ * style: "dashed",
161
+ * dash: [4, 4],
162
+ * };
163
+ * ```
164
+ */
165
+ export type TradeHandleLineConfig = {
166
+ width: number;
167
+ color: string;
168
+ opacity: number;
169
+ style: "solid" | "dashed" | "dotted";
170
+ dash?: number[];
171
+ };
172
+ /**
173
+ * Rectangular trade handle appearance.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const handle: TradeHandleRectConfig = {
178
+ * height: 22,
179
+ * widthVolume: 60,
180
+ * widthPNL: 80,
181
+ * widthClose: 24,
182
+ * position: { placement: "left", margin: 100 },
183
+ * borderWidth: 1,
184
+ * borderColor: "#3b82f6",
185
+ * borderOpacity: 0.9,
186
+ * backgroundColor: "#111827",
187
+ * backgroundOpacity: 0.9,
188
+ * sectionDividerColor: "#374151",
189
+ * paddingX: 10,
190
+ * closeButtonColor: "#3b82f6",
191
+ * showVolumeSection: true,
192
+ * showPnlSection: true,
193
+ * showCloseSection: true,
194
+ * };
195
+ * ```
196
+ */
197
+ export type TradeHandleRectConfig = {
198
+ height: number;
199
+ widthVolume: number;
200
+ widthPNL: number;
201
+ widthClose: number;
202
+ position: TradeHandlePositionConfig;
203
+ borderWidth: number;
204
+ borderColor: string;
205
+ borderOpacity: number;
206
+ backgroundColor: string;
207
+ backgroundOpacity: number;
208
+ sectionDividerColor: string;
209
+ paddingX: number;
210
+ closeButtonColor: string;
211
+ showVolumeSection: boolean;
212
+ showPnlSection: boolean;
213
+ showCloseSection: boolean;
214
+ };
215
+ /**
216
+ * Combined trade handle line and box styling.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const style: TradeHandleStyleConfig = {
221
+ * handle: { height: 22, widthVolume: 60, widthPNL: 80, widthClose: 24, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#3b82f6", borderOpacity: 0.9, backgroundColor: "#111827", backgroundOpacity: 0.9, sectionDividerColor: "#374151", paddingX: 10, closeButtonColor: "#3b82f6", showVolumeSection: true, showPnlSection: true, showCloseSection: true },
222
+ * handleLine: { width: 1, color: "#3b82f6", opacity: 1, style: "solid" },
223
+ * };
224
+ * ```
225
+ */
226
+ export type TradeHandleStyleConfig = {
227
+ handle: TradeHandleRectConfig;
228
+ handleLine: TradeHandleLineConfig;
229
+ };
230
+ /**
231
+ * Positive and negative PnL text colors.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * const colors: TradePnlTextColorConfig = {
236
+ * positive: "#22c55e",
237
+ * negative: "#ef4444",
238
+ * };
239
+ * ```
240
+ */
241
+ export type TradePnlTextColorConfig = {
242
+ positive: string;
243
+ negative: string;
244
+ };
245
+ /**
246
+ * Side on which missing protection handles appear.
247
+ *
248
+ * @example `"right"`
249
+ */
250
+ export type MissingTradeProtectionHandlePlacement = "left" | "right";
251
+ /**
252
+ * Style for the small add-SL / add-TP handles.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * const handle: MissingTradeProtectionHandleRectConfig = {
257
+ * width: 32,
258
+ * height: 22,
259
+ * gapFromStartPriceHandle: 6,
260
+ * gapBetweenHandles: 4,
261
+ * placement: "right",
262
+ * borderWidth: 1,
263
+ * borderColor: "#ef4444",
264
+ * borderOpacity: 0.5,
265
+ * backgroundColor: "#2b0f12",
266
+ * backgroundOpacity: 0.3,
267
+ * textColor: "#ef4444",
268
+ * textOpacity: 0.6,
269
+ * font: "12px Arial",
270
+ * };
271
+ * ```
272
+ */
273
+ export type MissingTradeProtectionHandleRectConfig = {
274
+ width: number;
275
+ height: number;
276
+ gapFromStartPriceHandle: number;
277
+ gapBetweenHandles: number;
278
+ placement: MissingTradeProtectionHandlePlacement;
279
+ borderWidth: number;
280
+ borderColor: string;
281
+ borderOpacity: number;
282
+ backgroundColor: string;
283
+ backgroundOpacity: number;
284
+ textColor: string;
285
+ textOpacity: number;
286
+ font: string;
287
+ };
288
+ /**
289
+ * Style for the temporary handle preview shown while adding SL or TP.
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * const handle: TemporaryTradeProtectionHandleRectConfig = {
294
+ * height: 22,
295
+ * widthPNL: 80,
296
+ * position: { placement: "left", margin: 100 },
297
+ * borderWidth: 1,
298
+ * borderColor: "#22c55e",
299
+ * borderOpacity: 0.4,
300
+ * backgroundColor: "#0f2b18",
301
+ * backgroundOpacity: 0.9,
302
+ * paddingX: 10,
303
+ * textColor: "#22c55e",
304
+ * textOpacity: 0.85,
305
+ * font: "12px Arial",
306
+ * };
307
+ * ```
308
+ */
309
+ export type TemporaryTradeProtectionHandleRectConfig = {
310
+ height: number;
311
+ widthPNL: number;
312
+ position: TradeHandlePositionConfig;
313
+ borderWidth: number;
314
+ borderColor: string;
315
+ borderOpacity: number;
316
+ backgroundColor: string;
317
+ backgroundOpacity: number;
318
+ paddingX: number;
319
+ textColor: string;
320
+ textOpacity: number;
321
+ font: string;
322
+ };
323
+ /**
324
+ * Config for missing SL/TP affordances.
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * const missingProtection: MissingTradeProtectionConfig = {
329
+ * visible: true,
330
+ * dragActivationThresholdPx: 2,
331
+ * slHandle: { width: 32, height: 22, gapFromStartPriceHandle: 6, gapBetweenHandles: 4, placement: "right", borderWidth: 1, borderColor: "#ef4444", borderOpacity: 0.5, backgroundColor: "#2b0f12", backgroundOpacity: 0.3, textColor: "#ef4444", textOpacity: 0.6, font: "12px Arial" },
332
+ * tpHandle: { width: 32, height: 22, gapFromStartPriceHandle: 6, gapBetweenHandles: 4, placement: "right", borderWidth: 1, borderColor: "#22c55e", borderOpacity: 0.5, backgroundColor: "#0f2b18", backgroundOpacity: 0.3, textColor: "#22c55e", textOpacity: 0.6, font: "12px Arial" },
333
+ * temporarySlHandle: { height: 22, widthPNL: 80, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#ef4444", borderOpacity: 0.4, backgroundColor: "#2b0f12", backgroundOpacity: 0.9, paddingX: 10, textColor: "#ef4444", textOpacity: 0.85, font: "12px Arial" },
334
+ * temporaryTpHandle: { height: 22, widthPNL: 80, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#22c55e", borderOpacity: 0.4, backgroundColor: "#0f2b18", backgroundOpacity: 0.9, paddingX: 10, textColor: "#22c55e", textOpacity: 0.85, font: "12px Arial" },
335
+ * temporarySlLine: { width: 1, color: "#ef4444", opacity: 0.9, style: "dotted", dash: [2, 4] },
336
+ * temporaryTpLine: { width: 1, color: "#22c55e", opacity: 0.9, style: "dotted", dash: [2, 4] },
337
+ * };
338
+ * ```
339
+ */
340
+ export type MissingTradeProtectionConfig = {
341
+ visible: boolean;
342
+ dragActivationThresholdPx: number;
343
+ slHandle: MissingTradeProtectionHandleRectConfig;
344
+ tpHandle: MissingTradeProtectionHandleRectConfig;
345
+ temporarySlHandle: TemporaryTradeProtectionHandleRectConfig;
346
+ temporaryTpHandle: TemporaryTradeProtectionHandleRectConfig;
347
+ temporarySlLine: TradeHandleLineConfig;
348
+ temporaryTpLine: TradeHandleLineConfig;
349
+ };
350
+ /**
351
+ * Full trade handle configuration.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * const tradeHandles: TradeHandlesConfig = {
356
+ * font: "12px Arial",
357
+ * textColor: "#ffffff",
358
+ * textOpacity: 0.8,
359
+ * pnlTextColors: { positive: "#22c55e", negative: "#ef4444" },
360
+ * slHandle: { handle: { height: 22, widthVolume: 60, widthPNL: 80, widthClose: 24, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#ef4444", borderOpacity: 0.4, backgroundColor: "#2b0f12", backgroundOpacity: 0.9, sectionDividerColor: "#374151", paddingX: 10, closeButtonColor: "#ef4444", showVolumeSection: false, showPnlSection: true, showCloseSection: true }, handleLine: { width: 1, color: "#ef4444", opacity: 0.9, style: "dashed", dash: [4, 4] } },
361
+ * tpHandle: { handle: { height: 22, widthVolume: 60, widthPNL: 80, widthClose: 24, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#22c55e", borderOpacity: 0.4, backgroundColor: "#0f2b18", backgroundOpacity: 0.9, sectionDividerColor: "#374151", paddingX: 10, closeButtonColor: "#22c55e", showVolumeSection: false, showPnlSection: true, showCloseSection: true }, handleLine: { width: 1, color: "#22c55e", opacity: 0.9, style: "dashed", dash: [4, 4] } },
362
+ * startPriceHandle: { handle: { height: 22, widthVolume: 60, widthPNL: 80, widthClose: 24, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#3b82f6", borderOpacity: 0.9, backgroundColor: "#111827", backgroundOpacity: 0.9, sectionDividerColor: "#374151", paddingX: 10, closeButtonColor: "#3b82f6", showVolumeSection: true, showPnlSection: true, showCloseSection: true }, handleLine: { width: 1, color: "#3b82f6", opacity: 1, style: "solid" } },
363
+ * missingProtectionHandles: { visible: true, dragActivationThresholdPx: 2, slHandle: { width: 32, height: 22, gapFromStartPriceHandle: 6, gapBetweenHandles: 4, placement: "right", borderWidth: 1, borderColor: "#ef4444", borderOpacity: 0.5, backgroundColor: "#2b0f12", backgroundOpacity: 0.3, textColor: "#ef4444", textOpacity: 0.6, font: "12px Arial" }, tpHandle: { width: 32, height: 22, gapFromStartPriceHandle: 6, gapBetweenHandles: 4, placement: "right", borderWidth: 1, borderColor: "#22c55e", borderOpacity: 0.5, backgroundColor: "#0f2b18", backgroundOpacity: 0.3, textColor: "#22c55e", textOpacity: 0.6, font: "12px Arial" }, temporarySlHandle: { height: 22, widthPNL: 80, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#ef4444", borderOpacity: 0.4, backgroundColor: "#2b0f12", backgroundOpacity: 0.9, paddingX: 10, textColor: "#ef4444", textOpacity: 0.85, font: "12px Arial" }, temporaryTpHandle: { height: 22, widthPNL: 80, position: { placement: "left", margin: 100 }, borderWidth: 1, borderColor: "#22c55e", borderOpacity: 0.4, backgroundColor: "#0f2b18", backgroundOpacity: 0.9, paddingX: 10, textColor: "#22c55e", textOpacity: 0.85, font: "12px Arial" }, temporarySlLine: { width: 1, color: "#ef4444", opacity: 0.9, style: "dotted", dash: [2, 4] }, temporaryTpLine: { width: 1, color: "#22c55e", opacity: 0.9, style: "dotted", dash: [2, 4] } },
364
+ * };
365
+ * ```
366
+ */
367
+ export type TradeHandlesConfig = {
368
+ font: string;
369
+ textColor: string;
370
+ textOpacity: number;
371
+ pnlTextColors: TradePnlTextColorConfig;
372
+ slHandle: TradeHandleStyleConfig;
373
+ tpHandle: TradeHandleStyleConfig;
374
+ startPriceHandle: TradeHandleStyleConfig;
375
+ missingProtectionHandles: MissingTradeProtectionConfig;
376
+ };
377
+ /**
378
+ * Arrow appearance for past trade markers.
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * const arrow: PastTradeIndicatorArrowConfig = {
383
+ * visible: true,
384
+ * width: 60,
385
+ * height: 30,
386
+ * headHeightRatio: 0.45,
387
+ * shaftWidthRatio: 6,
388
+ * buyColor: "#22c55e",
389
+ * sellColor: "#ef4444",
390
+ * buyBorderColor: "#ffffff",
391
+ * sellBorderColor: "#ffffff",
392
+ * borderWidth: 1,
393
+ * opacity: 1,
394
+ * };
395
+ * ```
396
+ */
397
+ export type PastTradeIndicatorArrowConfig = {
398
+ visible: boolean;
399
+ width: number;
400
+ height: number;
401
+ headHeightRatio: number;
402
+ shaftWidthRatio: number;
403
+ buyColor: string;
404
+ sellColor: string;
405
+ buyBorderColor: string;
406
+ sellBorderColor: string;
407
+ borderWidth: number;
408
+ opacity: number;
409
+ };
410
+ /**
411
+ * Historical trade marker configuration.
412
+ *
413
+ * @example
414
+ * ```ts
415
+ * const pastTrades: PastTradeIndicatorsConfig = {
416
+ * visible: true,
417
+ * arrow: { visible: true, width: 60, height: 30, headHeightRatio: 0.45, shaftWidthRatio: 6, buyColor: "#22c55e", sellColor: "#ef4444", buyBorderColor: "#ffffff", sellBorderColor: "#ffffff", borderWidth: 1, opacity: 1 },
418
+ * connectorLine: { width: 1, color: "#ffffff", opacity: 0.65, style: "dotted", dash: [2, 4] },
419
+ * };
420
+ * ```
421
+ */
422
+ export type PastTradeIndicatorsConfig = {
423
+ visible: boolean;
424
+ arrow: PastTradeIndicatorArrowConfig;
425
+ connectorLine: TradeHandleLineConfig;
426
+ };
427
+ /**
428
+ * Core bullish, bearish, and background colors.
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * const colors: ColorsConfig = {
433
+ * bullish: "#22c55e",
434
+ * bearish: "#ef4444",
435
+ * background: "#0b1220",
436
+ * };
437
+ * ```
438
+ */
439
+ export type ColorsConfig = {
440
+ bullish: string;
441
+ bearish: string;
442
+ background: string;
443
+ };
444
+ /**
445
+ * Crosshair label box shown on the axes.
446
+ *
447
+ * @example
448
+ * ```ts
449
+ * const label: AxisCrosshairLabelConfig = {
450
+ * backgroundColor: "#111827",
451
+ * borderColor: "#111827",
452
+ * borderWidth: 1,
453
+ * textColor: "#ffffff",
454
+ * font: "12px Arial",
455
+ * paddingX: 8,
456
+ * height: 26,
457
+ * };
458
+ * ```
459
+ */
460
+ export type AxisCrosshairLabelConfig = {
461
+ backgroundColor: string;
462
+ borderColor: string;
463
+ borderWidth: number;
464
+ textColor: string;
465
+ font: string;
466
+ paddingX: number;
467
+ height: number;
468
+ };
469
+ /**
470
+ * Y-axis styling and metrics.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * const axisY: AxisYConfig = {
475
+ * width: 80,
476
+ * backgroundColor: "#0b1220",
477
+ * borderColor: "#1f2937",
478
+ * borderWidth: 1,
479
+ * textColor: "#cbd5e1",
480
+ * font: "12px Arial",
481
+ * textAlign: "left",
482
+ * tickCount: 12,
483
+ * tickColor: "#334155",
484
+ * tickWidth: 1,
485
+ * tickLength: 4,
486
+ * tickGap: 64,
487
+ * labelOffsetX: 8,
488
+ * crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 20 },
489
+ * };
490
+ * ```
491
+ */
492
+ export type AxisYConfig = {
493
+ width: number;
494
+ backgroundColor: string;
495
+ borderColor: string;
496
+ borderWidth: number;
497
+ textColor: string;
498
+ font: string;
499
+ textAlign: CanvasTextAlign;
500
+ tickCount: number;
501
+ tickColor: string;
502
+ tickWidth: number;
503
+ tickLength: number;
504
+ tickGap: number;
505
+ labelOffsetX: number;
506
+ crosshairLabel: AxisCrosshairLabelConfig;
507
+ };
508
+ /**
509
+ * X-axis styling and metrics.
510
+ *
511
+ * @example
512
+ * ```ts
513
+ * const axisX: AxisXConfig = {
514
+ * height: 30,
515
+ * backgroundColor: "#0b1220",
516
+ * borderColor: "#1f2937",
517
+ * borderWidth: 1,
518
+ * textColor: "#cbd5e1",
519
+ * font: "12px Arial",
520
+ * textAlign: "center",
521
+ * tickColor: "#334155",
522
+ * tickWidth: 1,
523
+ * tickLength: 4,
524
+ * labelOffsetY: 16,
525
+ * minLabelGap: 16,
526
+ * crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 26 },
527
+ * };
528
+ * ```
529
+ */
530
+ export type AxisXConfig = {
531
+ height: number;
532
+ backgroundColor: string;
533
+ borderColor: string;
534
+ borderWidth: number;
535
+ textColor: string;
536
+ font: string;
537
+ textAlign: CanvasTextAlign;
538
+ tickColor: string;
539
+ tickWidth: number;
540
+ tickLength: number;
541
+ labelOffsetY: number;
542
+ minLabelGap: number;
543
+ crosshairLabel: AxisCrosshairLabelConfig;
544
+ };
545
+ /**
546
+ * Both chart axes grouped together.
547
+ *
548
+ * @example
549
+ * ```ts
550
+ * const axis: AxisConfig = {
551
+ * axisX: { height: 30, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "center", tickColor: "#334155", tickWidth: 1, tickLength: 4, labelOffsetY: 16, minLabelGap: 16, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 26 } },
552
+ * axisY: { width: 80, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "left", tickCount: 12, tickColor: "#334155", tickWidth: 1, tickLength: 4, tickGap: 64, labelOffsetX: 8, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 20 } },
553
+ * };
554
+ * ```
555
+ */
556
+ export type AxisConfig = {
557
+ axisX: AxisXConfig;
558
+ axisY: AxisYConfig;
559
+ };
560
+ /**
561
+ * Line style for previous-day high/low overlays.
562
+ *
563
+ * @example
564
+ * ```ts
565
+ * const line: PreviousDayHighLowLineConfig = {
566
+ * color: "#94a3b8",
567
+ * width: 1,
568
+ * opacity: 0.8,
569
+ * dash: [4, 4],
570
+ * };
571
+ * ```
572
+ */
573
+ export type PreviousDayHighLowLineConfig = {
574
+ color: string;
575
+ width: number;
576
+ opacity: number;
577
+ dash: number[];
578
+ };
579
+ /**
580
+ * Text style for previous-day high/low labels.
581
+ *
582
+ * @example
583
+ * ```ts
584
+ * const text: PreviousDayHighLowTextConfig = {
585
+ * color: "#e2e8f0",
586
+ * font: "12px Arial",
587
+ * paddingX: 8,
588
+ * };
589
+ * ```
590
+ */
591
+ export type PreviousDayHighLowTextConfig = {
592
+ color: string;
593
+ font: string;
594
+ paddingX: number;
595
+ };
596
+ /**
597
+ * Previous day high/low annotation styling.
598
+ *
599
+ * @example
600
+ * ```ts
601
+ * const previousDayHighLow: PreviousDayHighLowConfig = {
602
+ * line: { color: "#94a3b8", width: 1, opacity: 0.8, dash: [4, 4] },
603
+ * text: { color: "#e2e8f0", font: "12px Arial", paddingX: 8 },
604
+ * };
605
+ * ```
606
+ */
607
+ export type PreviousDayHighLowConfig = {
608
+ line: PreviousDayHighLowLineConfig;
609
+ text: PreviousDayHighLowTextConfig;
610
+ };
611
+ /**
612
+ * Full public chart configuration.
613
+ *
614
+ * Consumers usually pass `DeepPartial<ChartConfig>` to the `config` prop so
615
+ * they can override only a few values.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * const config: ChartConfig = {
620
+ * zoom: { x: { speed: 0.05, min: 0.03, max: 20 }, y: { speed: 0.1, min: 10, max: 500 } },
621
+ * candles: { defaultWidth: 8, defaultGap: 2, minBodyHeight: 1, autoFollowLatestCandle: true, autoFollowThresholdCandles: 10, rightOffsetCandles: 15, liveBidPriceLine: { visible: true, width: 1, opacity: 0.7, dash: [4, 4], bullishColor: "#22c55e", bearishColor: "#ef4444" }, liveAskPriceLine: { visible: true, width: 1, opacity: 0.7, dash: [4, 6], bullishColor: "#a855f7", bearishColor: "#a855f7" } },
622
+ * volume: { visible: true, bullishColor: "#22c55e", bearishColor: "#ef4444", opacity: 0.35, height: 200, bottomOffset: 0, minBarHeight: 1 },
623
+ * crosshair: { color: "rgba(255,255,255,0.35)", thickness: 1, style: "dashed" },
624
+ * tradeHandles: {} as TradeHandlesConfig,
625
+ * pastTradeIndicators: { visible: true, arrow: { visible: true, width: 60, height: 30, headHeightRatio: 0.45, shaftWidthRatio: 6, buyColor: "#22c55e", sellColor: "#ef4444", buyBorderColor: "#ffffff", sellBorderColor: "#ffffff", borderWidth: 1, opacity: 1 }, connectorLine: { width: 1, color: "#ffffff", opacity: 0.65, style: "dotted", dash: [2, 4] } },
626
+ * colors: { bullish: "#22c55e", bearish: "#ef4444", background: "#0b1220" },
627
+ * axis: { axisX: { height: 30, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "center", tickColor: "#334155", tickWidth: 1, tickLength: 4, labelOffsetY: 16, minLabelGap: 16, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 26 } }, axisY: { width: 80, backgroundColor: "#0b1220", borderColor: "#1f2937", borderWidth: 1, textColor: "#cbd5e1", font: "12px Arial", textAlign: "left", tickCount: 12, tickColor: "#334155", tickWidth: 1, tickLength: 4, tickGap: 64, labelOffsetX: 8, crosshairLabel: { backgroundColor: "#111827", borderColor: "#111827", borderWidth: 1, textColor: "#ffffff", font: "12px Arial", paddingX: 8, height: 20 } } },
628
+ * shapes: { trendline: { lineColor: "#22c55e" } },
629
+ * };
630
+ * ```
631
+ */
632
+ export type ChartConfig = {
633
+ zoom: ZoomConfig;
634
+ candles: CandlesConfig;
635
+ volume: VolumeConfig;
636
+ crosshair: CrosshairConfig;
637
+ tradeHandles: TradeHandlesConfig;
638
+ pastTradeIndicators: PastTradeIndicatorsConfig;
639
+ colors: ColorsConfig;
640
+ axis: AxisConfig;
641
+ shapes: PartialShapeConfig;
642
+ };