From 776b528bf6efa52cb10823f123c681405196963e Mon Sep 17 00:00:00 2001 From: mulan xia Date: Thu, 8 Feb 2024 01:28:56 -0500 Subject: [PATCH] add trailing percent --- src/views/charts/TvChart.tsx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/views/charts/TvChart.tsx b/src/views/charts/TvChart.tsx index 35e7233..fedf080 100644 --- a/src/views/charts/TvChart.tsx +++ b/src/views/charts/TvChart.tsx @@ -112,20 +112,32 @@ export const TvChart = () => { const drawOrderLines = () => { currentMarketOrders.forEach( - ({ id, type, status, side, cancelReason, remainingSize, size, triggerPrice, price }) => { + ({ + id, + type, + status, + side, + cancelReason, + remainingSize, + size, + triggerPrice, + price, + trailingPercent, + }) => { const key = `${side.rawValue}-${id}`; - const orderType = type.rawValue as KotlinIrEnumValues; const quantity = (remainingSize ?? size).toString(); - const orderString = stringGetter({ + const orderType = type.rawValue as KotlinIrEnumValues; + const orderLabel = stringGetter({ key: ORDER_TYPE_LABEL_MAPPING[orderType] || '', }); + const orderString = trailingPercent ? `${orderLabel} ${trailingPercent}%` : orderLabel; + const shouldShow = !cancelReason && (status === AbacusOrderStatus.open || status === AbacusOrderStatus.untriggered); const maybeOrderLine = key in orderLines ? orderLines[key] : null; - if (maybeOrderLine) { if (!shouldShow) { maybeOrderLine.remove(); @@ -135,9 +147,7 @@ export const TvChart = () => { maybeOrderLine.setQuantity(quantity); return; } - } else if (!shouldShow) { - return; - } else { + } else if (shouldShow) { const { orderColor, borderColor, backgroundColor, textColor, textButtonColor } = getOrderLineColors({ side: side.rawValue, appTheme, appColorMode });