From f85c231be239982dcf49fd7f519e7d788fcec445 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Tue, 11 Feb 2025 21:59:10 +0800 Subject: [PATCH] update calculation --- src/routes/webhook/tradingview/+server.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/routes/webhook/tradingview/+server.ts b/src/routes/webhook/tradingview/+server.ts index 664a3dc..a646dc3 100644 --- a/src/routes/webhook/tradingview/+server.ts +++ b/src/routes/webhook/tradingview/+server.ts @@ -73,18 +73,19 @@ export const POST = async ({ locals, request }) => { ) qty = ( - (Number(wallet.result.list[0].totalAvailableBalance) * + Number(form.data.entryPrice) / + ((Number(wallet.result.list[0].totalAvailableBalance) * Number(form.data.qtyPercent)) / - 100 - ).toFixed(2) + 100) + ).toString() takeProfit = ( Number(form.data.entryPrice) * (1 + Number(form.data.takeProfitPercent) / 100) - ).toFixed(2) + ).toString() stopLoss = ( Number(form.data.entryPrice) * (1 - Number(form.data.stopLossPercent) / 100) - ).toFixed(2) + ).toString(2) } console.log({ qty, takeProfit, stopLoss })