From 7afff761df507fe9881837bb75f95a6dba210d9c Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 26 Feb 2025 19:56:49 +0800 Subject: [PATCH] update tpsl price decimals to follow entry point --- src/routes/webhook/tradingview/+server.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/webhook/tradingview/+server.ts b/src/routes/webhook/tradingview/+server.ts index 192404f..9829393 100644 --- a/src/routes/webhook/tradingview/+server.ts +++ b/src/routes/webhook/tradingview/+server.ts @@ -102,7 +102,8 @@ export const POST = async ({ locals, request }) => { const [price, decimals] = form.data.entryPrice.split('.') console.log('Decimals', decimals) - console.log('Decimals Length', decimals.length) + console.log('Decimals Length', decimals?.length || 0) + const decimalLength = decimals?.length || 0 qty = ( (Number(wallet.result.list[0].totalAvailableBalance) * @@ -113,11 +114,11 @@ export const POST = async ({ locals, request }) => { takeProfit = ( Number(form.data.entryPrice) * (1 + Number(form.data.takeProfitPercent) / 100) - ).toFixed(1) + ).toFixed(decimalLength) stopLoss = ( Number(form.data.entryPrice) * (1 - Number(form.data.stopLossPercent) / 100) - ).toFixed(1) + ).toFixed(decimalLength) side = form.data.side } else { const position = await client.getPositionInfo({