acttrader-charts 1.0.11 → 1.0.12
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 +71 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +71 -44
- package/dist/index.js.map +1 -1
- package/dist/webview/chart.html +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2100,7 +2100,7 @@ function drawLevel(ctx, level, layout, chartW, colors, theme, precision, hovered
|
|
|
2100
2100
|
ctx.restore();
|
|
2101
2101
|
if (draggable) {
|
|
2102
2102
|
drawGripHandle(ctx, gripX, boxY, boxH, colors, hovered);
|
|
2103
|
-
const BTN_ZONE_W = EDIT_R * 2 + EDIT_GAP + CLOSE_R * 2 + BOX_PAD_X / 2;
|
|
2103
|
+
const BTN_ZONE_W = hideConfirmCancel ? 0 : EDIT_R * 2 + EDIT_GAP + CLOSE_R * 2 + BOX_PAD_X / 2;
|
|
2104
2104
|
dragAreas.push({
|
|
2105
2105
|
label: level.label,
|
|
2106
2106
|
type: level.type,
|
|
@@ -2110,7 +2110,8 @@ function drawLevel(ctx, level, layout, chartW, colors, theme, precision, hovered
|
|
|
2110
2110
|
y: boxY,
|
|
2111
2111
|
w: GRIP_W + 2 + boxW - BTN_ZONE_W,
|
|
2112
2112
|
h: boxH,
|
|
2113
|
-
isBracket: false
|
|
2113
|
+
isBracket: false,
|
|
2114
|
+
isBox: true
|
|
2114
2115
|
});
|
|
2115
2116
|
dragAreas.push({
|
|
2116
2117
|
label: level.label,
|
|
@@ -2123,6 +2124,19 @@ function drawLevel(ctx, level, layout, chartW, colors, theme, precision, hovered
|
|
|
2123
2124
|
h: 8,
|
|
2124
2125
|
isBracket: false
|
|
2125
2126
|
});
|
|
2127
|
+
} else if (hideConfirmCancel && boxW > 0) {
|
|
2128
|
+
dragAreas.push({
|
|
2129
|
+
label: level.label,
|
|
2130
|
+
type: level.type,
|
|
2131
|
+
data: level.data,
|
|
2132
|
+
price: level.price,
|
|
2133
|
+
x: boxX,
|
|
2134
|
+
y: boxY,
|
|
2135
|
+
w: boxW,
|
|
2136
|
+
h: boxH,
|
|
2137
|
+
isBracket: false,
|
|
2138
|
+
isBox: true
|
|
2139
|
+
});
|
|
2126
2140
|
}
|
|
2127
2141
|
hoverAreas.push({
|
|
2128
2142
|
label: level.label,
|
|
@@ -16811,8 +16825,9 @@ var _ChartEngine = class _ChartEngine {
|
|
|
16811
16825
|
e.preventDefault();
|
|
16812
16826
|
const level = this.levels.find((l) => l.label === dragHit.label);
|
|
16813
16827
|
if (level) {
|
|
16814
|
-
const
|
|
16815
|
-
|
|
16828
|
+
const isAlreadySelected = this.selectedTradeLabel === level.label;
|
|
16829
|
+
const isMobileDraggable = dragHit.isBracket || level.type === "pending" && level.orderType !== "market" && (isAlreadySelected || !dragHit.isBox);
|
|
16830
|
+
if (this.hideLevelConfirmCancel && !isMobileDraggable) {
|
|
16816
16831
|
const hasPending = this.pendingLevelDrags.has(level.label);
|
|
16817
16832
|
if (this.selectedTradeLabel === level.label && !hasPending) {
|
|
16818
16833
|
this.selectedTradeLabel = null;
|
|
@@ -18883,8 +18898,10 @@ var _ChartEngine = class _ChartEngine {
|
|
|
18883
18898
|
addLevelBracket(label, type) {
|
|
18884
18899
|
const level = this.levels.find((l) => l.label === label);
|
|
18885
18900
|
if (!level) return this;
|
|
18886
|
-
const
|
|
18887
|
-
|
|
18901
|
+
const dragField = type === "sl" ? "stopLoss" : "takeProfit";
|
|
18902
|
+
const alreadyHasInLevel = type === "sl" ? level.stopLossPrice !== void 0 : level.takeProfitPrice !== void 0;
|
|
18903
|
+
const alreadyHasPending = this.pendingLevelDrags.get(label)?.some((c) => c.field === dragField && !c.isRemoval) ?? false;
|
|
18904
|
+
if (alreadyHasInLevel || alreadyHasPending) return this;
|
|
18888
18905
|
const { priceH } = this.getChartLayout();
|
|
18889
18906
|
const priceRange = this._displayedPriceRange ?? this.getScaledPriceRange(this.viewport);
|
|
18890
18907
|
const entryY = this.scaleManager.yToPixel(level.price, priceRange, priceH);
|
|
@@ -18893,6 +18910,10 @@ var _ChartEngine = class _ChartEngine {
|
|
|
18893
18910
|
const bracketY = entryY + (isBelowEntry ? 30 : -30);
|
|
18894
18911
|
const defaultPrice = this.scaleManager.pixelToPrice(bracketY, priceRange, priceH);
|
|
18895
18912
|
this.updateLevelBracket(label, type, defaultPrice);
|
|
18913
|
+
const existingDrags = this.pendingLevelDrags.get(label) ?? [];
|
|
18914
|
+
const filteredDrags = existingDrags.filter((c) => c.field !== dragField);
|
|
18915
|
+
filteredDrags.push({ field: dragField, newPrice: defaultPrice, oldPrice: defaultPrice, isNew: true });
|
|
18916
|
+
this.pendingLevelDrags.set(label, filteredDrags);
|
|
18896
18917
|
this.emitter.emit("tradeLevelBracketActivated", {
|
|
18897
18918
|
label,
|
|
18898
18919
|
bracketType: type,
|
|
@@ -18955,7 +18976,20 @@ var _ChartEngine = class _ChartEngine {
|
|
|
18955
18976
|
* No-op if the target doesn't exist or doesn't have the bracket type.
|
|
18956
18977
|
*/
|
|
18957
18978
|
removeBracket(type, label) {
|
|
18958
|
-
if (label)
|
|
18979
|
+
if (label) {
|
|
18980
|
+
const field = type === "sl" ? "stopLoss" : "takeProfit";
|
|
18981
|
+
const level = this.levels.find((l) => l.label === label);
|
|
18982
|
+
if (!level) return this;
|
|
18983
|
+
const existingChange = this.pendingLevelDrags.get(label)?.find((c) => c.field === field);
|
|
18984
|
+
const effectivePrice = existingChange && !existingChange.isRemoval ? existingChange.newPrice : type === "sl" ? level.stopLossPrice : level.takeProfitPrice;
|
|
18985
|
+
if (effectivePrice === void 0) return this;
|
|
18986
|
+
const existingDrags = this.pendingLevelDrags.get(label) ?? [];
|
|
18987
|
+
const filteredDrags = existingDrags.filter((c) => c.field !== field);
|
|
18988
|
+
filteredDrags.push({ field, newPrice: effectivePrice, oldPrice: effectivePrice, isRemoval: true });
|
|
18989
|
+
this.pendingLevelDrags.set(label, filteredDrags);
|
|
18990
|
+
this.renderTradeLayer();
|
|
18991
|
+
return this;
|
|
18992
|
+
}
|
|
18959
18993
|
if (type === "sl") {
|
|
18960
18994
|
this.draftBracketPnl = { ...this.draftBracketPnl, sl: void 0 };
|
|
18961
18995
|
} else {
|
|
@@ -19367,25 +19401,31 @@ var _ChartEngine = class _ChartEngine {
|
|
|
19367
19401
|
);
|
|
19368
19402
|
const processedLevels = this.levels.filter((l) => !(l.type === "pending" && l.ToClose != null)).map((l) => {
|
|
19369
19403
|
const draftChanges = this.pendingLevelDrags.get(l.label) ?? [];
|
|
19370
|
-
const
|
|
19371
|
-
const
|
|
19404
|
+
const slChange = draftChanges.find((c) => c.field === "stopLoss");
|
|
19405
|
+
const tpChange = draftChanges.find((c) => c.field === "takeProfit");
|
|
19406
|
+
const slDraft = slChange && !slChange.isRemoval ? slChange.newPrice : void 0;
|
|
19407
|
+
const tpDraft = tpChange && !tpChange.isRemoval ? tpChange.newPrice : void 0;
|
|
19408
|
+
const slIsRemoval = slChange?.isRemoval ?? false;
|
|
19409
|
+
const tpIsRemoval = tpChange?.isRemoval ?? false;
|
|
19372
19410
|
const mainDraft = draftChanges.find((c) => c.field === "main")?.newPrice;
|
|
19373
19411
|
const linked = bracketOrders.filter((b) => b.ToClose === l.label);
|
|
19374
|
-
if (linked.length === 0 && slDraft === void 0 && tpDraft === void 0 && mainDraft === void 0)
|
|
19412
|
+
if (linked.length === 0 && slDraft === void 0 && tpDraft === void 0 && mainDraft === void 0 && !slIsRemoval && !tpIsRemoval)
|
|
19375
19413
|
return l;
|
|
19376
19414
|
const clone = { ...l };
|
|
19377
19415
|
if (mainDraft !== void 0) clone.price = mainDraft;
|
|
19378
19416
|
if (slDraft !== void 0) clone.stopLossPrice = slDraft;
|
|
19417
|
+
else if (slIsRemoval) clone.stopLossPrice = void 0;
|
|
19379
19418
|
if (tpDraft !== void 0) clone.takeProfitPrice = tpDraft;
|
|
19419
|
+
else if (tpIsRemoval) clone.takeProfitPrice = void 0;
|
|
19380
19420
|
if (linked.length > 0) {
|
|
19381
19421
|
const parentSide = l.side ?? "buy";
|
|
19382
19422
|
for (const b of linked) {
|
|
19383
19423
|
const isSL = parentSide === "buy" ? b.price < l.price : b.price > l.price;
|
|
19384
19424
|
if (isSL) {
|
|
19385
|
-
clone.stopLossPrice = slDraft ?? clone.stopLossPrice ?? b.price;
|
|
19425
|
+
clone.stopLossPrice = slIsRemoval ? void 0 : slDraft ?? clone.stopLossPrice ?? b.price;
|
|
19386
19426
|
clone._slOrderLabel = b.label;
|
|
19387
19427
|
} else {
|
|
19388
|
-
clone.takeProfitPrice = tpDraft ?? clone.takeProfitPrice ?? b.price;
|
|
19428
|
+
clone.takeProfitPrice = tpIsRemoval ? void 0 : tpDraft ?? clone.takeProfitPrice ?? b.price;
|
|
19389
19429
|
clone._tpOrderLabel = b.label;
|
|
19390
19430
|
}
|
|
19391
19431
|
}
|
|
@@ -19447,8 +19487,9 @@ var _ChartEngine = class _ChartEngine {
|
|
|
19447
19487
|
const parentPrice = this._effectiveEntryPrice(result.label, level?.price ?? oldPrice);
|
|
19448
19488
|
const isEntryOrder = level?.entryPriceEditable === true;
|
|
19449
19489
|
const isDraft = level?.data?._isDraft === true;
|
|
19490
|
+
const isMobilePendingOrder = this.hideLevelConfirmCancel && result.type === "pending" && !isDraft;
|
|
19450
19491
|
const all = this.dataStore.all;
|
|
19451
|
-
const marketPrice = isEntryOrder || isDraft ? 0 : all[all.length - 1]?.close ?? 0;
|
|
19492
|
+
const marketPrice = isEntryOrder || isDraft || isMobilePendingOrder ? 0 : all[all.length - 1]?.close ?? 0;
|
|
19452
19493
|
if (!TradeDragHandler.isBracketPriceValid(
|
|
19453
19494
|
result.newPrice,
|
|
19454
19495
|
result.bracketType,
|
|
@@ -20259,24 +20300,20 @@ var _ChartEngine = class _ChartEngine {
|
|
|
20259
20300
|
const isDraftBracket = parentLevel?.data?._isDraft === true;
|
|
20260
20301
|
if (isDraftBracket && parentLevel) {
|
|
20261
20302
|
const bracketKey = closedLevel.bracketType === "stopLoss" ? "sl" : "tp";
|
|
20262
|
-
|
|
20263
|
-
|
|
20264
|
-
const entryY = this.scaleManager.yToPixel(
|
|
20265
|
-
parentLevel.price,
|
|
20266
|
-
priceRange,
|
|
20267
|
-
priceH
|
|
20268
|
-
);
|
|
20269
|
-
const side = parentLevel.side ?? "buy";
|
|
20270
|
-
const isBelowEntry = side === "buy" && bracketKey === "sl" || side === "sell" && bracketKey === "tp";
|
|
20271
|
-
const bracketY = entryY + (isBelowEntry ? 30 : -30);
|
|
20272
|
-
const defaultPrice = this.scaleManager.pixelToPrice(bracketY, priceRange, priceH);
|
|
20273
|
-
this.updateDraftOrderBracket(bracketKey, defaultPrice);
|
|
20274
|
-
this.emitter.emit("tradeLevelDrag", {
|
|
20303
|
+
this.updateDraftOrderBracket(bracketKey, null);
|
|
20304
|
+
this.emitter.emit("tradeLevelEdit", {
|
|
20275
20305
|
label: closedLevel.label,
|
|
20276
|
-
|
|
20277
|
-
data: parentLevel
|
|
20278
|
-
|
|
20279
|
-
|
|
20306
|
+
type: "pending",
|
|
20307
|
+
data: parentLevel.data,
|
|
20308
|
+
isFullscreen: this.isFullscreen,
|
|
20309
|
+
changes: [
|
|
20310
|
+
{
|
|
20311
|
+
field: closedLevel.bracketType === "stopLoss" ? "REMOVE_SL" : "REMOVE_TP",
|
|
20312
|
+
newPrice: 0,
|
|
20313
|
+
data: parentLevel.data,
|
|
20314
|
+
bracketOrderLabel: void 0
|
|
20315
|
+
}
|
|
20316
|
+
]
|
|
20280
20317
|
});
|
|
20281
20318
|
return;
|
|
20282
20319
|
}
|
|
@@ -20349,8 +20386,9 @@ var _ChartEngine = class _ChartEngine {
|
|
|
20349
20386
|
this._isBracketNew = false;
|
|
20350
20387
|
const isEntryOrder = level.entryPriceEditable === true;
|
|
20351
20388
|
const isDraft = level.data?._isDraft === true;
|
|
20389
|
+
const isMobilePendingOrder = this.hideLevelConfirmCancel && level.type === "pending" && !isDraft;
|
|
20352
20390
|
const all = this.dataStore.all;
|
|
20353
|
-
const marketPrice = isEntryOrder || isDraft ? 0 : all[all.length - 1]?.close ?? 0;
|
|
20391
|
+
const marketPrice = isEntryOrder || isDraft || isMobilePendingOrder ? 0 : all[all.length - 1]?.close ?? 0;
|
|
20354
20392
|
this.tradeDragHandler.startBracketDrag(
|
|
20355
20393
|
level,
|
|
20356
20394
|
dragHit.bracketType,
|
|
@@ -20408,20 +20446,9 @@ var _ChartEngine = class _ChartEngine {
|
|
|
20408
20446
|
const initialPrice = this.scaleManager.pixelToPrice(btnCenterY, priceRange, priceH);
|
|
20409
20447
|
const isEntryOrder = level.entryPriceEditable === true;
|
|
20410
20448
|
const isDraft = level.data?._isDraft === true;
|
|
20449
|
+
const isMobilePendingOrder = this.hideLevelConfirmCancel && level.type === "pending" && !isDraft;
|
|
20411
20450
|
const all = this.dataStore.all;
|
|
20412
|
-
const marketPrice = isEntryOrder || isDraft ? 0 : all[all.length - 1]?.close ?? 0;
|
|
20413
|
-
if (!isDraft) {
|
|
20414
|
-
this.emitter.emit("tradeLevelEditOpen", {
|
|
20415
|
-
label: level.label,
|
|
20416
|
-
type: level.type,
|
|
20417
|
-
data: level.data,
|
|
20418
|
-
price: level.price,
|
|
20419
|
-
side: level.side,
|
|
20420
|
-
stopLossPrice: level.stopLossPrice,
|
|
20421
|
-
takeProfitPrice: level.takeProfitPrice,
|
|
20422
|
-
isFullscreen: this.isFullscreen
|
|
20423
|
-
});
|
|
20424
|
-
}
|
|
20451
|
+
const marketPrice = isEntryOrder || isDraft || isMobilePendingOrder ? 0 : all[all.length - 1]?.close ?? 0;
|
|
20425
20452
|
this._pendingBracketOrderLabel = null;
|
|
20426
20453
|
this._isBracketNew = true;
|
|
20427
20454
|
this.tradeDragHandler.startBracketDrag(
|