swap tpsl if sell order

master
TZGyn 9 months ago
parent c0e9eb7521
commit b8ff408186
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -4,7 +4,6 @@ import { z } from 'zod'
export const POST = async ({ locals, request }) => { export const POST = async ({ locals, request }) => {
const type = request.headers.get('Content-Type') const type = request.headers.get('Content-Type')
console.log('Type:', type)
if (type !== 'application/json; charset=utf-8') { if (type !== 'application/json; charset=utf-8') {
return new Response() return new Response()
} }
@ -35,6 +34,7 @@ export const POST = async ({ locals, request }) => {
leverage: z.string().default('1'), leverage: z.string().default('1'),
takeProfitPercent: z.string().optional(), takeProfitPercent: z.string().optional(),
stopLossPercent: z.string().optional(), stopLossPercent: z.string().optional(),
// tpslDecimalPoint: z.string().default('1'),
}) })
const closePositionSchema = z.object({ const closePositionSchema = z.object({
type: z.literal('Close Position'), type: z.literal('Close Position'),
@ -144,8 +144,8 @@ export const POST = async ({ locals, request }) => {
side, side,
orderType: 'Market', orderType: 'Market',
qty, qty,
takeProfit, takeProfit: side === 'Buy' ? takeProfit : stopLoss,
stopLoss, stopLoss: side === 'Sell' ? stopLoss : takeProfit,
isLeverage: isLeverage ? 1 : 0, isLeverage: isLeverage ? 1 : 0,
}) })
return new Response() return new Response()

Loading…
Cancel
Save