@forgecharts/sdk 1.5.21 → 1.5.23
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 +58 -10
- package/dist/index.js.map +1 -1
- package/dist/internal.js +58 -10
- package/dist/internal.js.map +1 -1
- package/dist/pixi/PixiTradingRenderer.d.ts.map +1 -1
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
- package/dist/react/index.js +58 -10
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +58 -10
- package/dist/react/internal.js.map +1 -1
- package/package.json +1 -1
package/dist/react/internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React11, { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useCallback, useMemo, useContext, useReducer } from 'react';
|
|
2
|
-
import { TextStyle, Application, Container, Graphics, Text, FillGradient } from 'pixi.js';
|
|
2
|
+
import { TextStyle, Application, Container, Graphics, Text, FillGradient, CanvasTextMetrics } from 'pixi.js';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
|
|
@@ -7709,9 +7709,11 @@ function orderRoleLabel(role) {
|
|
|
7709
7709
|
}
|
|
7710
7710
|
}
|
|
7711
7711
|
function isDraggableRole(role) {
|
|
7712
|
-
return role === "stop_loss" || role === "take_profit";
|
|
7712
|
+
return role === "stop_loss" || role === "take_profit" || role === "limit" || role === "stop";
|
|
7713
7713
|
}
|
|
7714
7714
|
var LINE_H = 15;
|
|
7715
|
+
var LABEL_GAP = 6;
|
|
7716
|
+
var LABEL_PAD = 6;
|
|
7715
7717
|
var PILL_H = 16;
|
|
7716
7718
|
var PILL_W = 28;
|
|
7717
7719
|
var PILL_R = 4;
|
|
@@ -7878,13 +7880,18 @@ var PixiTradingRenderer = class {
|
|
|
7878
7880
|
this._drawDragHandle(plotWidth - 26, y, color, alpha);
|
|
7879
7881
|
}
|
|
7880
7882
|
const boxY = y - LINE_H / 2;
|
|
7883
|
+
const roleStr = orderRoleLabel(order.role);
|
|
7884
|
+
const text = roleStr ? `${roleStr} ${order.qty}` : `${order.side.toUpperCase()} ${order.qty}`;
|
|
7885
|
+
const textW = Math.ceil(CanvasTextMetrics.measureText(text, labelStyle).width);
|
|
7886
|
+
const pillW = textW + LABEL_PAD * 2;
|
|
7887
|
+
const pillX = Math.max(0, plotWidth - LABEL_GAP - pillW);
|
|
7888
|
+
this._boxGfx.roundRect(pillX, boxY, pillW, LINE_H, PILL_R).fill({ color, alpha });
|
|
7889
|
+
labelIdx = this._drawLabel(text, pillX + pillW / 2, y, labelIdx, labelStyle, true);
|
|
7881
7890
|
this._boxGfx.rect(plotWidth, boxY, psWidth, LINE_H).fill({ color, alpha });
|
|
7891
|
+
labelIdx = this._drawLabel(order.price.toFixed(2), plotWidth + 4, y, labelIdx, labelStyle);
|
|
7882
7892
|
if (isDraggableRole(order.role)) {
|
|
7883
7893
|
this._orderHitZones.push({ id: order.id, role: order.role, x: 0, y: boxY, w: plotWidth + psWidth, h: LINE_H });
|
|
7884
7894
|
}
|
|
7885
|
-
const roleStr = orderRoleLabel(order.role);
|
|
7886
|
-
const text = roleStr && isDraggableRole(order.role) ? `${roleStr} ${order.price.toFixed(2)}` : roleStr ? `${roleStr} ${order.qty}` : `${order.side.toUpperCase()} ${order.qty}`;
|
|
7887
|
-
labelIdx = this._drawLabel(text, plotWidth + 4, y, labelIdx, labelStyle);
|
|
7888
7895
|
if (isEntry && !order.groupId && !bracketEntryIds.has(order.id)) {
|
|
7889
7896
|
const tpPillY = y - PILL_H / 2;
|
|
7890
7897
|
this._boxGfx.roundRect(PILL_TP_X, tpPillY, PILL_W, PILL_H, PILL_R).fill({ color: TP_PILL_COLOR, alpha: 0.85 });
|
|
@@ -7949,19 +7956,56 @@ var PixiTradingRenderer = class {
|
|
|
7949
7956
|
}
|
|
7950
7957
|
this._lineGfx.stroke();
|
|
7951
7958
|
const boxY = y - LINE_H / 2;
|
|
7952
|
-
this._boxGfx.rect(plotWidth, boxY, psWidth, LINE_H).fill({ color, alpha: 0.9 });
|
|
7953
|
-
this._positionHitZones.push({ id: pos.id, x: plotWidth, y: boxY, w: psWidth, h: LINE_H });
|
|
7954
7959
|
let text;
|
|
7955
7960
|
if (pos.label) {
|
|
7956
7961
|
text = pos.label;
|
|
7957
7962
|
} else {
|
|
7958
|
-
text =
|
|
7963
|
+
text = `${pos.side.toUpperCase()} ${pos.qty}`;
|
|
7959
7964
|
if (pos.unrealizedPnl !== void 0) {
|
|
7960
7965
|
const pnlSign = pos.unrealizedPnl >= 0 ? "+" : "";
|
|
7961
7966
|
text += ` ${pnlSign}${pos.unrealizedPnl.toFixed(2)}`;
|
|
7962
7967
|
}
|
|
7963
7968
|
}
|
|
7964
|
-
|
|
7969
|
+
const textW = Math.ceil(CanvasTextMetrics.measureText(text, labelStyle).width);
|
|
7970
|
+
const pillW = textW + LABEL_PAD * 2;
|
|
7971
|
+
const pillX = Math.max(0, plotWidth - LABEL_GAP - pillW);
|
|
7972
|
+
this._boxGfx.roundRect(pillX, boxY, pillW, LINE_H, PILL_R).fill({ color, alpha: 0.9 });
|
|
7973
|
+
labelIdx = this._drawLabel(text, pillX + pillW / 2, y, labelIdx, labelStyle, true);
|
|
7974
|
+
this._boxGfx.rect(plotWidth, boxY, psWidth, LINE_H).fill({ color, alpha: 0.9 });
|
|
7975
|
+
labelIdx = this._drawLabel(String(pos.entryPrice), plotWidth + 4, y, labelIdx, labelStyle);
|
|
7976
|
+
this._positionHitZones.push({ id: pos.id, x: pillX, y: boxY, w: pillW, h: LINE_H });
|
|
7977
|
+
const linked = pos.linkedOrderIds ?? [];
|
|
7978
|
+
const hasTp = linked.some((id) => id.endsWith("-tp"));
|
|
7979
|
+
const hasSl = linked.some((id) => id.endsWith("-sl"));
|
|
7980
|
+
const entrySide = pos.side === "long" ? "buy" : "sell";
|
|
7981
|
+
if (!hasTp) {
|
|
7982
|
+
const tpY = y - PILL_H / 2;
|
|
7983
|
+
this._boxGfx.roundRect(PILL_TP_X, tpY, PILL_W, PILL_H, PILL_R).fill({ color: TP_PILL_COLOR, alpha: 0.85 });
|
|
7984
|
+
labelIdx = this._drawLabel("TP", PILL_TP_X + PILL_W / 2, y, labelIdx, pillLabelStyle, true);
|
|
7985
|
+
this._pillHitZones.push({
|
|
7986
|
+
kind: "tp",
|
|
7987
|
+
entryOrderId: pos.id,
|
|
7988
|
+
entrySide,
|
|
7989
|
+
x: PILL_TP_X,
|
|
7990
|
+
y: tpY,
|
|
7991
|
+
w: PILL_W,
|
|
7992
|
+
h: PILL_H
|
|
7993
|
+
});
|
|
7994
|
+
}
|
|
7995
|
+
if (!hasSl) {
|
|
7996
|
+
const slY = y - PILL_H / 2;
|
|
7997
|
+
this._boxGfx.roundRect(PILL_SL_X, slY, PILL_W, PILL_H, PILL_R).fill({ color: SL_PILL_COLOR, alpha: 0.85 });
|
|
7998
|
+
labelIdx = this._drawLabel("SL", PILL_SL_X + PILL_W / 2, y, labelIdx, pillLabelStyle, true);
|
|
7999
|
+
this._pillHitZones.push({
|
|
8000
|
+
kind: "sl",
|
|
8001
|
+
entryOrderId: pos.id,
|
|
8002
|
+
entrySide,
|
|
8003
|
+
x: PILL_SL_X,
|
|
8004
|
+
y: slY,
|
|
8005
|
+
w: PILL_W,
|
|
8006
|
+
h: PILL_H
|
|
8007
|
+
});
|
|
8008
|
+
}
|
|
7965
8009
|
}
|
|
7966
8010
|
}
|
|
7967
8011
|
}
|
|
@@ -23118,7 +23162,11 @@ var ChartCanvas = forwardRef(
|
|
|
23118
23162
|
type: "modify",
|
|
23119
23163
|
orderId,
|
|
23120
23164
|
symbol: symbolRef.current,
|
|
23121
|
-
|
|
23165
|
+
// Route by role: a stop order's price is its TRIGGER, not a limit.
|
|
23166
|
+
// Sending limitPrice for a stop would modify the wrong field on the
|
|
23167
|
+
// broker (or be rejected), which matters now that stop orders are
|
|
23168
|
+
// draggable and not just bracket legs.
|
|
23169
|
+
...order?.role === "stop" ? { stopPrice: newPrice } : { limitPrice: newPrice },
|
|
23122
23170
|
timestamp: Date.now()
|
|
23123
23171
|
});
|
|
23124
23172
|
}
|