From 443971f127b1c278dfe4bf376594d5b8081cfd1d Mon Sep 17 00:00:00 2001 From: mnsrulz Date: Fri, 12 Apr 2024 03:03:44 +0000 Subject: [PATCH] fix the close price --- src/components/close-trade.tsx | 8 ++++++-- src/lib/useTrades.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/close-trade.tsx b/src/components/close-trade.tsx index e3e5559..2bb7406 100644 --- a/src/components/close-trade.tsx +++ b/src/components/close-trade.tsx @@ -25,8 +25,12 @@ const SubComp = (props: { t: Trade }) => { const [contractPriceAtClose] = useWatch({ name: ['contractPriceAtClose'], }); + + const [transactionEndDate] = useWatch({ + name: ['transactionEndDate'], + }); - const t1 = mapTradeToView({ ...props.t, lastContractPrice: contractPriceAtClose }); + const t1 = mapTradeToView({ ...props.t, contractPriceAtClose, transactionEndDate }); return ( <> @@ -113,7 +117,7 @@ export const CloseTradeDialog = (props: ITickerProps) => { */} - + $ }} /> diff --git a/src/lib/useTrades.ts b/src/lib/useTrades.ts index de092d8..d676d05 100644 --- a/src/lib/useTrades.ts +++ b/src/lib/useTrades.ts @@ -7,7 +7,7 @@ import { ITradeView } from "./types"; const SellContracts = ['PUT_SELL', 'CALL_SELL']; -export const mapTradeToView = (trade: Trade): ITradeView => { +export const mapTradeToView = (trade: Trade): ITradeView => { const isSellContract = SellContracts.includes(trade.contractType); const sellCost = isSellContract ? (Number(trade.contractPrice) * 100 * trade.numberOfContracts) : 0; const buyCost = (isSellContract && trade.contractPriceAtClose) ? (Number(trade.contractPriceAtClose) * 100 * trade.numberOfContracts) : NaN;