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({