fix: update test endpoint to use symbol-specific position sizing
This commit is contained in:
@@ -53,6 +53,14 @@ export async function POST(request: NextRequest): Promise<NextResponse<TestTrade
|
|||||||
// Get trading configuration
|
// Get trading configuration
|
||||||
const config = getMergedConfig()
|
const config = getMergedConfig()
|
||||||
|
|
||||||
|
// Get symbol-specific position sizing
|
||||||
|
const { getPositionSizeForSymbol } = await import('@/config/trading')
|
||||||
|
const { size: positionSize, leverage } = getPositionSizeForSymbol(driftSymbol, config)
|
||||||
|
|
||||||
|
console.log(`📐 Symbol-specific sizing for ${driftSymbol}:`)
|
||||||
|
console.log(` Position size: $${positionSize}`)
|
||||||
|
console.log(` Leverage: ${leverage}x`)
|
||||||
|
|
||||||
// Initialize Drift service if not already initialized
|
// Initialize Drift service if not already initialized
|
||||||
const driftService = await initializeDriftService()
|
const driftService = await initializeDriftService()
|
||||||
|
|
||||||
@@ -72,12 +80,12 @@ export async function POST(request: NextRequest): Promise<NextResponse<TestTrade
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate position size with leverage
|
// Calculate position size with leverage
|
||||||
const positionSizeUSD = config.positionSize * config.leverage
|
const positionSizeUSD = positionSize * leverage
|
||||||
|
|
||||||
console.log(`💰 Opening ${direction} position:`)
|
console.log(`💰 Opening ${direction} position:`)
|
||||||
console.log(` Symbol: ${driftSymbol}`)
|
console.log(` Symbol: ${driftSymbol}`)
|
||||||
console.log(` Base size: $${config.positionSize}`)
|
console.log(` Base size: $${positionSize}`)
|
||||||
console.log(` Leverage: ${config.leverage}x`)
|
console.log(` Leverage: ${leverage}x`)
|
||||||
console.log(` Total position: $${positionSizeUSD}`)
|
console.log(` Total position: $${positionSizeUSD}`)
|
||||||
|
|
||||||
// Open position
|
// Open position
|
||||||
@@ -162,7 +170,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<TestTrade
|
|||||||
entryPrice,
|
entryPrice,
|
||||||
entryTime: Date.now(),
|
entryTime: Date.now(),
|
||||||
positionSize: positionSizeUSD,
|
positionSize: positionSizeUSD,
|
||||||
leverage: config.leverage,
|
leverage: leverage,
|
||||||
stopLossPrice,
|
stopLossPrice,
|
||||||
tp1Price,
|
tp1Price,
|
||||||
tp2Price,
|
tp2Price,
|
||||||
@@ -248,7 +256,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<TestTrade
|
|||||||
direction: direction,
|
direction: direction,
|
||||||
entryPrice,
|
entryPrice,
|
||||||
positionSizeUSD: positionSizeUSD,
|
positionSizeUSD: positionSizeUSD,
|
||||||
leverage: config.leverage,
|
leverage: leverage,
|
||||||
stopLossPrice,
|
stopLossPrice,
|
||||||
takeProfit1Price: tp1Price,
|
takeProfit1Price: tp1Price,
|
||||||
takeProfit2Price: tp2Price,
|
takeProfit2Price: tp2Price,
|
||||||
|
|||||||
Reference in New Issue
Block a user