// Get all orders for the account
const orders = await client.accounts.getOrders('acc_123456');
console.log(`Total orders: ${orders.length}\n`);
// Group by status
const ordersByStatus = orders.reduce((acc, order) => {
acc[order.status] = acc[order.status] || [];
acc[order.status].push(order);
return acc;
}, {});
Object.entries(ordersByStatus).forEach(([status, orderList]) => {
console.log(`${status.toUpperCase()}: ${orderList.length} orders`);
});
// Show recent filled orders
const filledOrders = orders
.filter(o => o.status === 'filled')
.sort((a, b) => new Date(b.filledAt) - new Date(a.filledAt))
.slice(0, 5);
console.log('\nRecent Fills:');
filledOrders.forEach(order => {
console.log(`${order.symbol} - ${order.side.toUpperCase()} ${order.quantity} @ $${order.averageFillPrice.toFixed(2)}`);
});