Use resolved active contracts for orders
This commit is contained in:
@@ -28,12 +28,12 @@ export async function POST(
|
||||
const client = clients.get(firmId);
|
||||
if (!client) return NextResponse.json({ error: 'Client not found for firm' }, { status: 404 });
|
||||
|
||||
// 1. Find the front-month contract
|
||||
// 1. Find the active contract chosen by the shared resolver
|
||||
const contract = await client.findFrontMonthContract(symbol);
|
||||
if (!contract) {
|
||||
return NextResponse.json({ error: `Could not find active front-month contract for ${symbol}` }, { status: 404 });
|
||||
return NextResponse.json({ error: `Could not find an active contract for ${symbol}` }, { status: 404 });
|
||||
}
|
||||
console.log(`[order] front-month: ${contract.name} (id=${contract.id})`);
|
||||
console.log(`[order] active contract: ${contract.name} (id=${contract.id})`);
|
||||
|
||||
// 2. Place the order — resolves with the fill event (includes commission/fees)
|
||||
const fill = await client.sendOrder(accountId, contract.name, qty, action, orderType, price);
|
||||
|
||||
Reference in New Issue
Block a user