@tradecanvas/commons 1.3.0 → 1.7.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +617 -122
- package/dist/index.js.map +1 -1
- package/dist/types/a11y.d.ts +18 -0
- package/dist/types/a11y.d.ts.map +1 -0
- package/dist/types/chart.d.ts +113 -9
- package/dist/types/chart.d.ts.map +1 -1
- package/dist/types/drawing.d.ts +85 -1
- package/dist/types/drawing.d.ts.map +1 -1
- package/dist/types/events.d.ts +155 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/execution.d.ts +20 -1
- package/dist/types/execution.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/indicator.d.ts +81 -0
- package/dist/types/indicator.d.ts.map +1 -1
- package/dist/types/layout.d.ts +8 -0
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/news.d.ts +18 -0
- package/dist/types/news.d.ts.map +1 -0
- package/dist/types/ohlc.d.ts +11 -1
- package/dist/types/ohlc.d.ts.map +1 -1
- package/dist/types/quote.d.ts +40 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/realtime.d.ts +50 -0
- package/dist/types/realtime.d.ts.map +1 -1
- package/dist/types/rendering.d.ts +13 -0
- package/dist/types/rendering.d.ts.map +1 -1
- package/dist/types/symbol.d.ts +42 -0
- package/dist/types/symbol.d.ts.map +1 -0
- package/dist/types/theme.d.ts +6 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/types/trading.d.ts +33 -2
- package/dist/types/trading.d.ts.map +1 -1
- package/dist/utils/chartTypeOptions.d.ts +9 -0
- package/dist/utils/chartTypeOptions.d.ts.map +1 -0
- package/dist/utils/drawingOptions.d.ts +8 -0
- package/dist/utils/drawingOptions.d.ts.map +1 -0
- package/dist/utils/drawingStyle.d.ts +9 -0
- package/dist/utils/drawingStyle.d.ts.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/marketStatus.d.ts +16 -0
- package/dist/utils/marketStatus.d.ts.map +1 -0
- package/dist/utils/precision.d.ts +18 -0
- package/dist/utils/precision.d.ts.map +1 -1
- package/dist/utils/priceSource.d.ts +15 -0
- package/dist/utils/priceSource.d.ts.map +1 -0
- package/dist/utils/resample.d.ts +13 -0
- package/dist/utils/resample.d.ts.map +1 -0
- package/dist/utils/symbols.d.ts +13 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/dist/utils/time.d.ts +17 -6
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +28 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/types/chart.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { Theme, ThemeName } from './theme.js';
|
|
2
2
|
import { DrawingToolType } from './drawing.js';
|
|
3
3
|
import { TimeFrame } from './ohlc.js';
|
|
4
|
-
export type ChartType = 'candlestick' | 'line' | 'area' | 'bar' | 'heikinAshi' | 'hollowCandle' | 'baseline' | 'renko' | 'lineBreak' | 'kagi' | 'pointAndFigure' | 'rangeBars' | 'volumeCandles' | 'hlcArea' | 'stepLine' | 'lineWithMarkers' | 'equivolume';
|
|
4
|
+
export type ChartType = 'candlestick' | 'line' | 'area' | 'bar' | 'heikinAshi' | 'hollowCandle' | 'baseline' | 'renko' | 'lineBreak' | 'kagi' | 'pointAndFigure' | 'rangeBars' | 'volumeCandles' | 'hlcArea' | 'stepLine' | 'lineWithMarkers' | 'equivolume' | 'hiLo';
|
|
5
|
+
/**
|
|
6
|
+
* Settings of the chart types that build bars of their own. What isn't set
|
|
7
|
+
* is worked out from the data.
|
|
8
|
+
*/
|
|
9
|
+
export interface ChartTypeOptions {
|
|
10
|
+
/** Box size in price, or 'atr' (default): the average true range of the last `atrPeriod` bars (14). */
|
|
11
|
+
renko?: {
|
|
12
|
+
boxSize?: number | 'atr';
|
|
13
|
+
atrPeriod?: number;
|
|
14
|
+
};
|
|
15
|
+
/** How many lines a reversal has to break (3). */
|
|
16
|
+
lineBreak?: {
|
|
17
|
+
lines?: number;
|
|
18
|
+
};
|
|
19
|
+
/** The reversal: percent of the line's start (4), or an amount of price with `reversalType` 'price'. */
|
|
20
|
+
kagi?: {
|
|
21
|
+
reversal?: number;
|
|
22
|
+
reversalType?: 'percent' | 'price';
|
|
23
|
+
};
|
|
24
|
+
/** Box size in price ('auto': 1% of the average close) and boxes to reverse (3). */
|
|
25
|
+
pointAndFigure?: {
|
|
26
|
+
boxSize?: number | 'auto';
|
|
27
|
+
reversal?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Each bar's range in price ('auto': 0.5% of the average close). */
|
|
30
|
+
rangeBars?: {
|
|
31
|
+
range?: number | 'auto';
|
|
32
|
+
};
|
|
33
|
+
}
|
|
5
34
|
export type LineStyle = 'solid' | 'dashed' | 'dotted';
|
|
6
35
|
/**
|
|
7
36
|
* Controls which features are available to the end user.
|
|
@@ -13,7 +42,7 @@ export interface FeaturesConfig {
|
|
|
13
42
|
drawings?: boolean;
|
|
14
43
|
/** Whitelist of allowed drawing tool types. When set, only these tools are available. */
|
|
15
44
|
drawingTools?: DrawingToolType[];
|
|
16
|
-
/**
|
|
45
|
+
/** Allow magnet/snap for drawing anchors. When false, `setDrawingMagnet(true)` is ignored. */
|
|
17
46
|
drawingMagnet?: boolean;
|
|
18
47
|
/** Enable undo/redo for drawings (Ctrl+Z / Ctrl+Y) */
|
|
19
48
|
drawingUndoRedo?: boolean;
|
|
@@ -21,6 +50,11 @@ export interface FeaturesConfig {
|
|
|
21
50
|
trading?: boolean;
|
|
22
51
|
/** Right-click menu for placing orders. Default `false` — opt in explicitly. */
|
|
23
52
|
tradingContextMenu?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* A "+" by the price axis, level with the crosshair; a click on it emits
|
|
55
|
+
* `priceAxisAdd` with the price. Default `false` (ChartWidget turns it on).
|
|
56
|
+
*/
|
|
57
|
+
priceAxisAddButton?: boolean;
|
|
24
58
|
/** Enable indicator overlays and panels */
|
|
25
59
|
indicators?: boolean;
|
|
26
60
|
/** Whitelist of allowed indicator IDs. When set, only these are available. */
|
|
@@ -48,6 +82,8 @@ export interface FeaturesConfig {
|
|
|
48
82
|
grid?: boolean;
|
|
49
83
|
/** Show OHLCV legend overlay */
|
|
50
84
|
legend?: boolean;
|
|
85
|
+
/** Tag each indicator line's latest value on its value axis. Default true. */
|
|
86
|
+
indicatorValueLabels?: boolean;
|
|
51
87
|
/** Show volume bars below candles */
|
|
52
88
|
volume?: boolean;
|
|
53
89
|
/** Show watermark text */
|
|
@@ -62,23 +98,27 @@ export interface FeaturesConfig {
|
|
|
62
98
|
replay?: boolean;
|
|
63
99
|
/** Show session break lines (day separators) */
|
|
64
100
|
sessionBreaks?: boolean;
|
|
65
|
-
/** Show bar countdown timer (time until current candle closes) */
|
|
101
|
+
/** Show bar countdown timer (time until current candle closes). When false it stays hidden. */
|
|
66
102
|
barCountdown?: boolean;
|
|
67
|
-
/** Enable compare/overlay symbols */
|
|
103
|
+
/** Enable compare/overlay symbols. When false, `addCompareSymbol` does nothing. */
|
|
68
104
|
compareSymbols?: boolean;
|
|
69
|
-
/** Enable data export (CSV/JSON) */
|
|
105
|
+
/** Enable data export (CSV/JSON). When false, `exportVisibleData` / `exportAllData` do nothing. */
|
|
70
106
|
dataExport?: boolean;
|
|
71
|
-
/**
|
|
107
|
+
/** Allow the logarithmic price scale. When false, switching to it is ignored. */
|
|
72
108
|
logScale?: boolean;
|
|
73
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Whitelist of timeframes. When set, `setTimeframe` ignores any other, and
|
|
111
|
+
* ChartWidget offers only these.
|
|
112
|
+
*/
|
|
74
113
|
timeframes?: TimeFrame[];
|
|
75
|
-
/**
|
|
114
|
+
/** ChartWidget: timeframes on the quick-access bar until the user changes them. */
|
|
76
115
|
defaultTimeframeFavorites?: TimeFrame[];
|
|
77
116
|
}
|
|
78
117
|
export interface ChartOptions {
|
|
79
118
|
width?: number;
|
|
80
119
|
height?: number;
|
|
81
|
-
|
|
120
|
+
/** Default `'candlestick'`. */
|
|
121
|
+
chartType?: ChartType;
|
|
82
122
|
theme?: ThemeName | Theme;
|
|
83
123
|
autoScale?: boolean;
|
|
84
124
|
rightMargin?: number;
|
|
@@ -104,11 +144,75 @@ export interface ChartOptions {
|
|
|
104
144
|
* resting position).
|
|
105
145
|
*/
|
|
106
146
|
freePan?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Timezone for the time axis, crosshair, tooltip, day breaks and range
|
|
149
|
+
* presets: an IANA zone (`'America/New_York'`, daylight saving included), a
|
|
150
|
+
* fixed offset in minutes east of UTC, or null (default) for the browser's.
|
|
151
|
+
*/
|
|
152
|
+
timeZone?: string | number | null;
|
|
153
|
+
/**
|
|
154
|
+
* Show a price scale on the left too. It carries the overlays put on it
|
|
155
|
+
* (`addIndicator(…, { scale: 'left' })`), else it mirrors the price scale.
|
|
156
|
+
* It shows by itself once an overlay is on it.
|
|
157
|
+
*/
|
|
158
|
+
leftPriceScale?: boolean;
|
|
107
159
|
/** Bounds for free panning. */
|
|
108
160
|
panLimits?: {
|
|
109
161
|
minVisibleBars?: number;
|
|
110
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* How prices read on the price scale and everything that prints one (axis,
|
|
165
|
+
* crosshair, last-price tag, legend, tooltip, orders, alerts, drawings): a
|
|
166
|
+
* function of yours, or fractions of a point (a bond in 32nds: `101'16`).
|
|
167
|
+
* Indicator panes keep their own numbers. Default: decimals.
|
|
168
|
+
*/
|
|
169
|
+
priceFormat?: PriceFormatter | PriceFraction;
|
|
170
|
+
/** How times read on the time axis, the crosshair and the tooltip. Default: the chart's own. */
|
|
171
|
+
timeFormatter?: TimeFormatter;
|
|
172
|
+
/** Settings of Renko, Line Break, Kagi, Point & Figure and range bars. */
|
|
173
|
+
chartTypeOptions?: ChartTypeOptions;
|
|
174
|
+
/** Mark the highest high and lowest low on screen with a line and a price tag. */
|
|
175
|
+
highLowLines?: boolean;
|
|
176
|
+
/** The shapes the chart draws: price tags, axis pills and order badges square (default), rounded or pills. */
|
|
177
|
+
shapes?: import('./theme.js').ShapeConfig;
|
|
178
|
+
/**
|
|
179
|
+
* The chart for screen readers: a summary, what is on screen after the keys
|
|
180
|
+
* move it, comma and period to read the bars. On by default; labels in your
|
|
181
|
+
* language here; `false` leaves it out.
|
|
182
|
+
*/
|
|
183
|
+
a11y?: false | {
|
|
184
|
+
labels?: Partial<import('./a11y.js').ChartA11yLabels>;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Show the bars outside the symbol's regular hours (`SymbolInfo.sessions`):
|
|
188
|
+
* pre- and post-market. Default true; bars a day or longer are never left out.
|
|
189
|
+
*/
|
|
190
|
+
extendedHours?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/** A price in your words, e.g. `(p) => '$' + p.toFixed(2)`. */
|
|
193
|
+
export type PriceFormatter = (price: number) => string;
|
|
194
|
+
/**
|
|
195
|
+
* Prices in fractions of a point: `denominator` 32 prints 101.5 as `101'16`.
|
|
196
|
+
* `subDenominator` 2 or 4 splits each fraction in halves or quarters, printed
|
|
197
|
+
* as a last digit the way futures quote them (`101'165` is 101 and 16½ 32nds).
|
|
198
|
+
*/
|
|
199
|
+
export interface PriceFraction {
|
|
200
|
+
denominator: number;
|
|
201
|
+
subDenominator?: number;
|
|
202
|
+
}
|
|
203
|
+
/** Where a time is printed, for a `TimeFormatter`. */
|
|
204
|
+
export interface TimeFormatContext {
|
|
205
|
+
/**
|
|
206
|
+
* `'date'`: an axis label of a bar a day or longer; `'day'`: an axis label
|
|
207
|
+
* where a new day starts; `'time'`: an axis label within a day;
|
|
208
|
+
* `'crosshair'`: the crosshair's label and the tooltip.
|
|
209
|
+
*/
|
|
210
|
+
kind: 'date' | 'day' | 'time' | 'crosshair';
|
|
211
|
+
/** The chart's time zone: an IANA name, minutes east of UTC, or null for the browser's. */
|
|
212
|
+
timeZone: string | number | null;
|
|
111
213
|
}
|
|
214
|
+
/** A time (ms since the epoch) in your words. */
|
|
215
|
+
export type TimeFormatter = (time: number, context: TimeFormatContext) => string;
|
|
112
216
|
export interface SessionBreakOptions {
|
|
113
217
|
visible?: boolean;
|
|
114
218
|
color?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/types/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GACvC,YAAY,GAAG,cAAc,GAAG,UAAU,GAC1C,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,gBAAgB,GACjD,WAAW,GACX,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,iBAAiB,GAC5D,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/types/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GACvC,YAAY,GAAG,cAAc,GAAG,UAAU,GAC1C,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,gBAAgB,GACjD,WAAW,GACX,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,iBAAiB,GAC5D,YA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KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,YAAY,CAAC;CAC7C;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types/drawing.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Point, ViewportState } from './rendering.js';
|
|
2
|
-
|
|
2
|
+
import { OHLCBar } from './ohlc.js';
|
|
3
|
+
export type DrawingToolType = 'trendLine' | 'horizontalLine' | 'horizontalRay' | 'verticalLine' | 'ray' | 'extendedLine' | 'crossLine' | 'trendAngle' | 'infoLine' | 'parallelChannel' | 'regressionChannel' | 'fibRetracement' | 'fibExtension' | 'fibTimeZones' | 'fibChannel' | 'fibSpeedResistanceFan' | 'rectangle' | 'ellipse' | 'triangle' | 'circle' | 'pitchfork' | 'schiffPitchfork' | 'modifiedSchiffPitchfork' | 'elliottWave' | 'xabcdPattern' | 'abcdPattern' | 'headAndShoulders' | 'priceRange' | 'dateRange' | 'dateAndPriceRange' | 'measure' | 'text' | 'arrow' | 'priceLabel' | 'gannFan' | 'gannBox' | 'cyclicLines' | 'anchoredVWAP' | 'volumeProfileRange' | 'riskReward' | 'note' | 'callout' | 'flag' | 'arrowMark' | 'icon' | 'brush' | 'highlighter' | 'path' | 'polyline' | 'curve' | 'arc' | 'fibCircles' | 'fibSpiral' | 'fibArcs' | 'fibWedge' | 'pitchfan' | 'gannSquare' | 'elliottImpulse' | 'elliottCorrection' | 'elliottTriangle' | 'elliottDoubleCombo' | 'elliottTripleCombo' | 'threeDrives' | 'cypherPattern' | 'timeCycles' | 'sineLine' | 'forecast' | 'projection' | 'barsPattern';
|
|
3
4
|
export interface AnchorPoint {
|
|
4
5
|
time: number;
|
|
5
6
|
price: number;
|
|
@@ -20,19 +21,102 @@ export interface DrawingState {
|
|
|
20
21
|
style: DrawingStyle;
|
|
21
22
|
visible: boolean;
|
|
22
23
|
locked: boolean;
|
|
24
|
+
/** The tool's own settings (levels, extend left/right…); see `DrawingDescriptor.options`. */
|
|
25
|
+
options?: DrawingOptions;
|
|
26
|
+
/** The group it belongs to: drawings selected, hidden and locked together. */
|
|
27
|
+
group?: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
23
31
|
meta?: Record<string, unknown>;
|
|
24
32
|
}
|
|
33
|
+
/** One level of a Fibonacci or Gann tool: a ratio, shown or not, in its own colour. */
|
|
34
|
+
export interface DrawingLevel {
|
|
35
|
+
value: number;
|
|
36
|
+
visible: boolean;
|
|
37
|
+
/** CSS colour; the drawing's colour when left out. */
|
|
38
|
+
color?: string;
|
|
39
|
+
}
|
|
40
|
+
export type DrawingOptionValue = boolean | number | string | DrawingLevel[];
|
|
41
|
+
/** A drawing's settings beyond the shared style, by key. Missing keys take the tool's defaults. */
|
|
42
|
+
export type DrawingOptions = Record<string, DrawingOptionValue>;
|
|
43
|
+
/** A setting a drawing tool offers beyond the shared style, with its default. */
|
|
44
|
+
export type DrawingOptionDef = {
|
|
45
|
+
kind: 'boolean';
|
|
46
|
+
label: string;
|
|
47
|
+
default: boolean;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'number';
|
|
50
|
+
label: string;
|
|
51
|
+
default: number;
|
|
52
|
+
min?: number;
|
|
53
|
+
max?: number;
|
|
54
|
+
step?: number;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'choice';
|
|
57
|
+
label: string;
|
|
58
|
+
default: string;
|
|
59
|
+
choices: readonly {
|
|
60
|
+
value: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}[];
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'levels';
|
|
65
|
+
label: string;
|
|
66
|
+
default: readonly DrawingLevel[];
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'text';
|
|
69
|
+
label: string;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
export type DrawingOptionDefs = Readonly<Record<string, DrawingOptionDef>>;
|
|
25
73
|
export interface DrawingDescriptor {
|
|
26
74
|
type: DrawingToolType;
|
|
27
75
|
name: string;
|
|
28
76
|
requiredAnchors: number;
|
|
29
77
|
singleClick?: boolean;
|
|
78
|
+
/** Settings the tool offers beyond the shared style; a settings dialog is built from them. */
|
|
79
|
+
options?: DrawingOptionDefs;
|
|
80
|
+
/** It fills an area with `style.fillColor` (a settings dialog offers the fill). */
|
|
81
|
+
fill?: boolean;
|
|
82
|
+
/** It draws `style.text` (a settings dialog offers the text and its size). */
|
|
83
|
+
text?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* How it is drawn with the pointer. 'clicks' (the default): a click per
|
|
86
|
+
* anchor up to `requiredAnchors`. 'freehand': press and drag, a point every
|
|
87
|
+
* few pixels, release to finish. 'path': a click per point, at least
|
|
88
|
+
* `requiredAnchors` and at most `maxAnchors`; a double-click, Enter or a
|
|
89
|
+
* click on the last point finishes it.
|
|
90
|
+
*/
|
|
91
|
+
creation?: 'clicks' | 'freehand' | 'path';
|
|
92
|
+
/** Most points a 'path' takes (100 when left out). */
|
|
93
|
+
maxAnchors?: number;
|
|
30
94
|
}
|
|
31
95
|
export interface DrawingPlugin {
|
|
32
96
|
descriptor: DrawingDescriptor;
|
|
33
97
|
render(ctx: CanvasRenderingContext2D, state: DrawingState, viewport: ViewportState, selected: boolean): void;
|
|
34
98
|
hitTest(point: Point, state: DrawingState, viewport: ViewportState, tolerance: number): boolean;
|
|
35
99
|
hitTestAnchor(point: Point, state: DrawingState, viewport: ViewportState, tolerance: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* The drawing after handle `index` (from `hitTestAnchor`) is dragged to
|
|
102
|
+
* `anchor`. Without it, the handle is anchor `index` and moves there. A
|
|
103
|
+
* tool with handles that are not anchors (a position's target, say)
|
|
104
|
+
* changes its options instead.
|
|
105
|
+
*/
|
|
106
|
+
moveHandle?(state: DrawingState, index: number, anchor: AnchorPoint): DrawingState;
|
|
107
|
+
/**
|
|
108
|
+
* The prices of the drawing's lines at `time` (what an alert on it
|
|
109
|
+
* crosses), or null where it doesn't reach. Tools without it take no alerts.
|
|
110
|
+
* With `viewport` the lines follow the chart as drawn: straight across bars
|
|
111
|
+
* (not clock time, so a weekend gap doesn't bend them) and on a log scale
|
|
112
|
+
* straight in log price.
|
|
113
|
+
*/
|
|
114
|
+
priceAt?(state: DrawingState, time: number, viewport?: ViewportState): number[] | null;
|
|
115
|
+
/**
|
|
116
|
+
* For a tool drawn from the chart's bars (an anchored VWAP, a volume
|
|
117
|
+
* profile): the chart hands it a getter for them when it is registered.
|
|
118
|
+
*/
|
|
119
|
+
setDataGetter?(getter: () => readonly OHLCBar[]): void;
|
|
36
120
|
}
|
|
37
121
|
export declare const DEFAULT_DRAWING_STYLE: DrawingStyle;
|
|
38
122
|
//# sourceMappingURL=drawing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawing.d.ts","sourceRoot":"","sources":["../../src/types/drawing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"drawing.d.ts","sourceRoot":"","sources":["../../src/types/drawing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,eAAe,GACvB,WAAW,GAAG,gBAAgB,GAAG,eAAe,GAAG,cAAc,GAAG,KAAK,GAAG,cAAc,GAC1F,WAAW,GAAG,YAAY,GAAG,UAAU,GACvC,iBAAiB,GAAG,mBAAmB,GACvC,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,YAAY,GAAG,uBAAuB,GAC3F,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAC/C,WAAW,GAAG,iBAAiB,GAAG,yBAAyB,GAAG,aAAa,GAC3E,cAAc,GAAG,aAAa,GAAG,kBAAkB,GACnD,YAAY,GAAG,WAAW,GAAG,mBAAmB,GAAG,SAAS,GAC5D,MAAM,GAAG,OAAO,GAAG,YAAY,GAC/B,SAAS,GAAG,SAAS,GAAG,aAAa,GACrC,cAAc,GACd,oBAAoB,GACpB,YAAY,GACZ,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAClD,OAAO,GAAG,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAC/D,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,GAC/E,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,oBAAo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;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1C,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,MAAM,CACJ,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,OAAO,GAChB,IAAI,CAAC;IACR,OAAO,CACL,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IACX,aAAa,CACX,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC;IACV;;;;;OAKG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC;IACnF;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACvF;;;OAGG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,MAAM,SAAS,OAAO,EAAE,GAAG,IAAI,CAAC;CACxD;AAED,eAAO,MAAM,qBAAqB,EAAE,YAOnC,CAAC"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { OHLCBar, DataSeries } from './ohlc.js';
|
|
2
2
|
import { Point } from './rendering.js';
|
|
3
3
|
import { IndicatorValue } from './indicator.js';
|
|
4
|
-
|
|
4
|
+
import { DrawingToolType } from './drawing.js';
|
|
5
|
+
import { SymbolInfo } from './symbol.js';
|
|
6
|
+
export type ChartEventType = 'crosshairMove' | 'crosshairLeave' | 'click' | 'barClick' | 'visibleRangeChange' | 'priceRangeChange' | 'zoomChange' | 'dataUpdate' | 'historyLoad' | 'symbolInfoChange' | 'indicatorAdd' | 'indicatorRemove' | 'paneResize'
|
|
7
|
+
/** A pane was folded or opened, maximised or put back, or moved up or down. */
|
|
8
|
+
| 'paneChange' | 'indicatorUpdate' | 'indicatorChange' | 'themeChange' | 'resize' | 'orderPlace' | 'orderModify' | 'orderCancel' | 'positionClose' | 'positionReverse' | 'positionModify' | 'executionFill' | 'ordersChange' | 'positionsChange' | 'executionError' | 'bracketPlace' | 'drawingCreate' | 'drawingUpdate' | 'drawingDoubleClick' | 'drawingContextMenu' | 'toolModeChange' | 'chartContextMenu' | 'priceAxisAdd' | 'drawingRemove' | 'drawingToolChange' | 'signalMarkerAdd' | 'signalMarkerRemove'
|
|
9
|
+
/** The pointer went onto a signal marker, or off it (`marker: null`). */
|
|
10
|
+
| 'signalMarkerHover'
|
|
11
|
+
/** A signal marker was clicked. */
|
|
12
|
+
| 'signalMarkerClick' | 'tradeZoneAdd' | 'tradeZoneRemove' | 'alertAdd' | 'alertRemove' | 'alertTriggered'
|
|
13
|
+
/** An alert reached its `expiresAt` without firing. */
|
|
14
|
+
| 'alertExpired' | 'symbolSeriesRequest'
|
|
15
|
+
/** A replay step: the bar forming, when it opened, and up to when the replay has shown. */
|
|
16
|
+
| 'replayStep'
|
|
17
|
+
/** A replay started playing, paused or ended. */
|
|
18
|
+
| 'replayState' | 'alertUpdate'
|
|
19
|
+
/**
|
|
20
|
+
* Something a saved layout holds may have changed: drawings, indicators,
|
|
21
|
+
* alerts, the chart type or the theme. Fires often; debounce it.
|
|
22
|
+
*/
|
|
23
|
+
| 'stateChange'
|
|
24
|
+
/** The chart type changed (`setChartType`). */
|
|
25
|
+
| 'chartTypeChange'
|
|
26
|
+
/** The stream moved to another symbol (`connect`, `switchStream`). */
|
|
27
|
+
| 'symbolChange'
|
|
28
|
+
/** The stream moved to another timeframe (`connect`, `setTimeframe`, `switchStream`). */
|
|
29
|
+
| 'timeframeChange'
|
|
30
|
+
/** The undo history changed: whether there is something to undo or redo. */
|
|
31
|
+
| 'historyChange'
|
|
32
|
+
/** The drawings selected changed. */
|
|
33
|
+
| 'drawingSelect';
|
|
5
34
|
export interface ChartEvent<T = unknown> {
|
|
6
35
|
type: ChartEventType;
|
|
7
36
|
timestamp: number;
|
|
@@ -106,6 +135,28 @@ export interface DrawingCreatePayload {
|
|
|
106
135
|
export interface DrawingRemovePayload {
|
|
107
136
|
id: string;
|
|
108
137
|
}
|
|
138
|
+
/** Where a right-click landed: the price pane, another pane, or an axis. */
|
|
139
|
+
export type ChartContextArea = 'plot' | 'pane' | 'priceAxis' | 'timeAxis';
|
|
140
|
+
/**
|
|
141
|
+
* Payload for `chartContextMenu`: a right-click off any drawing, where it was
|
|
142
|
+
* (`x`, `y` in the chart's pixels), and the price and bar time there when the
|
|
143
|
+
* area has them (the price pane: both; the price axis: price; the time axis: time).
|
|
144
|
+
*/
|
|
145
|
+
export interface ChartContextMenuPayload {
|
|
146
|
+
area: ChartContextArea;
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
price?: number;
|
|
150
|
+
time?: number;
|
|
151
|
+
/** For a pane: the indicator whose pane it is. */
|
|
152
|
+
pane?: string;
|
|
153
|
+
}
|
|
154
|
+
/** Payload for `priceAxisAdd`: the "+" by the price axis was clicked at `price`. */
|
|
155
|
+
export interface PriceAxisAddPayload {
|
|
156
|
+
price: number;
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
}
|
|
109
160
|
export interface SignalMarkerAddPayload {
|
|
110
161
|
id: string;
|
|
111
162
|
source: string;
|
|
@@ -123,13 +174,41 @@ export interface TradeZoneRemovePayload {
|
|
|
123
174
|
}
|
|
124
175
|
export interface AlertPayload {
|
|
125
176
|
id: string;
|
|
177
|
+
/** The level; for an alert on another line, that line's latest value; NaN for a move. */
|
|
126
178
|
price: number;
|
|
127
179
|
condition: string;
|
|
128
180
|
message?: string;
|
|
129
181
|
triggered: boolean;
|
|
182
|
+
/** What it watches: `'price'` or `<instanceId>:<key>`. */
|
|
183
|
+
channel?: string;
|
|
184
|
+
label?: string;
|
|
185
|
+
/** The line it compares with. */
|
|
186
|
+
target?: string;
|
|
187
|
+
/** The drawing it watches. */
|
|
188
|
+
drawingId?: string;
|
|
189
|
+
/** A move: the percent, within how many bars. */
|
|
190
|
+
percent?: number;
|
|
191
|
+
bars?: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Payload for `historyLoad`: paging older bars in. `loading` when a request
|
|
195
|
+
* starts, then `loaded` (`count` bars added), `end` (no older bars) or
|
|
196
|
+
* `error`.
|
|
197
|
+
*/
|
|
198
|
+
export interface HistoryLoadPayload {
|
|
199
|
+
state: 'loading' | 'loaded' | 'end' | 'error';
|
|
200
|
+
count: number;
|
|
201
|
+
error?: string;
|
|
202
|
+
}
|
|
203
|
+
/** What changed on an indicator (`indicatorChange`). */
|
|
204
|
+
export interface IndicatorSettingsChangePayload {
|
|
205
|
+
instanceId: string;
|
|
206
|
+
change: 'visible' | 'style' | 'levels' | 'params' | 'pane' | 'scale';
|
|
130
207
|
}
|
|
131
208
|
export interface ChartEventMap {
|
|
132
209
|
crosshairMove: CrosshairMovePayload;
|
|
210
|
+
/** The pointer left the plot; the crosshair is gone. */
|
|
211
|
+
crosshairLeave: Record<string, never>;
|
|
133
212
|
click: {
|
|
134
213
|
x: number;
|
|
135
214
|
y: number;
|
|
@@ -139,8 +218,51 @@ export interface ChartEventMap {
|
|
|
139
218
|
priceRangeChange: PriceRangeChangePayload;
|
|
140
219
|
zoomChange: ZoomChangePayload;
|
|
141
220
|
dataUpdate: DataSeries;
|
|
221
|
+
/** Older bars are being paged in, or finished loading. */
|
|
222
|
+
historyLoad: HistoryLoadPayload;
|
|
223
|
+
/** What is known about the symbol on the chart changed (`setSymbolInfo`, or the stream's adapter). */
|
|
224
|
+
symbolInfoChange: {
|
|
225
|
+
info: SymbolInfo | null;
|
|
226
|
+
};
|
|
227
|
+
chartTypeChange: {
|
|
228
|
+
type: string;
|
|
229
|
+
previous: string;
|
|
230
|
+
};
|
|
231
|
+
symbolChange: {
|
|
232
|
+
symbol: string;
|
|
233
|
+
previous: string | null;
|
|
234
|
+
};
|
|
235
|
+
timeframeChange: {
|
|
236
|
+
timeframe: string;
|
|
237
|
+
previous: string | null;
|
|
238
|
+
};
|
|
239
|
+
historyChange: {
|
|
240
|
+
canUndo: boolean;
|
|
241
|
+
canRedo: boolean;
|
|
242
|
+
};
|
|
243
|
+
/** The selected drawings' ids, the primary (its handles show) first; none: nothing selected. */
|
|
244
|
+
drawingSelect: {
|
|
245
|
+
ids: string[];
|
|
246
|
+
primary: string | null;
|
|
247
|
+
};
|
|
142
248
|
indicatorAdd: IndicatorChangePayload;
|
|
143
249
|
indicatorRemove: IndicatorChangePayload;
|
|
250
|
+
/** An indicator pane was resized (by dragging its divider or `setPanelSize`). */
|
|
251
|
+
paneResize: {
|
|
252
|
+
instanceId: string;
|
|
253
|
+
size: number;
|
|
254
|
+
};
|
|
255
|
+
/** A pane was folded or opened, maximised or put back, or moved up or down. */
|
|
256
|
+
paneChange: {
|
|
257
|
+
instanceId: string;
|
|
258
|
+
change: 'collapsed' | 'maximized' | 'order' | 'scale';
|
|
259
|
+
};
|
|
260
|
+
/** Indicator values were recomputed from bar index `from` on: new bars, a live tick, a replay step. */
|
|
261
|
+
indicatorUpdate: {
|
|
262
|
+
from: number;
|
|
263
|
+
};
|
|
264
|
+
/** One indicator's settings changed: shown or hidden, restyled, new levels or inputs, moved to another pane. */
|
|
265
|
+
indicatorChange: IndicatorSettingsChangePayload;
|
|
144
266
|
themeChange: ThemeChangePayload;
|
|
145
267
|
resize: ResizePayload;
|
|
146
268
|
orderPlace: OrderPlacePayload;
|
|
@@ -152,15 +274,47 @@ export interface ChartEventMap {
|
|
|
152
274
|
executionError: ExecutionErrorPayload;
|
|
153
275
|
drawingCreate: DrawingCreatePayload;
|
|
154
276
|
drawingRemove: DrawingRemovePayload;
|
|
277
|
+
/** The active drawing tool changed — picked, finished, or cancelled (`tool: null`). */
|
|
278
|
+
drawingToolChange: {
|
|
279
|
+
tool: DrawingToolType | null;
|
|
280
|
+
};
|
|
155
281
|
signalMarkerAdd: SignalMarkerAddPayload;
|
|
156
282
|
signalMarkerRemove: SignalMarkerRemovePayload;
|
|
283
|
+
signalMarkerHover: {
|
|
284
|
+
marker: import('./signal.js').SignalMarker | null;
|
|
285
|
+
x: number;
|
|
286
|
+
y: number;
|
|
287
|
+
};
|
|
288
|
+
signalMarkerClick: {
|
|
289
|
+
marker: import('./signal.js').SignalMarker;
|
|
290
|
+
x: number;
|
|
291
|
+
y: number;
|
|
292
|
+
};
|
|
157
293
|
tradeZoneAdd: TradeZoneAddPayload;
|
|
158
294
|
tradeZoneRemove: TradeZoneRemovePayload;
|
|
159
295
|
alertAdd: AlertPayload;
|
|
160
296
|
alertRemove: AlertRemovePayload;
|
|
161
297
|
alertTriggered: AlertPayload;
|
|
298
|
+
alertExpired: AlertPayload;
|
|
299
|
+
/** An indicator reads a symbol the chart has no bars of: give them with `setSymbolSeries`. */
|
|
300
|
+
symbolSeriesRequest: {
|
|
301
|
+
symbol: string;
|
|
302
|
+
};
|
|
303
|
+
replayStep: ReplayStepPayload;
|
|
304
|
+
replayState: {
|
|
305
|
+
state: 'playing' | 'paused' | 'stopped';
|
|
306
|
+
};
|
|
162
307
|
alertUpdate: AlertPayload;
|
|
163
308
|
}
|
|
309
|
+
/** Payload for `replayStep`. */
|
|
310
|
+
export interface ReplayStepPayload {
|
|
311
|
+
/** The chart's bar forming now. */
|
|
312
|
+
barIndex: number;
|
|
313
|
+
/** When it opened. */
|
|
314
|
+
time: number;
|
|
315
|
+
/** The replay has shown everything before this time (the next step's). */
|
|
316
|
+
until: number;
|
|
317
|
+
}
|
|
164
318
|
export interface AlertRemovePayload {
|
|
165
319
|
id: string;
|
|
166
320
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,gBAAgB,GAChB,OAAO,GACP,UAAU,GACV,oBAAoB,GACpB,kBAAkB,GAClB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,YAAY;AACd,+EAA+E;GAC7E,YAAY,GACZ,iBAAiB,GACjB,iBAAiB,GACjB,aAAa,GACb,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,aAAa,GACb,eAAe,GACf,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,GACf,oBAAoB,GACpB,oBAAoB,GACpB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,iBAAiB,GACjB,oBAAoB;AACtB,yEAAyE;GACvE,mBAAmB;AACrB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CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/F,iBAAiB,EAAE;QAAE,MAAM,EAAE,OAAO,aAAa,EAAE,YAAY,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxF,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,sBAAsB,CAAC;IACxC,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,YAAY,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,8FAA8F;IAC9F,mBAAmB,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,WAAW,EAAE;QAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC;IACzD,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,gCAAgC;AAChC,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionState } from './realtime.js';
|
|
2
|
-
import { TradingOrder, OrderSide, OrderPlaceIntent, OrderModifyIntent, OrderCancelIntent, PositionModifyIntent, PositionCloseIntent } from './trading.js';
|
|
2
|
+
import { TradingOrder, OrderSide, OrderPlaceIntent, OrderModifyIntent, OrderCancelIntent, PositionModifyIntent, PositionCloseIntent, PositionReverseIntent } from './trading.js';
|
|
3
3
|
export interface ExecutionConfig {
|
|
4
4
|
/** Account identifier, when the broker scopes by account. */
|
|
5
5
|
account?: string;
|
|
@@ -8,12 +8,20 @@ export interface ExecutionConfig {
|
|
|
8
8
|
meta?: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
10
|
export type ExecutionEventType = 'orders' | 'positions' | 'fill' | 'connectionChange' | 'error';
|
|
11
|
+
/** Why a fill happened: an order, a position closed by hand or reversed, or its stop-loss or take-profit. */
|
|
12
|
+
export type FillReason = 'order' | 'close' | 'reverse' | 'stopLoss' | 'takeProfit';
|
|
11
13
|
export interface FillEvent {
|
|
12
14
|
orderId: string;
|
|
13
15
|
side: OrderSide;
|
|
14
16
|
price: number;
|
|
15
17
|
quantity: number;
|
|
18
|
+
/** When it filled (ms since the epoch). */
|
|
16
19
|
time: number;
|
|
20
|
+
/** The position it opened or closed. */
|
|
21
|
+
positionId?: string;
|
|
22
|
+
reason?: FillReason;
|
|
23
|
+
/** Profit or loss it realised, for a fill that closes a position. */
|
|
24
|
+
pnl?: number;
|
|
17
25
|
}
|
|
18
26
|
export interface ExecutionError {
|
|
19
27
|
message: string;
|
|
@@ -51,6 +59,17 @@ export interface ExecutionAdapter {
|
|
|
51
59
|
modifyPosition(intent: PositionModifyIntent): Promise<void>;
|
|
52
60
|
/** Close a position (full close). */
|
|
53
61
|
closePosition(intent: PositionCloseIntent): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Close a position and open the same size the other way. Optional: without
|
|
64
|
+
* it, the chart closes the position and places a market order instead.
|
|
65
|
+
*/
|
|
66
|
+
reversePosition?(intent: PositionReverseIntent): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* The market price, live or replayed, and its time (ms). Optional: a paper
|
|
69
|
+
* adapter fills pending orders and stops against it and stamps fills with
|
|
70
|
+
* the time. The chart calls it with the replayed price during a replay.
|
|
71
|
+
*/
|
|
72
|
+
setMarkPrice?(price: number, time?: number): void;
|
|
54
73
|
on<T = unknown>(event: ExecutionEventType, listener: ExecutionListener<T>): void;
|
|
55
74
|
off<T = unknown>(event: ExecutionEventType, listener: ExecutionListener<T>): void;
|
|
56
75
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAWtB,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,MAAM,kBAAkB,GAC1B,QAAQ,GACR,WAAW,GACX,MAAM,GACN,kBAAkB,GAClB,OAAO,CAAC;AAEZ,6GAA6G;AAC7G,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAEnF,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,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AI,CAAC,CAAC;IAC5D,qCAAqC;IACrC,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D;;;OAGG;IACH,eAAe,CAAC,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D;;;;OAIG;IACH,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAElD,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAElF,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,4 +12,8 @@ export * from './execution.js';
|
|
|
12
12
|
export * from './signal.js';
|
|
13
13
|
export * from './realtime.js';
|
|
14
14
|
export * from './finance.js';
|
|
15
|
+
export * from './symbol.js';
|
|
16
|
+
export * from './quote.js';
|
|
17
|
+
export * from './news.js';
|
|
18
|
+
export * from './a11y.js';
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|