From 1446ec92abeedf1d184793f4d2a4ed2827d21415 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Tue, 11 Feb 2025 22:03:07 +0800 Subject: [PATCH] update calculation --- src/routes/webhook/tradingview/+server.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/routes/webhook/tradingview/+server.ts b/src/routes/webhook/tradingview/+server.ts index a646dc3..41342d4 100644 --- a/src/routes/webhook/tradingview/+server.ts +++ b/src/routes/webhook/tradingview/+server.ts @@ -73,10 +73,10 @@ export const POST = async ({ locals, request }) => { ) qty = ( - Number(form.data.entryPrice) / - ((Number(wallet.result.list[0].totalAvailableBalance) * + (Number(form.data.entryPrice) * Number(form.data.qtyPercent)) / - 100) + 100 / + Number(wallet.result.list[0].totalAvailableBalance) ).toString() takeProfit = ( Number(form.data.entryPrice) * @@ -85,7 +85,7 @@ export const POST = async ({ locals, request }) => { stopLoss = ( Number(form.data.entryPrice) * (1 - Number(form.data.stopLossPercent) / 100) - ).toString(2) + ).toString() } console.log({ qty, takeProfit, stopLoss }) @@ -99,8 +99,6 @@ export const POST = async ({ locals, request }) => { takeProfit, stopLoss, }) - - console.log(order.result.orderId) } catch (error) { console.log('Error', error) } finally {