Use resolved active contracts for orders

This commit is contained in:
Brandon Li
2026-03-18 00:52:25 -05:00
parent f498594b16
commit 131c9bca9f
2 changed files with 13 additions and 7 deletions
+3 -3
View File
@@ -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);