@forgecharts/sdk 1.5.22 → 1.5.24
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.js +53 -36
- package/dist/index.js.map +1 -1
- package/dist/internal.js +53 -36
- package/dist/internal.js.map +1 -1
- package/dist/pixi/PixiChart.d.ts +15 -0
- package/dist/pixi/PixiChart.d.ts.map +1 -1
- package/dist/pixi/PixiTradingRenderer.d.ts +15 -0
- package/dist/pixi/PixiTradingRenderer.d.ts.map +1 -1
- package/dist/react/index.js +53 -36
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +53 -36
- package/dist/react/internal.js.map +1 -1
- package/package.json +1 -1
package/dist/react/internal.js
CHANGED
|
@@ -7711,6 +7711,9 @@ function orderRoleLabel(role) {
|
|
|
7711
7711
|
function isDraggableRole(role) {
|
|
7712
7712
|
return role === "stop_loss" || role === "take_profit" || role === "limit" || role === "stop";
|
|
7713
7713
|
}
|
|
7714
|
+
function isTerminal(status) {
|
|
7715
|
+
return status === "cancelled" || status === "rejected" || status === "expired" || status === "filled";
|
|
7716
|
+
}
|
|
7714
7717
|
var LINE_H = 15;
|
|
7715
7718
|
var LABEL_GAP = 6;
|
|
7716
7719
|
var LABEL_PAD = 6;
|
|
@@ -7975,33 +7978,37 @@ var PixiTradingRenderer = class {
|
|
|
7975
7978
|
labelIdx = this._drawLabel(String(pos.entryPrice), plotWidth + 4, y, labelIdx, labelStyle);
|
|
7976
7979
|
this._positionHitZones.push({ id: pos.id, x: pillX, y: boxY, w: pillW, h: LINE_H });
|
|
7977
7980
|
const linked = pos.linkedOrderIds ?? [];
|
|
7978
|
-
const hasTp = linked.some((id) => id.endsWith("-tp"));
|
|
7979
|
-
const hasSl = linked.some((id) => id.endsWith("-sl"));
|
|
7981
|
+
const hasTp = linked.some((id) => id.endsWith("-tp")) || orders.some((o) => (o.role === "take_profit" || o.role === "limit") && !isTerminal(o.status));
|
|
7982
|
+
const hasSl = linked.some((id) => id.endsWith("-sl")) || orders.some((o) => (o.role === "stop_loss" || o.role === "stop") && !isTerminal(o.status));
|
|
7980
7983
|
const entrySide = pos.side === "long" ? "buy" : "sell";
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7984
|
+
let pillCursor = pillX - 4;
|
|
7985
|
+
if (!hasSl) {
|
|
7986
|
+
const slX = pillCursor - PILL_W;
|
|
7987
|
+
const slY = y - PILL_H / 2;
|
|
7988
|
+
this._boxGfx.roundRect(slX, slY, PILL_W, PILL_H, PILL_R).fill({ color: SL_PILL_COLOR, alpha: 0.85 });
|
|
7989
|
+
labelIdx = this._drawLabel("SL", slX + PILL_W / 2, y, labelIdx, pillLabelStyle, true);
|
|
7985
7990
|
this._pillHitZones.push({
|
|
7986
|
-
kind: "
|
|
7991
|
+
kind: "sl",
|
|
7987
7992
|
entryOrderId: pos.id,
|
|
7988
7993
|
entrySide,
|
|
7989
|
-
x:
|
|
7990
|
-
y:
|
|
7994
|
+
x: slX,
|
|
7995
|
+
y: slY,
|
|
7991
7996
|
w: PILL_W,
|
|
7992
7997
|
h: PILL_H
|
|
7993
7998
|
});
|
|
7999
|
+
pillCursor = slX - 4;
|
|
7994
8000
|
}
|
|
7995
|
-
if (!
|
|
7996
|
-
const
|
|
7997
|
-
|
|
7998
|
-
|
|
8001
|
+
if (!hasTp) {
|
|
8002
|
+
const tpX = pillCursor - PILL_W;
|
|
8003
|
+
const tpY = y - PILL_H / 2;
|
|
8004
|
+
this._boxGfx.roundRect(tpX, tpY, PILL_W, PILL_H, PILL_R).fill({ color: TP_PILL_COLOR, alpha: 0.85 });
|
|
8005
|
+
labelIdx = this._drawLabel("TP", tpX + PILL_W / 2, y, labelIdx, pillLabelStyle, true);
|
|
7999
8006
|
this._pillHitZones.push({
|
|
8000
|
-
kind: "
|
|
8007
|
+
kind: "tp",
|
|
8001
8008
|
entryOrderId: pos.id,
|
|
8002
8009
|
entrySide,
|
|
8003
|
-
x:
|
|
8004
|
-
y:
|
|
8010
|
+
x: tpX,
|
|
8011
|
+
y: tpY,
|
|
8005
8012
|
w: PILL_W,
|
|
8006
8013
|
h: PILL_H
|
|
8007
8014
|
});
|
|
@@ -9294,30 +9301,40 @@ var PixiChart = class {
|
|
|
9294
9301
|
setTradingOrders(orders) {
|
|
9295
9302
|
this._tradingOrders = orders;
|
|
9296
9303
|
this._layers.dirty.mark(4 /* TradingOverlay */);
|
|
9297
|
-
|
|
9298
|
-
(o) => (o.role === "stop_loss" || o.role === "take_profit") && o.status !== "cancelled" && o.status !== "filled"
|
|
9299
|
-
);
|
|
9300
|
-
if (hasDraggable) {
|
|
9301
|
-
this._interaction.setOrderLineHitTest(
|
|
9302
|
-
(x, y) => this._tradingRenderer.hitTestDraggableOrder(x, y)
|
|
9303
|
-
);
|
|
9304
|
-
} else {
|
|
9305
|
-
this._interaction.setOrderLineHitTest(null);
|
|
9306
|
-
}
|
|
9307
|
-
const hasEntryWithoutBracket = orders.some(
|
|
9308
|
-
(o) => o.role === "entry" && !o.groupId && o.status !== "cancelled" && o.status !== "filled" && o.status !== "rejected"
|
|
9309
|
-
);
|
|
9310
|
-
if (hasEntryWithoutBracket) {
|
|
9311
|
-
this._interaction.setPillHitTest(
|
|
9312
|
-
(x, y) => this._tradingRenderer.hitTestPill(x, y)
|
|
9313
|
-
);
|
|
9314
|
-
} else {
|
|
9315
|
-
this._interaction.setPillHitTest(null);
|
|
9316
|
-
}
|
|
9304
|
+
this._refreshTradingHitTests();
|
|
9317
9305
|
}
|
|
9318
9306
|
setTradingPositions(positions) {
|
|
9319
9307
|
this._tradingPositions = positions;
|
|
9320
9308
|
this._layers.dirty.mark(4 /* TradingOverlay */);
|
|
9309
|
+
this._refreshTradingHitTests();
|
|
9310
|
+
}
|
|
9311
|
+
/**
|
|
9312
|
+
* (Re)register the trading hit tests against current orders AND positions.
|
|
9313
|
+
*
|
|
9314
|
+
* Was inline in setTradingOrders and keyed on hardcoded roles, which left
|
|
9315
|
+
* both interactions half-wired:
|
|
9316
|
+
*
|
|
9317
|
+
* - the drag hit test required a 'stop_loss'/'take_profit' order, so
|
|
9318
|
+
* working limit and stop lines rendered a drag handle they could not
|
|
9319
|
+
* actually be grabbed by
|
|
9320
|
+
* - the pill hit test required an ORDER with role 'entry' and no groupId,
|
|
9321
|
+
* but the pills are drawn on POSITIONS, so they were never grabbable
|
|
9322
|
+
*
|
|
9323
|
+
* Both now derive from the same predicates the renderer draws with.
|
|
9324
|
+
*/
|
|
9325
|
+
_refreshTradingHitTests() {
|
|
9326
|
+
const hasDraggable = this._tradingOrders.some(
|
|
9327
|
+
(o) => isDraggableRole(o.role) && o.status !== "cancelled" && o.status !== "filled"
|
|
9328
|
+
);
|
|
9329
|
+
this._interaction.setOrderLineHitTest(
|
|
9330
|
+
hasDraggable ? (x, y) => this._tradingRenderer.hitTestDraggableOrder(x, y) : null
|
|
9331
|
+
);
|
|
9332
|
+
const hasPillSource = this._tradingPositions.some((p) => p.status === "open") || this._tradingOrders.some(
|
|
9333
|
+
(o) => o.role === "entry" && !o.groupId && o.status !== "cancelled" && o.status !== "filled" && o.status !== "rejected"
|
|
9334
|
+
);
|
|
9335
|
+
this._interaction.setPillHitTest(
|
|
9336
|
+
hasPillSource ? (x, y) => this._tradingRenderer.hitTestPill(x, y) : null
|
|
9337
|
+
);
|
|
9321
9338
|
}
|
|
9322
9339
|
setContractSwitches(switches) {
|
|
9323
9340
|
this._timeScale.contractSwitches = switches;
|