acttrader-charts 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/{MACD-BbNppL1E.d.cts → MACD-CjgSMwdG.d.cts} +19 -1
- package/dist/{MACD-BbNppL1E.d.ts → MACD-CjgSMwdG.d.ts} +19 -1
- package/dist/index.cjs +549 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +549 -142
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/webview/chart.html +67 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,17 @@ Dual ESM/CJS output, TypeScript-first.
|
|
|
13
13
|
npm install acttrader-charts
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
### Beta releases
|
|
17
|
+
|
|
18
|
+
Pre-release builds are published under the `beta` dist-tag and use prerelease semver (`X.Y.Z-beta.N`). They never move the default `latest` tag, so existing consumers are unaffected.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install acttrader-charts@beta # opt in to the latest beta
|
|
22
|
+
npm install acttrader-charts@1.1.0-beta.1 # pin a specific beta
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`npm install acttrader-charts` and existing semver ranges (`^1.0.0`, `~1.0.0`) continue to resolve only to stable releases — by spec, semver ranges exclude prerelease versions.
|
|
26
|
+
|
|
16
27
|
---
|
|
17
28
|
|
|
18
29
|
## Basic Usage
|
|
@@ -164,6 +175,8 @@ chart.setLevels([], 'label', 'price', 'pending'); // clear all of one type
|
|
|
164
175
|
|
|
165
176
|
**Visual differentiation:** pending orders and ES/EL entry working orders render as **dashed** lines tinted by side (`pendingBuyLine` green / `pendingSellLine` red). True open positions render as **solid** lines: green/red when `pnl` is set (sign-colored), otherwise `positionLine` (purple/indigo). The info-box border matches the line color. Each true open position also gets a small colored price tag on the right-side price axis showing the entry price — same visual language as the Bid/Ask tag — so you can read the entry price without hunting for the info box.
|
|
166
177
|
|
|
178
|
+
**Brackets follow entry on drag:** when the entry line of a pending order, draft order, or an open position with `entryPriceEditable: true` is dragged, any existing `stopLossPrice` / `takeProfitPrice` brackets translate along with it by the same price delta. The distance between entry and each bracket is whatever the user currently sees — if they manually drag SL or TP to a new price, that new distance becomes the anchor for the next entry drag. Missing brackets aren't auto-created. On confirm, `tradeLevelEdit` carries all translated fields together in one `changes[]` array; on mobile (`hideLevelConfirmCancel`) the three changes are applied as one atomic event.
|
|
179
|
+
|
|
167
180
|
**TFC events:**
|
|
168
181
|
|
|
169
182
|
```ts
|
|
@@ -263,6 +276,7 @@ When `enableTrading` is on and live BID/ASK data is streaming, hovering / activa
|
|
|
263
276
|
| `tradeDisplayFilter` | | `"all"` | Which TFC levels are visible: `"all"` · `"positions"` · `"orders"` · `"none"` |
|
|
264
277
|
| `positionRenderStyle` | | auto | Force position render style: `"line"` or `"dot"` |
|
|
265
278
|
| `hideLevelConfirmCancel` | | `false` | Hide on-canvas ✓/✗ confirm-cancel buttons for TFC level edits |
|
|
279
|
+
| `tradeLevelButtonScale` | | `1` | Multiplier for trade-level Confirm/Cancel/Edit/Close button radii and gaps. Scales visuals **and** hit/drag areas together — raise it on touch devices for larger tap targets. Clamped to `[1, 3]`. Also settable at runtime via `chart.setTradeLevelButtonScale(scale)` |
|
|
266
280
|
| `tfcEnabled` | | `true` | Enable the TFC toggle button in the top bar. When `false`, TFC is completely disabled — the toggle button is hidden and all trade levels, draft orders, and the floating trade button are suppressed |
|
|
267
281
|
| `levelClusteringEnabled` | | `true` | Enable trade-level fan-out clustering; overlapping levels group into expandable badges |
|
|
268
282
|
| `clusterThresholdDistance` | | `20` | Pixel proximity threshold for clustering (only when `levelClusteringEnabled` is `true`) |
|
|
@@ -604,6 +618,53 @@ if (saved) chart.setState(JSON.parse(saved) as ChartState);
|
|
|
604
618
|
chart.destroy(): void
|
|
605
619
|
```
|
|
606
620
|
|
|
621
|
+
### Dismissing open UI
|
|
622
|
+
|
|
623
|
+
Closes any open flyout/modal/dropdown/popover (quantity edit, symbol picker,
|
|
624
|
+
indicator settings, chart settings, trade popover, topbar dropdowns, mobile
|
|
625
|
+
drawing flyout) in a single call. Designed for wiring to the system back
|
|
626
|
+
button / gesture in PWAs, installed web apps, and native wrapper hosts.
|
|
627
|
+
|
|
628
|
+
```ts
|
|
629
|
+
chart.dismissAllUI(): boolean // true if anything was dismissed, false if nothing was open
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
Paired with the `uiStateChange` event so you can track whether a back action
|
|
633
|
+
should dismiss chart UI or fall through to your own navigation:
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
chart.on('uiStateChange', ({ hasOpenUI }) => {
|
|
637
|
+
// hasOpenUI === true when at least one flyout/modal/dropdown is open
|
|
638
|
+
});
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
**PWA — proper History API wiring** (back press dismisses flyout without
|
|
642
|
+
navigating away from the page):
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
let pushedStateForUI = false;
|
|
646
|
+
|
|
647
|
+
chart.on('uiStateChange', ({ hasOpenUI }) => {
|
|
648
|
+
if (hasOpenUI && !pushedStateForUI) {
|
|
649
|
+
history.pushState({ chartUI: true }, '');
|
|
650
|
+
pushedStateForUI = true;
|
|
651
|
+
} else if (!hasOpenUI) {
|
|
652
|
+
pushedStateForUI = false;
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
window.addEventListener('popstate', () => {
|
|
657
|
+
if (chart.dismissAllUI()) pushedStateForUI = false;
|
|
658
|
+
});
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
**Minimum wiring** (back press closes flyout AND advances browser history —
|
|
662
|
+
fine for single-screen apps without client routing):
|
|
663
|
+
|
|
664
|
+
```ts
|
|
665
|
+
window.addEventListener('popstate', () => chart.dismissAllUI());
|
|
666
|
+
```
|
|
667
|
+
|
|
607
668
|
---
|
|
608
669
|
|
|
609
670
|
## Built-in Indicators
|
|
@@ -865,6 +865,14 @@ interface ChartConfig {
|
|
|
865
865
|
* Default: `false`.
|
|
866
866
|
*/
|
|
867
867
|
hideLevelConfirmCancel?: boolean;
|
|
868
|
+
/**
|
|
869
|
+
* Multiplier applied to the Confirm (✓), Cancel (✗), Edit (✎), and Close (×)
|
|
870
|
+
* buttons on trade-level overlays (both main-level and SL/TP bracket boxes).
|
|
871
|
+
* Scales button radii and inter-button gaps so visual size AND hit/drag areas
|
|
872
|
+
* grow together — useful for touch targets.
|
|
873
|
+
* Clamped to `[1, 3]`. Default: `1`.
|
|
874
|
+
*/
|
|
875
|
+
tradeLevelButtonScale?: number;
|
|
868
876
|
/**
|
|
869
877
|
* When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
|
|
870
878
|
* Default: `false` — the toggle is hidden.
|
|
@@ -1093,12 +1101,16 @@ type ChartEventMap = {
|
|
|
1093
1101
|
isFullscreen: boolean;
|
|
1094
1102
|
};
|
|
1095
1103
|
/** Emitted on every mouse-move while dragging a trade level line (before confirm).
|
|
1096
|
-
* `bracketType` is present when dragging an SL/TP bracket line; absent for main entry drag.
|
|
1104
|
+
* `bracketType` is present when dragging an SL/TP bracket line; absent for main entry drag.
|
|
1105
|
+
* `derivedSLPrice` / `derivedTPPrice` are present during a main-entry drag in follow-brackets mode
|
|
1106
|
+
* so external panels can mirror the SL/TP translation live (keeps validation from flickering). */
|
|
1097
1107
|
tradeLevelDrag: {
|
|
1098
1108
|
label: string;
|
|
1099
1109
|
newPrice: number;
|
|
1100
1110
|
data: unknown;
|
|
1101
1111
|
bracketType?: 'stopLoss' | 'takeProfit';
|
|
1112
|
+
derivedSLPrice?: number;
|
|
1113
|
+
derivedTPPrice?: number;
|
|
1102
1114
|
isFullscreen: boolean;
|
|
1103
1115
|
};
|
|
1104
1116
|
/** Emitted at the instant a bracket (SL/TP) drag begins — before any movement.
|
|
@@ -1155,6 +1167,12 @@ type ChartEventMap = {
|
|
|
1155
1167
|
tfcToggle: {
|
|
1156
1168
|
enabled: boolean;
|
|
1157
1169
|
};
|
|
1170
|
+
/** Emitted whenever any dismissible UI (flyout, modal, dropdown, popover) opens or closes.
|
|
1171
|
+
* Hosts (native wrappers, PWAs) listen to track whether a back button / gesture should
|
|
1172
|
+
* dismiss chart UI vs. navigate. Pair with `dismissAllUI()` to wire platform back events. */
|
|
1173
|
+
uiStateChange: {
|
|
1174
|
+
hasOpenUI: boolean;
|
|
1175
|
+
};
|
|
1158
1176
|
/** Emitted when the user confirms all edits to a level — replaces separate tradeLevelDragEnd / tradeLevelBracketDrag events. */
|
|
1159
1177
|
tradeLevelEdit: {
|
|
1160
1178
|
label: string;
|
|
@@ -865,6 +865,14 @@ interface ChartConfig {
|
|
|
865
865
|
* Default: `false`.
|
|
866
866
|
*/
|
|
867
867
|
hideLevelConfirmCancel?: boolean;
|
|
868
|
+
/**
|
|
869
|
+
* Multiplier applied to the Confirm (✓), Cancel (✗), Edit (✎), and Close (×)
|
|
870
|
+
* buttons on trade-level overlays (both main-level and SL/TP bracket boxes).
|
|
871
|
+
* Scales button radii and inter-button gaps so visual size AND hit/drag areas
|
|
872
|
+
* grow together — useful for touch targets.
|
|
873
|
+
* Clamped to `[1, 3]`. Default: `1`.
|
|
874
|
+
*/
|
|
875
|
+
tradeLevelButtonScale?: number;
|
|
868
876
|
/**
|
|
869
877
|
* When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
|
|
870
878
|
* Default: `false` — the toggle is hidden.
|
|
@@ -1093,12 +1101,16 @@ type ChartEventMap = {
|
|
|
1093
1101
|
isFullscreen: boolean;
|
|
1094
1102
|
};
|
|
1095
1103
|
/** Emitted on every mouse-move while dragging a trade level line (before confirm).
|
|
1096
|
-
* `bracketType` is present when dragging an SL/TP bracket line; absent for main entry drag.
|
|
1104
|
+
* `bracketType` is present when dragging an SL/TP bracket line; absent for main entry drag.
|
|
1105
|
+
* `derivedSLPrice` / `derivedTPPrice` are present during a main-entry drag in follow-brackets mode
|
|
1106
|
+
* so external panels can mirror the SL/TP translation live (keeps validation from flickering). */
|
|
1097
1107
|
tradeLevelDrag: {
|
|
1098
1108
|
label: string;
|
|
1099
1109
|
newPrice: number;
|
|
1100
1110
|
data: unknown;
|
|
1101
1111
|
bracketType?: 'stopLoss' | 'takeProfit';
|
|
1112
|
+
derivedSLPrice?: number;
|
|
1113
|
+
derivedTPPrice?: number;
|
|
1102
1114
|
isFullscreen: boolean;
|
|
1103
1115
|
};
|
|
1104
1116
|
/** Emitted at the instant a bracket (SL/TP) drag begins — before any movement.
|
|
@@ -1155,6 +1167,12 @@ type ChartEventMap = {
|
|
|
1155
1167
|
tfcToggle: {
|
|
1156
1168
|
enabled: boolean;
|
|
1157
1169
|
};
|
|
1170
|
+
/** Emitted whenever any dismissible UI (flyout, modal, dropdown, popover) opens or closes.
|
|
1171
|
+
* Hosts (native wrappers, PWAs) listen to track whether a back button / gesture should
|
|
1172
|
+
* dismiss chart UI vs. navigate. Pair with `dismissAllUI()` to wire platform back events. */
|
|
1173
|
+
uiStateChange: {
|
|
1174
|
+
hasOpenUI: boolean;
|
|
1175
|
+
};
|
|
1158
1176
|
/** Emitted when the user confirms all edits to a level — replaces separate tradeLevelDragEnd / tradeLevelBracketDrag events. */
|
|
1159
1177
|
tradeLevelEdit: {
|
|
1160
1178
|
label: string;
|