@orderly.network/ui-tradingview 3.0.0-beta.0 → 3.0.0-beta.10
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +172 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -15529,6 +15529,7 @@ interface DisplayControlSettingInterface {
|
|
|
15529
15529
|
tpsl: boolean;
|
|
15530
15530
|
positionTpsl: boolean;
|
|
15531
15531
|
trailingStop: boolean;
|
|
15532
|
+
liquidationPrice: boolean;
|
|
15532
15533
|
}
|
|
15533
15534
|
|
|
15534
15535
|
declare const TradingviewWidget: React$1.ForwardRefExoticComponent<TradingviewWidgetPropsInterface & React$1.RefAttributes<HTMLDivElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -15529,6 +15529,7 @@ interface DisplayControlSettingInterface {
|
|
|
15529
15529
|
tpsl: boolean;
|
|
15530
15530
|
positionTpsl: boolean;
|
|
15531
15531
|
trailingStop: boolean;
|
|
15532
|
+
liquidationPrice: boolean;
|
|
15532
15533
|
}
|
|
15533
15534
|
|
|
15534
15535
|
declare const TradingviewWidget: React$1.ForwardRefExoticComponent<TradingviewWidgetPropsInterface & React$1.RefAttributes<HTMLDivElement>>;
|
package/dist/index.js
CHANGED
|
@@ -664,6 +664,10 @@ var init_displayControl_desktop = __esm({
|
|
|
664
664
|
{
|
|
665
665
|
label: t("orderEntry.orderType.trailingStop"),
|
|
666
666
|
id: "trailingStop"
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
label: t("tradingView.displayControl.liquidationPrice"),
|
|
670
|
+
id: "liquidationPrice"
|
|
667
671
|
}
|
|
668
672
|
];
|
|
669
673
|
}, [t]);
|
|
@@ -725,7 +729,7 @@ var init_displayControl_desktop = __esm({
|
|
|
725
729
|
{
|
|
726
730
|
className: ui.cn(
|
|
727
731
|
"oui-text-sm oui-text-base-contrast-80",
|
|
728
|
-
!displayControlState[item.id] && "oui-text-base-contrast-36"
|
|
732
|
+
!(displayControlState[item.id] ?? true) && "oui-text-base-contrast-36"
|
|
729
733
|
),
|
|
730
734
|
children: item.label
|
|
731
735
|
}
|
|
@@ -734,7 +738,7 @@ var init_displayControl_desktop = __esm({
|
|
|
734
738
|
ui.Switch,
|
|
735
739
|
{
|
|
736
740
|
className: "oui-h-4 oui-w-8",
|
|
737
|
-
checked: displayControlState[item.id],
|
|
741
|
+
checked: displayControlState[item.id] ?? true,
|
|
738
742
|
onCheckedChange: (checked) => {
|
|
739
743
|
changeDisplayControlState({
|
|
740
744
|
...displayControlState,
|
|
@@ -799,8 +803,10 @@ var init_displayControl_mobile = __esm({
|
|
|
799
803
|
label: t("orderEntry.orderType.trailingStop"),
|
|
800
804
|
id: "trailingStop"
|
|
801
805
|
},
|
|
802
|
-
|
|
803
|
-
|
|
806
|
+
{
|
|
807
|
+
label: t("tradingView.displayControl.liquidationPrice"),
|
|
808
|
+
id: "liquidationPrice"
|
|
809
|
+
}
|
|
804
810
|
]
|
|
805
811
|
];
|
|
806
812
|
}, [t]);
|
|
@@ -853,7 +859,7 @@ var init_displayControl_mobile = __esm({
|
|
|
853
859
|
"oui-flex oui-h-6 oui-w-full oui-items-center oui-justify-between",
|
|
854
860
|
"oui-rounded oui-px-2 oui-text-2xs",
|
|
855
861
|
item.id && "oui-bg-base-5",
|
|
856
|
-
props.displayControlState[item.id] ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
|
|
862
|
+
props.displayControlState[item.id] ?? true ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
|
|
857
863
|
),
|
|
858
864
|
onClick: () => {
|
|
859
865
|
if (!item.id) {
|
|
@@ -866,7 +872,7 @@ var init_displayControl_mobile = __esm({
|
|
|
866
872
|
},
|
|
867
873
|
children: item.id && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
868
874
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: item.label }),
|
|
869
|
-
props.displayControlState[item.id] ? /* @__PURE__ */ jsxRuntime.jsx(SelectedIcon, { className: "oui-size-3" }) : /* @__PURE__ */ jsxRuntime.jsx(UnSelectIcon, { className: "oui-size-3" })
|
|
875
|
+
props.displayControlState[item.id] ?? true ? /* @__PURE__ */ jsxRuntime.jsx(SelectedIcon, { className: "oui-size-3" }) : /* @__PURE__ */ jsxRuntime.jsx(UnSelectIcon, { className: "oui-size-3" })
|
|
870
876
|
] })
|
|
871
877
|
},
|
|
872
878
|
item.id || index
|
|
@@ -2388,13 +2394,22 @@ var getTpslEstPnl = (tpslOrder, position) => {
|
|
|
2388
2394
|
tpslOrder.type === "CLOSE_POSITION" /* CLOSE_POSITION */ ? position.balance : tpslOrder.quantity
|
|
2389
2395
|
);
|
|
2390
2396
|
const sideFlag = tpslOrder.side === "SELL" /* SELL */ ? 1 : -1;
|
|
2391
|
-
const
|
|
2392
|
-
const estPnl = new utils.Decimal(tpslOrder.trigger_price).minus(
|
|
2393
|
-
return { estPnl, quantity, openPrice };
|
|
2397
|
+
const priceRef = position.open;
|
|
2398
|
+
const estPnl = new utils.Decimal(tpslOrder.trigger_price).minus(priceRef).times(quantity).times(sideFlag).toString();
|
|
2399
|
+
return { estPnl, quantity, openPrice: priceRef };
|
|
2394
2400
|
};
|
|
2395
2401
|
var formatPnl = (pnl) => {
|
|
2396
2402
|
return pnl !== void 0 && pnl !== "" ? new utils.Decimal(pnl).todp(EST_TPSL_PNL_DECIMAL, utils.Decimal.ROUND_FLOOR) : textDash;
|
|
2397
2403
|
};
|
|
2404
|
+
var getPositionSide = (balance) => {
|
|
2405
|
+
return balance >= 0 ? "LONG" /* LONG */ : "SHORT" /* SHORT */;
|
|
2406
|
+
};
|
|
2407
|
+
var determineTpslType = (targetPrice, markPrice, positionSide) => {
|
|
2408
|
+
if (positionSide === "LONG" /* LONG */) {
|
|
2409
|
+
return targetPrice > markPrice ? "tp" : "sl";
|
|
2410
|
+
}
|
|
2411
|
+
return targetPrice < markPrice ? "tp" : "sl";
|
|
2412
|
+
};
|
|
2398
2413
|
function useCancelOrder() {
|
|
2399
2414
|
const [
|
|
2400
2415
|
pendingOrders,
|
|
@@ -2747,41 +2762,42 @@ var ExecutionService = class _ExecutionService {
|
|
|
2747
2762
|
};
|
|
2748
2763
|
var LiquidationLineService = class {
|
|
2749
2764
|
constructor(instance, broker) {
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2765
|
+
/** Single temporary line driven by Order Entry estimated liquidation price. */
|
|
2766
|
+
this.estimatedLine = null;
|
|
2767
|
+
/** Persistent lines driven by current positions (can be multiple, e.g. cross + isolated). */
|
|
2768
|
+
this.positionLines = [];
|
|
2753
2769
|
this.instance = instance;
|
|
2754
2770
|
this.broker = broker;
|
|
2755
2771
|
}
|
|
2756
2772
|
/**
|
|
2757
|
-
* Render or update
|
|
2773
|
+
* Render or update liquidation lines. Call when position or estimated liq. price changes.
|
|
2758
2774
|
*/
|
|
2759
2775
|
renderLiquidationLine(params) {
|
|
2760
|
-
const {
|
|
2776
|
+
const { positionLiqItems, estimatedLiqPrice } = params;
|
|
2761
2777
|
const hasValidEst = estimatedLiqPrice != null && Number.isFinite(estimatedLiqPrice);
|
|
2762
|
-
const
|
|
2778
|
+
const validPositionItems = (positionLiqItems ?? []).filter(
|
|
2779
|
+
(item) => item != null && item.price != null && Number.isFinite(item.price)
|
|
2780
|
+
);
|
|
2763
2781
|
if (hasValidEst) {
|
|
2764
|
-
this.
|
|
2765
|
-
this.
|
|
2766
|
-
this.
|
|
2782
|
+
this.removePositionLines();
|
|
2783
|
+
this.setEstimatedLinePrice(estimatedLiqPrice);
|
|
2784
|
+
this.estimatedLine?.setLineStyle(1);
|
|
2767
2785
|
return;
|
|
2768
2786
|
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
this.
|
|
2772
|
-
this.line?.setLineStyle(0);
|
|
2787
|
+
this.removeEstimatedLine();
|
|
2788
|
+
if (validPositionItems.length > 0) {
|
|
2789
|
+
this.renderPositionLines(validPositionItems);
|
|
2773
2790
|
return;
|
|
2774
2791
|
}
|
|
2775
|
-
this.
|
|
2792
|
+
this.removePositionLines();
|
|
2776
2793
|
}
|
|
2777
|
-
/** Remove
|
|
2794
|
+
/** Remove all liquidation lines (e.g. on destroy). */
|
|
2778
2795
|
remove() {
|
|
2779
|
-
this.
|
|
2796
|
+
this.removeEstimatedLine();
|
|
2797
|
+
this.removePositionLines();
|
|
2780
2798
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
return this.line;
|
|
2784
|
-
}
|
|
2799
|
+
/** Build a TradingView order line and apply shared style. */
|
|
2800
|
+
createBaseLine() {
|
|
2785
2801
|
try {
|
|
2786
2802
|
const activeChart = this.instance.activeChart();
|
|
2787
2803
|
if (!activeChart) return null;
|
|
@@ -2790,41 +2806,93 @@ var LiquidationLineService = class {
|
|
|
2790
2806
|
const colorConfig = this.broker.colorConfig;
|
|
2791
2807
|
const lineColor = colorConfig.liqLineColor ?? colorConfig.textColor;
|
|
2792
2808
|
if (!lineColor) return null;
|
|
2793
|
-
|
|
2794
|
-
this.updateLineLabel();
|
|
2809
|
+
let line = orderLine.setCancellable(false).setLineLength(100).setEditable(false).setExtendLeft(true).setQuantity("").setLineStyle(0).setLineColor(lineColor).setBodyBorderColor(lineColor);
|
|
2795
2810
|
if (colorConfig.chartBG) {
|
|
2796
|
-
|
|
2811
|
+
line = line.setBodyBackgroundColor(colorConfig.chartBG).setQuantityBackgroundColor(colorConfig.chartBG);
|
|
2797
2812
|
}
|
|
2798
2813
|
if (colorConfig.textColor) {
|
|
2799
|
-
|
|
2814
|
+
line = line.setBodyTextColor(colorConfig.textColor);
|
|
2800
2815
|
}
|
|
2801
2816
|
if (colorConfig.font) {
|
|
2802
|
-
|
|
2817
|
+
line = line.setBodyFont(colorConfig.font).setQuantityFont(colorConfig.font);
|
|
2803
2818
|
}
|
|
2804
|
-
return
|
|
2819
|
+
return line;
|
|
2805
2820
|
} catch {
|
|
2806
2821
|
return null;
|
|
2807
2822
|
}
|
|
2808
2823
|
}
|
|
2809
|
-
|
|
2810
|
-
|
|
2824
|
+
/** Get or create the single estimated liquidation line. */
|
|
2825
|
+
getOrCreateEstimatedLine() {
|
|
2826
|
+
if (this.estimatedLine != null) {
|
|
2827
|
+
return this.estimatedLine;
|
|
2828
|
+
}
|
|
2829
|
+
const line = this.createBaseLine();
|
|
2811
2830
|
if (line) {
|
|
2812
|
-
line
|
|
2813
|
-
this.updateLineLabel();
|
|
2831
|
+
this.estimatedLine = line;
|
|
2832
|
+
this.updateLineLabel(line, true);
|
|
2814
2833
|
}
|
|
2834
|
+
return line;
|
|
2815
2835
|
}
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
this.
|
|
2836
|
+
/** Get or create one position liquidation line by index. */
|
|
2837
|
+
getOrCreatePositionLine(index) {
|
|
2838
|
+
if (this.positionLines[index] != null) {
|
|
2839
|
+
return this.positionLines[index];
|
|
2840
|
+
}
|
|
2841
|
+
const line = this.createBaseLine();
|
|
2842
|
+
if (line) {
|
|
2843
|
+
this.positionLines[index] = line;
|
|
2844
|
+
this.updateLineLabel(line, false);
|
|
2820
2845
|
}
|
|
2846
|
+
return line;
|
|
2847
|
+
}
|
|
2848
|
+
/** Update estimated line price and metadata. */
|
|
2849
|
+
setEstimatedLinePrice(price) {
|
|
2850
|
+
const line = this.getOrCreateEstimatedLine();
|
|
2851
|
+
if (!line) return;
|
|
2852
|
+
line.setPrice(price);
|
|
2853
|
+
this.updateLineLabel(line, true);
|
|
2854
|
+
}
|
|
2855
|
+
/** Sync position lines to input items (create/update/remove extra lines). */
|
|
2856
|
+
renderPositionLines(items) {
|
|
2857
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
2858
|
+
const line = this.getOrCreatePositionLine(i);
|
|
2859
|
+
if (!line) continue;
|
|
2860
|
+
line.setLineStyle(0);
|
|
2861
|
+
line.setPrice(items[i].price);
|
|
2862
|
+
this.updateLineLabel(line, false, items[i].marginMode, items[i].leverage);
|
|
2863
|
+
}
|
|
2864
|
+
for (let i = items.length; i < this.positionLines.length; i += 1) {
|
|
2865
|
+
this.positionLines[i]?.remove();
|
|
2866
|
+
}
|
|
2867
|
+
this.positionLines = this.positionLines.slice(0, items.length);
|
|
2868
|
+
}
|
|
2869
|
+
/** Remove the estimated line if it exists. */
|
|
2870
|
+
removeEstimatedLine() {
|
|
2871
|
+
if (this.estimatedLine) {
|
|
2872
|
+
this.estimatedLine.remove();
|
|
2873
|
+
this.estimatedLine = null;
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
/** Remove all position lines if they exist. */
|
|
2877
|
+
removePositionLines() {
|
|
2878
|
+
this.positionLines.forEach((line) => line.remove());
|
|
2879
|
+
this.positionLines = [];
|
|
2821
2880
|
}
|
|
2822
|
-
/**
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2881
|
+
/**
|
|
2882
|
+
* Ensure line tooltip/text reflect its source (estimated vs position + margin mode).
|
|
2883
|
+
* When showing margin mode, we also append leverage (if available) right after it.
|
|
2884
|
+
*/
|
|
2885
|
+
updateLineLabel(line, isEstimated, marginMode, leverage) {
|
|
2886
|
+
const key = isEstimated ? "orderEntry.estLiqPrice" : "positions.column.liqPrice";
|
|
2887
|
+
let label = i18n.i18n.t(key);
|
|
2888
|
+
if (!isEstimated && marginMode) {
|
|
2889
|
+
const marginModeLabel = i18n.i18n.t(
|
|
2890
|
+
marginMode === "ISOLATED" ? "marginMode.isolated" : "marginMode.cross"
|
|
2891
|
+
);
|
|
2892
|
+
const leverageLabel = leverage != null && Number.isFinite(leverage) ? ` ${leverage}x` : "";
|
|
2893
|
+
label += ` (${marginModeLabel}${leverageLabel})`;
|
|
2894
|
+
}
|
|
2895
|
+
line.setTooltip(label).setText(label);
|
|
2828
2896
|
}
|
|
2829
2897
|
};
|
|
2830
2898
|
|
|
@@ -3240,7 +3308,11 @@ var PositionLineService = class _PositionLineService {
|
|
|
3240
3308
|
);
|
|
3241
3309
|
const quantity = _PositionLineService.getPositionQuantity(position.balance);
|
|
3242
3310
|
if (needDrawMarginMode) {
|
|
3243
|
-
|
|
3311
|
+
const marginModeLabel = i18n.i18n.t(
|
|
3312
|
+
position.marginMode === "ISOLATED" ? "marginMode.isolated" : "marginMode.cross"
|
|
3313
|
+
);
|
|
3314
|
+
const leverageLabel = position.leverage != null && Number.isFinite(position.leverage) ? ` ${position.leverage}x` : "";
|
|
3315
|
+
text += ` (${marginModeLabel}${leverageLabel})`;
|
|
3244
3316
|
}
|
|
3245
3317
|
const line = this.positionLines[idx].setQuantity(quantity).setPrice(price).setCloseButtonIconColor(colorConfig.closeIcon).setCloseButtonBorderColor(sideColor).setBodyBackgroundColor(pnlColor).setQuantityTextColor(sideColor).setBodyBorderColor(pnlColor).setLineColor(sideColor).setQuantityBorderColor(sideColor).setText(text);
|
|
3246
3318
|
if (colorConfig.closeIcon) {
|
|
@@ -3308,11 +3380,15 @@ var TPSLService = class {
|
|
|
3308
3380
|
}
|
|
3309
3381
|
}
|
|
3310
3382
|
showTPSLDialog(params) {
|
|
3311
|
-
const
|
|
3383
|
+
const markPrice = this.currentPosition?.markPrice ?? this.currentPosition.open;
|
|
3384
|
+
const positionSide = getPositionSide(this.currentPosition.balance ?? 0);
|
|
3385
|
+
const type = determineTpslType(params.price, markPrice, positionSide);
|
|
3386
|
+
const marginMode = this.currentPosition?.marginMode ?? types.MarginMode.CROSS;
|
|
3312
3387
|
ui.modal.show("TPSLSimpleDialogId", {
|
|
3313
|
-
title:
|
|
3388
|
+
title: type === "tp" ? i18n.i18n.t("tpsl.TPOrderConfirm") : i18n.i18n.t("tpsl.SLOrderConfirm"),
|
|
3314
3389
|
triggerPrice: params.price,
|
|
3315
|
-
type
|
|
3390
|
+
type,
|
|
3391
|
+
marginMode,
|
|
3316
3392
|
symbol: this.currentPosition.symbol,
|
|
3317
3393
|
onComplete: () => {
|
|
3318
3394
|
this.clearTPSLElements();
|
|
@@ -3322,7 +3398,7 @@ var TPSLService = class {
|
|
|
3322
3398
|
},
|
|
3323
3399
|
showAdvancedTPSLDialog: (options) => {
|
|
3324
3400
|
this.showAdvancedTPSLDialog({
|
|
3325
|
-
type
|
|
3401
|
+
type,
|
|
3326
3402
|
triggerPrice: params.price,
|
|
3327
3403
|
qty: options.qty
|
|
3328
3404
|
});
|
|
@@ -3344,29 +3420,27 @@ var TPSLService = class {
|
|
|
3344
3420
|
triggerPrice,
|
|
3345
3421
|
qty
|
|
3346
3422
|
}) {
|
|
3423
|
+
const onCloseHandler = () => {
|
|
3424
|
+
this.clearTPSLElements();
|
|
3425
|
+
this.chart.setScrollEnabled(true);
|
|
3426
|
+
this.chart.setZoomEnabled(true);
|
|
3427
|
+
this.interactiveMode = 0 /* NONE */;
|
|
3428
|
+
};
|
|
3347
3429
|
ui.modal.show("TPSLDialogId", {
|
|
3348
3430
|
withTriggerPrice: true,
|
|
3349
3431
|
type,
|
|
3350
3432
|
triggerPrice,
|
|
3351
3433
|
symbol: this.currentPosition?.symbol,
|
|
3352
3434
|
qty,
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
this.chart.setZoomEnabled(true);
|
|
3357
|
-
this.interactiveMode = 0 /* NONE */;
|
|
3358
|
-
}
|
|
3435
|
+
position: this.currentPosition,
|
|
3436
|
+
onComplete: onCloseHandler,
|
|
3437
|
+
onCancel: onCloseHandler
|
|
3359
3438
|
}).then(
|
|
3360
3439
|
() => {
|
|
3361
3440
|
},
|
|
3362
3441
|
(err) => {
|
|
3363
3442
|
}
|
|
3364
|
-
).finally(
|
|
3365
|
-
this.clearTPSLElements();
|
|
3366
|
-
this.chart.setScrollEnabled(true);
|
|
3367
|
-
this.chart.setZoomEnabled(true);
|
|
3368
|
-
this.interactiveMode = 0 /* NONE */;
|
|
3369
|
-
});
|
|
3443
|
+
).finally(onCloseHandler);
|
|
3370
3444
|
}
|
|
3371
3445
|
updatePositions(positions) {
|
|
3372
3446
|
this.lastPositions = positions;
|
|
@@ -3399,13 +3473,16 @@ var TPSLService = class {
|
|
|
3399
3473
|
}
|
|
3400
3474
|
drawTPSL(params) {
|
|
3401
3475
|
const { price } = params;
|
|
3402
|
-
const
|
|
3476
|
+
const markPrice = this.currentPosition?.markPrice ?? this.currentPosition.open;
|
|
3477
|
+
const positionSide = getPositionSide(this.currentPosition.balance ?? 0);
|
|
3478
|
+
const type = determineTpslType(price, markPrice, positionSide);
|
|
3479
|
+
const pnl = new utils.Decimal(price).minus(markPrice).mul(this.currentPosition?.balance ?? 0);
|
|
3403
3480
|
const { tpslOrderLine, verticalLine } = this.ensureTPSLElements({
|
|
3404
3481
|
price,
|
|
3405
3482
|
pnl
|
|
3406
3483
|
});
|
|
3407
|
-
const direction =
|
|
3408
|
-
const color =
|
|
3484
|
+
const direction = type === "tp" ? i18n.i18n.t("tpsl.tp") : i18n.i18n.t("tpsl.sl");
|
|
3485
|
+
const color = type === "tp" ? this.broker.colorConfig.upColor : this.broker.colorConfig.downColor;
|
|
3409
3486
|
tpslOrderLine?.setText(`${direction} ${pnl.toDecimalPlaces(2).toNumber()}`).setBodyTextColor(color).setBodyBorderColor(color).setLineColor(color);
|
|
3410
3487
|
if (this.tpslVerticalLineTime) {
|
|
3411
3488
|
verticalLine?.setPoints([
|
|
@@ -3558,7 +3635,7 @@ var Renderer = class {
|
|
|
3558
3635
|
this.orderLineService.updatePositions(positions);
|
|
3559
3636
|
this.tpslService.updatePositions(positions);
|
|
3560
3637
|
}
|
|
3561
|
-
/** Update
|
|
3638
|
+
/** Update liquidation price lines (positions + optional estimated from Order Entry). */
|
|
3562
3639
|
renderLiquidationLine(params) {
|
|
3563
3640
|
this.liquidationLineService.renderLiquidationLine(params);
|
|
3564
3641
|
}
|
|
@@ -3615,9 +3692,7 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3615
3692
|
});
|
|
3616
3693
|
const positions = React3.useMemo(() => {
|
|
3617
3694
|
if (!rows?.length) return [];
|
|
3618
|
-
return rows.filter(
|
|
3619
|
-
(item) => item.symbol === symbol && (marginMode == null || item.margin_mode === marginMode)
|
|
3620
|
-
);
|
|
3695
|
+
return rows.filter((item) => item.symbol === symbol);
|
|
3621
3696
|
}, [rows, symbol, marginMode]);
|
|
3622
3697
|
const [pendingOrders] = hooks.useOrderStream({
|
|
3623
3698
|
status: types.OrderStatus.INCOMPLETE,
|
|
@@ -3662,13 +3737,16 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3662
3737
|
symbol: item.symbol,
|
|
3663
3738
|
open: item.average_open_price,
|
|
3664
3739
|
balance: item.position_qty,
|
|
3740
|
+
leverage: item.leverage,
|
|
3665
3741
|
closablePosition: 9999,
|
|
3666
3742
|
// @ts-ignore
|
|
3667
3743
|
unrealPnl: item.unrealized_pnl ?? 0,
|
|
3668
3744
|
interest: 0,
|
|
3669
3745
|
unrealPnlDecimal: 2,
|
|
3670
3746
|
basePriceDecimal: 4,
|
|
3671
|
-
marginMode: item.margin_mode
|
|
3747
|
+
marginMode: item.margin_mode,
|
|
3748
|
+
margin_mode: item.margin_mode,
|
|
3749
|
+
markPrice: item.mark_price
|
|
3672
3750
|
};
|
|
3673
3751
|
});
|
|
3674
3752
|
renderer?.renderPositions(positionList);
|
|
@@ -3688,11 +3766,24 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3688
3766
|
}, [ee, symbol]);
|
|
3689
3767
|
React3.useEffect(() => {
|
|
3690
3768
|
if (!renderer || !displayControlSetting?.position) return;
|
|
3691
|
-
const
|
|
3692
|
-
|
|
3769
|
+
const positionLiqItems = (positions ?? []).filter((p) => p.symbol === symbol).flatMap((p) => {
|
|
3770
|
+
const price = p.est_liq_price;
|
|
3771
|
+
const leverage = p.leverage;
|
|
3772
|
+
if (price == null || !Number.isFinite(price)) {
|
|
3773
|
+
return [];
|
|
3774
|
+
}
|
|
3775
|
+
return [
|
|
3776
|
+
{
|
|
3777
|
+
price,
|
|
3778
|
+
marginMode: p.margin_mode,
|
|
3779
|
+
leverage: leverage ?? void 0
|
|
3780
|
+
}
|
|
3781
|
+
];
|
|
3782
|
+
});
|
|
3693
3783
|
const effectiveEstimatedLiqPrice = estimatedLiqPrice != null && Number.isFinite(estimatedLiqPrice) ? estimatedLiqPrice : null;
|
|
3784
|
+
const showPositionLiqItems = displayControlSetting?.liquidationPrice !== false ? positionLiqItems : [];
|
|
3694
3785
|
renderer.renderLiquidationLine({
|
|
3695
|
-
|
|
3786
|
+
positionLiqItems: showPositionLiqItems,
|
|
3696
3787
|
estimatedLiqPrice: effectiveEstimatedLiqPrice
|
|
3697
3788
|
});
|
|
3698
3789
|
}, [
|
|
@@ -3700,7 +3791,8 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3700
3791
|
positions,
|
|
3701
3792
|
symbol,
|
|
3702
3793
|
estimatedLiqPrice,
|
|
3703
|
-
displayControlSetting?.position
|
|
3794
|
+
displayControlSetting?.position,
|
|
3795
|
+
displayControlSetting?.liquidationPrice
|
|
3704
3796
|
]);
|
|
3705
3797
|
React3.useEffect(() => {
|
|
3706
3798
|
if (!displayControlSetting || !displayControlSetting.buySell) {
|
|
@@ -4321,7 +4413,8 @@ function useTradingviewScript(props) {
|
|
|
4321
4413
|
stopOrders: true,
|
|
4322
4414
|
tpsl: true,
|
|
4323
4415
|
positionTpsl: true,
|
|
4324
|
-
trailingStop: true
|
|
4416
|
+
trailingStop: true,
|
|
4417
|
+
liquidationPrice: true
|
|
4325
4418
|
};
|
|
4326
4419
|
});
|
|
4327
4420
|
const [interval, setInterval] = React3.useState(() => {
|