@orderly.network/ui-tradingview 3.0.0-beta.0 → 3.0.0-beta.2
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.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import React3, { forwardRef, useRef, useState, useMemo, useEffect, useCallback }
|
|
|
3
3
|
import { useTranslation, Trans, useLocaleCode, i18n } from '@orderly.network/i18n';
|
|
4
4
|
import { injectable, cn, Flex, Divider, useScreen, useOrderlyTheme, Box, useThemeAttribute, toast, modal, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, Text, Switch } from '@orderly.network/ui';
|
|
5
5
|
import { useMediaQuery, useConfig, useAccount, useSymbolsInfo, useLocalStorage, useOrderEntry_deprecated, useMarginModeBySymbol, useWS, usePositionStream, useOrderStream, useEventEmitter } from '@orderly.network/hooks';
|
|
6
|
-
import { MEDIA_TABLET, OrderSide, TradingviewFullscreenKey, OrderType, AccountStatusEnum, OrderStatus, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE } from '@orderly.network/types';
|
|
6
|
+
import { MEDIA_TABLET, OrderSide, TradingviewFullscreenKey, OrderType, AccountStatusEnum, OrderStatus, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE, MarginMode } from '@orderly.network/types';
|
|
7
7
|
import { Decimal, commify, getTrailingStopPrice, getPrecisionByNumber } from '@orderly.network/utils';
|
|
8
8
|
import { startOfSecond, startOfMinute, startOfHour, startOfDay, startOfMonth, startOfYear, startOfWeek } from 'date-fns';
|
|
9
9
|
|
|
@@ -658,6 +658,10 @@ var init_displayControl_desktop = __esm({
|
|
|
658
658
|
{
|
|
659
659
|
label: t("orderEntry.orderType.trailingStop"),
|
|
660
660
|
id: "trailingStop"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
label: t("tradingView.displayControl.liquidationPrice"),
|
|
664
|
+
id: "liquidationPrice"
|
|
661
665
|
}
|
|
662
666
|
];
|
|
663
667
|
}, [t]);
|
|
@@ -719,7 +723,7 @@ var init_displayControl_desktop = __esm({
|
|
|
719
723
|
{
|
|
720
724
|
className: cn(
|
|
721
725
|
"oui-text-sm oui-text-base-contrast-80",
|
|
722
|
-
!displayControlState[item.id] && "oui-text-base-contrast-36"
|
|
726
|
+
!(displayControlState[item.id] ?? true) && "oui-text-base-contrast-36"
|
|
723
727
|
),
|
|
724
728
|
children: item.label
|
|
725
729
|
}
|
|
@@ -728,7 +732,7 @@ var init_displayControl_desktop = __esm({
|
|
|
728
732
|
Switch,
|
|
729
733
|
{
|
|
730
734
|
className: "oui-h-4 oui-w-8",
|
|
731
|
-
checked: displayControlState[item.id],
|
|
735
|
+
checked: displayControlState[item.id] ?? true,
|
|
732
736
|
onCheckedChange: (checked) => {
|
|
733
737
|
changeDisplayControlState({
|
|
734
738
|
...displayControlState,
|
|
@@ -793,8 +797,10 @@ var init_displayControl_mobile = __esm({
|
|
|
793
797
|
label: t("orderEntry.orderType.trailingStop"),
|
|
794
798
|
id: "trailingStop"
|
|
795
799
|
},
|
|
796
|
-
|
|
797
|
-
|
|
800
|
+
{
|
|
801
|
+
label: t("tradingView.displayControl.liquidationPrice"),
|
|
802
|
+
id: "liquidationPrice"
|
|
803
|
+
}
|
|
798
804
|
]
|
|
799
805
|
];
|
|
800
806
|
}, [t]);
|
|
@@ -847,7 +853,7 @@ var init_displayControl_mobile = __esm({
|
|
|
847
853
|
"oui-flex oui-h-6 oui-w-full oui-items-center oui-justify-between",
|
|
848
854
|
"oui-rounded oui-px-2 oui-text-2xs",
|
|
849
855
|
item.id && "oui-bg-base-5",
|
|
850
|
-
props.displayControlState[item.id] ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
|
|
856
|
+
props.displayControlState[item.id] ?? true ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
|
|
851
857
|
),
|
|
852
858
|
onClick: () => {
|
|
853
859
|
if (!item.id) {
|
|
@@ -860,7 +866,7 @@ var init_displayControl_mobile = __esm({
|
|
|
860
866
|
},
|
|
861
867
|
children: item.id && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
862
868
|
/* @__PURE__ */ jsx("div", { children: item.label }),
|
|
863
|
-
props.displayControlState[item.id] ? /* @__PURE__ */ jsx(SelectedIcon, { className: "oui-size-3" }) : /* @__PURE__ */ jsx(UnSelectIcon, { className: "oui-size-3" })
|
|
869
|
+
props.displayControlState[item.id] ?? true ? /* @__PURE__ */ jsx(SelectedIcon, { className: "oui-size-3" }) : /* @__PURE__ */ jsx(UnSelectIcon, { className: "oui-size-3" })
|
|
864
870
|
] })
|
|
865
871
|
},
|
|
866
872
|
item.id || index
|
|
@@ -2382,13 +2388,22 @@ var getTpslEstPnl = (tpslOrder, position) => {
|
|
|
2382
2388
|
tpslOrder.type === "CLOSE_POSITION" /* CLOSE_POSITION */ ? position.balance : tpslOrder.quantity
|
|
2383
2389
|
);
|
|
2384
2390
|
const sideFlag = tpslOrder.side === "SELL" /* SELL */ ? 1 : -1;
|
|
2385
|
-
const
|
|
2386
|
-
const estPnl = new Decimal(tpslOrder.trigger_price).minus(
|
|
2387
|
-
return { estPnl, quantity, openPrice };
|
|
2391
|
+
const priceRef = position.open;
|
|
2392
|
+
const estPnl = new Decimal(tpslOrder.trigger_price).minus(priceRef).times(quantity).times(sideFlag).toString();
|
|
2393
|
+
return { estPnl, quantity, openPrice: priceRef };
|
|
2388
2394
|
};
|
|
2389
2395
|
var formatPnl = (pnl) => {
|
|
2390
2396
|
return pnl !== void 0 && pnl !== "" ? new Decimal(pnl).todp(EST_TPSL_PNL_DECIMAL, Decimal.ROUND_FLOOR) : textDash;
|
|
2391
2397
|
};
|
|
2398
|
+
var getPositionSide = (balance) => {
|
|
2399
|
+
return balance >= 0 ? "LONG" /* LONG */ : "SHORT" /* SHORT */;
|
|
2400
|
+
};
|
|
2401
|
+
var determineTpslType = (targetPrice, markPrice, positionSide) => {
|
|
2402
|
+
if (positionSide === "LONG" /* LONG */) {
|
|
2403
|
+
return targetPrice > markPrice ? "tp" : "sl";
|
|
2404
|
+
}
|
|
2405
|
+
return targetPrice < markPrice ? "tp" : "sl";
|
|
2406
|
+
};
|
|
2392
2407
|
function useCancelOrder() {
|
|
2393
2408
|
const [
|
|
2394
2409
|
pendingOrders,
|
|
@@ -2741,41 +2756,42 @@ var ExecutionService = class _ExecutionService {
|
|
|
2741
2756
|
};
|
|
2742
2757
|
var LiquidationLineService = class {
|
|
2743
2758
|
constructor(instance, broker) {
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2759
|
+
/** Single temporary line driven by Order Entry estimated liquidation price. */
|
|
2760
|
+
this.estimatedLine = null;
|
|
2761
|
+
/** Persistent lines driven by current positions (can be multiple, e.g. cross + isolated). */
|
|
2762
|
+
this.positionLines = [];
|
|
2747
2763
|
this.instance = instance;
|
|
2748
2764
|
this.broker = broker;
|
|
2749
2765
|
}
|
|
2750
2766
|
/**
|
|
2751
|
-
* Render or update
|
|
2767
|
+
* Render or update liquidation lines. Call when position or estimated liq. price changes.
|
|
2752
2768
|
*/
|
|
2753
2769
|
renderLiquidationLine(params) {
|
|
2754
|
-
const {
|
|
2770
|
+
const { positionLiqItems, estimatedLiqPrice } = params;
|
|
2755
2771
|
const hasValidEst = estimatedLiqPrice != null && Number.isFinite(estimatedLiqPrice);
|
|
2756
|
-
const
|
|
2772
|
+
const validPositionItems = (positionLiqItems ?? []).filter(
|
|
2773
|
+
(item) => item != null && item.price != null && Number.isFinite(item.price)
|
|
2774
|
+
);
|
|
2757
2775
|
if (hasValidEst) {
|
|
2758
|
-
this.
|
|
2759
|
-
this.
|
|
2760
|
-
this.
|
|
2776
|
+
this.removePositionLines();
|
|
2777
|
+
this.setEstimatedLinePrice(estimatedLiqPrice);
|
|
2778
|
+
this.estimatedLine?.setLineStyle(1);
|
|
2761
2779
|
return;
|
|
2762
2780
|
}
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
this.
|
|
2766
|
-
this.line?.setLineStyle(0);
|
|
2781
|
+
this.removeEstimatedLine();
|
|
2782
|
+
if (validPositionItems.length > 0) {
|
|
2783
|
+
this.renderPositionLines(validPositionItems);
|
|
2767
2784
|
return;
|
|
2768
2785
|
}
|
|
2769
|
-
this.
|
|
2786
|
+
this.removePositionLines();
|
|
2770
2787
|
}
|
|
2771
|
-
/** Remove
|
|
2788
|
+
/** Remove all liquidation lines (e.g. on destroy). */
|
|
2772
2789
|
remove() {
|
|
2773
|
-
this.
|
|
2790
|
+
this.removeEstimatedLine();
|
|
2791
|
+
this.removePositionLines();
|
|
2774
2792
|
}
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
return this.line;
|
|
2778
|
-
}
|
|
2793
|
+
/** Build a TradingView order line and apply shared style. */
|
|
2794
|
+
createBaseLine() {
|
|
2779
2795
|
try {
|
|
2780
2796
|
const activeChart = this.instance.activeChart();
|
|
2781
2797
|
if (!activeChart) return null;
|
|
@@ -2784,41 +2800,93 @@ var LiquidationLineService = class {
|
|
|
2784
2800
|
const colorConfig = this.broker.colorConfig;
|
|
2785
2801
|
const lineColor = colorConfig.liqLineColor ?? colorConfig.textColor;
|
|
2786
2802
|
if (!lineColor) return null;
|
|
2787
|
-
|
|
2788
|
-
this.updateLineLabel();
|
|
2803
|
+
let line = orderLine.setCancellable(false).setLineLength(100).setEditable(false).setExtendLeft(true).setQuantity("").setLineStyle(0).setLineColor(lineColor).setBodyBorderColor(lineColor);
|
|
2789
2804
|
if (colorConfig.chartBG) {
|
|
2790
|
-
|
|
2805
|
+
line = line.setBodyBackgroundColor(colorConfig.chartBG).setQuantityBackgroundColor(colorConfig.chartBG);
|
|
2791
2806
|
}
|
|
2792
2807
|
if (colorConfig.textColor) {
|
|
2793
|
-
|
|
2808
|
+
line = line.setBodyTextColor(colorConfig.textColor);
|
|
2794
2809
|
}
|
|
2795
2810
|
if (colorConfig.font) {
|
|
2796
|
-
|
|
2811
|
+
line = line.setBodyFont(colorConfig.font).setQuantityFont(colorConfig.font);
|
|
2797
2812
|
}
|
|
2798
|
-
return
|
|
2813
|
+
return line;
|
|
2799
2814
|
} catch {
|
|
2800
2815
|
return null;
|
|
2801
2816
|
}
|
|
2802
2817
|
}
|
|
2803
|
-
|
|
2804
|
-
|
|
2818
|
+
/** Get or create the single estimated liquidation line. */
|
|
2819
|
+
getOrCreateEstimatedLine() {
|
|
2820
|
+
if (this.estimatedLine != null) {
|
|
2821
|
+
return this.estimatedLine;
|
|
2822
|
+
}
|
|
2823
|
+
const line = this.createBaseLine();
|
|
2805
2824
|
if (line) {
|
|
2806
|
-
line
|
|
2807
|
-
this.updateLineLabel();
|
|
2825
|
+
this.estimatedLine = line;
|
|
2826
|
+
this.updateLineLabel(line, true);
|
|
2808
2827
|
}
|
|
2828
|
+
return line;
|
|
2809
2829
|
}
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
this.
|
|
2830
|
+
/** Get or create one position liquidation line by index. */
|
|
2831
|
+
getOrCreatePositionLine(index) {
|
|
2832
|
+
if (this.positionLines[index] != null) {
|
|
2833
|
+
return this.positionLines[index];
|
|
2834
|
+
}
|
|
2835
|
+
const line = this.createBaseLine();
|
|
2836
|
+
if (line) {
|
|
2837
|
+
this.positionLines[index] = line;
|
|
2838
|
+
this.updateLineLabel(line, false);
|
|
2814
2839
|
}
|
|
2840
|
+
return line;
|
|
2841
|
+
}
|
|
2842
|
+
/** Update estimated line price and metadata. */
|
|
2843
|
+
setEstimatedLinePrice(price) {
|
|
2844
|
+
const line = this.getOrCreateEstimatedLine();
|
|
2845
|
+
if (!line) return;
|
|
2846
|
+
line.setPrice(price);
|
|
2847
|
+
this.updateLineLabel(line, true);
|
|
2848
|
+
}
|
|
2849
|
+
/** Sync position lines to input items (create/update/remove extra lines). */
|
|
2850
|
+
renderPositionLines(items) {
|
|
2851
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
2852
|
+
const line = this.getOrCreatePositionLine(i);
|
|
2853
|
+
if (!line) continue;
|
|
2854
|
+
line.setLineStyle(0);
|
|
2855
|
+
line.setPrice(items[i].price);
|
|
2856
|
+
this.updateLineLabel(line, false, items[i].marginMode, items[i].leverage);
|
|
2857
|
+
}
|
|
2858
|
+
for (let i = items.length; i < this.positionLines.length; i += 1) {
|
|
2859
|
+
this.positionLines[i]?.remove();
|
|
2860
|
+
}
|
|
2861
|
+
this.positionLines = this.positionLines.slice(0, items.length);
|
|
2862
|
+
}
|
|
2863
|
+
/** Remove the estimated line if it exists. */
|
|
2864
|
+
removeEstimatedLine() {
|
|
2865
|
+
if (this.estimatedLine) {
|
|
2866
|
+
this.estimatedLine.remove();
|
|
2867
|
+
this.estimatedLine = null;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
/** Remove all position lines if they exist. */
|
|
2871
|
+
removePositionLines() {
|
|
2872
|
+
this.positionLines.forEach((line) => line.remove());
|
|
2873
|
+
this.positionLines = [];
|
|
2815
2874
|
}
|
|
2816
|
-
/**
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2875
|
+
/**
|
|
2876
|
+
* Ensure line tooltip/text reflect its source (estimated vs position + margin mode).
|
|
2877
|
+
* When showing margin mode, we also append leverage (if available) right after it.
|
|
2878
|
+
*/
|
|
2879
|
+
updateLineLabel(line, isEstimated, marginMode, leverage) {
|
|
2880
|
+
const key = isEstimated ? "orderEntry.estLiqPrice" : "positions.column.liqPrice";
|
|
2881
|
+
let label = i18n.t(key);
|
|
2882
|
+
if (!isEstimated && marginMode) {
|
|
2883
|
+
const marginModeLabel = i18n.t(
|
|
2884
|
+
marginMode === "ISOLATED" ? "marginMode.isolated" : "marginMode.cross"
|
|
2885
|
+
);
|
|
2886
|
+
const leverageLabel = leverage != null && Number.isFinite(leverage) ? ` ${leverage}x` : "";
|
|
2887
|
+
label += ` (${marginModeLabel}${leverageLabel})`;
|
|
2888
|
+
}
|
|
2889
|
+
line.setTooltip(label).setText(label);
|
|
2822
2890
|
}
|
|
2823
2891
|
};
|
|
2824
2892
|
|
|
@@ -3234,7 +3302,11 @@ var PositionLineService = class _PositionLineService {
|
|
|
3234
3302
|
);
|
|
3235
3303
|
const quantity = _PositionLineService.getPositionQuantity(position.balance);
|
|
3236
3304
|
if (needDrawMarginMode) {
|
|
3237
|
-
|
|
3305
|
+
const marginModeLabel = i18n.t(
|
|
3306
|
+
position.marginMode === "ISOLATED" ? "marginMode.isolated" : "marginMode.cross"
|
|
3307
|
+
);
|
|
3308
|
+
const leverageLabel = position.leverage != null && Number.isFinite(position.leverage) ? ` ${position.leverage}x` : "";
|
|
3309
|
+
text += ` (${marginModeLabel}${leverageLabel})`;
|
|
3238
3310
|
}
|
|
3239
3311
|
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);
|
|
3240
3312
|
if (colorConfig.closeIcon) {
|
|
@@ -3302,11 +3374,15 @@ var TPSLService = class {
|
|
|
3302
3374
|
}
|
|
3303
3375
|
}
|
|
3304
3376
|
showTPSLDialog(params) {
|
|
3305
|
-
const
|
|
3377
|
+
const markPrice = this.currentPosition?.markPrice ?? this.currentPosition.open;
|
|
3378
|
+
const positionSide = getPositionSide(this.currentPosition.balance ?? 0);
|
|
3379
|
+
const type = determineTpslType(params.price, markPrice, positionSide);
|
|
3380
|
+
const marginMode = this.currentPosition?.marginMode ?? MarginMode.CROSS;
|
|
3306
3381
|
modal.show("TPSLSimpleDialogId", {
|
|
3307
|
-
title:
|
|
3382
|
+
title: type === "tp" ? i18n.t("tpsl.TPOrderConfirm") : i18n.t("tpsl.SLOrderConfirm"),
|
|
3308
3383
|
triggerPrice: params.price,
|
|
3309
|
-
type
|
|
3384
|
+
type,
|
|
3385
|
+
marginMode,
|
|
3310
3386
|
symbol: this.currentPosition.symbol,
|
|
3311
3387
|
onComplete: () => {
|
|
3312
3388
|
this.clearTPSLElements();
|
|
@@ -3316,7 +3392,7 @@ var TPSLService = class {
|
|
|
3316
3392
|
},
|
|
3317
3393
|
showAdvancedTPSLDialog: (options) => {
|
|
3318
3394
|
this.showAdvancedTPSLDialog({
|
|
3319
|
-
type
|
|
3395
|
+
type,
|
|
3320
3396
|
triggerPrice: params.price,
|
|
3321
3397
|
qty: options.qty
|
|
3322
3398
|
});
|
|
@@ -3338,29 +3414,27 @@ var TPSLService = class {
|
|
|
3338
3414
|
triggerPrice,
|
|
3339
3415
|
qty
|
|
3340
3416
|
}) {
|
|
3417
|
+
const onCloseHandler = () => {
|
|
3418
|
+
this.clearTPSLElements();
|
|
3419
|
+
this.chart.setScrollEnabled(true);
|
|
3420
|
+
this.chart.setZoomEnabled(true);
|
|
3421
|
+
this.interactiveMode = 0 /* NONE */;
|
|
3422
|
+
};
|
|
3341
3423
|
modal.show("TPSLDialogId", {
|
|
3342
3424
|
withTriggerPrice: true,
|
|
3343
3425
|
type,
|
|
3344
3426
|
triggerPrice,
|
|
3345
3427
|
symbol: this.currentPosition?.symbol,
|
|
3346
3428
|
qty,
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
this.chart.setZoomEnabled(true);
|
|
3351
|
-
this.interactiveMode = 0 /* NONE */;
|
|
3352
|
-
}
|
|
3429
|
+
position: this.currentPosition,
|
|
3430
|
+
onComplete: onCloseHandler,
|
|
3431
|
+
onCancel: onCloseHandler
|
|
3353
3432
|
}).then(
|
|
3354
3433
|
() => {
|
|
3355
3434
|
},
|
|
3356
3435
|
(err) => {
|
|
3357
3436
|
}
|
|
3358
|
-
).finally(
|
|
3359
|
-
this.clearTPSLElements();
|
|
3360
|
-
this.chart.setScrollEnabled(true);
|
|
3361
|
-
this.chart.setZoomEnabled(true);
|
|
3362
|
-
this.interactiveMode = 0 /* NONE */;
|
|
3363
|
-
});
|
|
3437
|
+
).finally(onCloseHandler);
|
|
3364
3438
|
}
|
|
3365
3439
|
updatePositions(positions) {
|
|
3366
3440
|
this.lastPositions = positions;
|
|
@@ -3393,13 +3467,16 @@ var TPSLService = class {
|
|
|
3393
3467
|
}
|
|
3394
3468
|
drawTPSL(params) {
|
|
3395
3469
|
const { price } = params;
|
|
3396
|
-
const
|
|
3470
|
+
const markPrice = this.currentPosition?.markPrice ?? this.currentPosition.open;
|
|
3471
|
+
const positionSide = getPositionSide(this.currentPosition.balance ?? 0);
|
|
3472
|
+
const type = determineTpslType(price, markPrice, positionSide);
|
|
3473
|
+
const pnl = new Decimal(price).minus(markPrice).mul(this.currentPosition?.balance ?? 0);
|
|
3397
3474
|
const { tpslOrderLine, verticalLine } = this.ensureTPSLElements({
|
|
3398
3475
|
price,
|
|
3399
3476
|
pnl
|
|
3400
3477
|
});
|
|
3401
|
-
const direction =
|
|
3402
|
-
const color =
|
|
3478
|
+
const direction = type === "tp" ? i18n.t("tpsl.tp") : i18n.t("tpsl.sl");
|
|
3479
|
+
const color = type === "tp" ? this.broker.colorConfig.upColor : this.broker.colorConfig.downColor;
|
|
3403
3480
|
tpslOrderLine?.setText(`${direction} ${pnl.toDecimalPlaces(2).toNumber()}`).setBodyTextColor(color).setBodyBorderColor(color).setLineColor(color);
|
|
3404
3481
|
if (this.tpslVerticalLineTime) {
|
|
3405
3482
|
verticalLine?.setPoints([
|
|
@@ -3552,7 +3629,7 @@ var Renderer = class {
|
|
|
3552
3629
|
this.orderLineService.updatePositions(positions);
|
|
3553
3630
|
this.tpslService.updatePositions(positions);
|
|
3554
3631
|
}
|
|
3555
|
-
/** Update
|
|
3632
|
+
/** Update liquidation price lines (positions + optional estimated from Order Entry). */
|
|
3556
3633
|
renderLiquidationLine(params) {
|
|
3557
3634
|
this.liquidationLineService.renderLiquidationLine(params);
|
|
3558
3635
|
}
|
|
@@ -3609,9 +3686,7 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3609
3686
|
});
|
|
3610
3687
|
const positions = useMemo(() => {
|
|
3611
3688
|
if (!rows?.length) return [];
|
|
3612
|
-
return rows.filter(
|
|
3613
|
-
(item) => item.symbol === symbol && (marginMode == null || item.margin_mode === marginMode)
|
|
3614
|
-
);
|
|
3689
|
+
return rows.filter((item) => item.symbol === symbol);
|
|
3615
3690
|
}, [rows, symbol, marginMode]);
|
|
3616
3691
|
const [pendingOrders] = useOrderStream({
|
|
3617
3692
|
status: OrderStatus.INCOMPLETE,
|
|
@@ -3656,13 +3731,16 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3656
3731
|
symbol: item.symbol,
|
|
3657
3732
|
open: item.average_open_price,
|
|
3658
3733
|
balance: item.position_qty,
|
|
3734
|
+
leverage: item.leverage,
|
|
3659
3735
|
closablePosition: 9999,
|
|
3660
3736
|
// @ts-ignore
|
|
3661
3737
|
unrealPnl: item.unrealized_pnl ?? 0,
|
|
3662
3738
|
interest: 0,
|
|
3663
3739
|
unrealPnlDecimal: 2,
|
|
3664
3740
|
basePriceDecimal: 4,
|
|
3665
|
-
marginMode: item.margin_mode
|
|
3741
|
+
marginMode: item.margin_mode,
|
|
3742
|
+
margin_mode: item.margin_mode,
|
|
3743
|
+
markPrice: item.mark_price
|
|
3666
3744
|
};
|
|
3667
3745
|
});
|
|
3668
3746
|
renderer?.renderPositions(positionList);
|
|
@@ -3682,11 +3760,24 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3682
3760
|
}, [ee, symbol]);
|
|
3683
3761
|
useEffect(() => {
|
|
3684
3762
|
if (!renderer || !displayControlSetting?.position) return;
|
|
3685
|
-
const
|
|
3686
|
-
|
|
3763
|
+
const positionLiqItems = (positions ?? []).filter((p) => p.symbol === symbol).flatMap((p) => {
|
|
3764
|
+
const price = p.est_liq_price;
|
|
3765
|
+
const leverage = p.leverage;
|
|
3766
|
+
if (price == null || !Number.isFinite(price)) {
|
|
3767
|
+
return [];
|
|
3768
|
+
}
|
|
3769
|
+
return [
|
|
3770
|
+
{
|
|
3771
|
+
price,
|
|
3772
|
+
marginMode: p.margin_mode,
|
|
3773
|
+
leverage: leverage ?? void 0
|
|
3774
|
+
}
|
|
3775
|
+
];
|
|
3776
|
+
});
|
|
3687
3777
|
const effectiveEstimatedLiqPrice = estimatedLiqPrice != null && Number.isFinite(estimatedLiqPrice) ? estimatedLiqPrice : null;
|
|
3778
|
+
const showPositionLiqItems = displayControlSetting?.liquidationPrice !== false ? positionLiqItems : [];
|
|
3688
3779
|
renderer.renderLiquidationLine({
|
|
3689
|
-
|
|
3780
|
+
positionLiqItems: showPositionLiqItems,
|
|
3690
3781
|
estimatedLiqPrice: effectiveEstimatedLiqPrice
|
|
3691
3782
|
});
|
|
3692
3783
|
}, [
|
|
@@ -3694,7 +3785,8 @@ function useCreateRenderer(symbol, displayControlSetting, marginMode) {
|
|
|
3694
3785
|
positions,
|
|
3695
3786
|
symbol,
|
|
3696
3787
|
estimatedLiqPrice,
|
|
3697
|
-
displayControlSetting?.position
|
|
3788
|
+
displayControlSetting?.position,
|
|
3789
|
+
displayControlSetting?.liquidationPrice
|
|
3698
3790
|
]);
|
|
3699
3791
|
useEffect(() => {
|
|
3700
3792
|
if (!displayControlSetting || !displayControlSetting.buySell) {
|
|
@@ -4315,7 +4407,8 @@ function useTradingviewScript(props) {
|
|
|
4315
4407
|
stopOrders: true,
|
|
4316
4408
|
tpsl: true,
|
|
4317
4409
|
positionTpsl: true,
|
|
4318
|
-
trailingStop: true
|
|
4410
|
+
trailingStop: true,
|
|
4411
|
+
liquidationPrice: true
|
|
4319
4412
|
};
|
|
4320
4413
|
});
|
|
4321
4414
|
const [interval, setInterval] = useState(() => {
|