From b8ff408186af13b497b899ab6468f13730746393 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 26 Feb 2025 19:42:25 +0800 Subject: [PATCH] swap tpsl if sell order --- src/routes/webhook/tradingview/+server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/webhook/tradingview/+server.ts b/src/routes/webhook/tradingview/+server.ts index 832ef83..74eca77 100644 --- a/src/routes/webhook/tradingview/+server.ts +++ b/src/routes/webhook/tradingview/+server.ts @@ -4,7 +4,6 @@ import { z } from 'zod' export const POST = async ({ locals, request }) => { const type = request.headers.get('Content-Type') - console.log('Type:', type) if (type !== 'application/json; charset=utf-8') { return new Response() } @@ -35,6 +34,7 @@ export const POST = async ({ locals, request }) => { leverage: z.string().default('1'), takeProfitPercent: z.string().optional(), stopLossPercent: z.string().optional(), + // tpslDecimalPoint: z.string().default('1'), }) const closePositionSchema = z.object({ type: z.literal('Close Position'), @@ -144,8 +144,8 @@ export const POST = async ({ locals, request }) => { side, orderType: 'Market', qty, - takeProfit, - stopLoss, + takeProfit: side === 'Buy' ? takeProfit : stopLoss, + stopLoss: side === 'Sell' ? stopLoss : takeProfit, isLeverage: isLeverage ? 1 : 0, }) return new Response()