Skip to content

Commit dc2095c

Browse files
authored
Merge pull request #12 from code-rabi/fix-get-live-orders-accountid
fix: remove accountId parameter from get_live_orders tool
2 parents 4d0852b + 007a852 commit dc2095c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/tool-definitions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ export const GetOrderStatusZodShape = {
4141
orderId: z.string()
4242
};
4343

44-
export const GetLiveOrdersZodShape = {
45-
accountId: z.string().optional()
46-
};
44+
export const GetLiveOrdersZodShape = {};
4745

4846
export const ConfirmOrderZodShape = {
4947
replyId: z.string(),

src/tool-handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ export class ToolHandlers {
455455
await this.ensureAuth();
456456
}
457457

458-
const result = await this.context.ibClient.getOrders(input.accountId);
458+
// Always fetch all orders (don't pass accountId as it causes API errors)
459+
const result = await this.context.ibClient.getOrders();
459460
return {
460461
content: [
461462
{

src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function registerTools(
8686
// Register get_live_orders tool
8787
server.tool(
8888
"get_live_orders",
89-
"Get all live/open orders for monitoring and validation. Usage: `{}` to get all orders or `{ \"accountId\": \"<id>\" }` for a specific account. " +
89+
"Get all live/open orders for monitoring and validation. Usage: `{}`. " +
9090
"This is the recommended way to validate that market orders were executed successfully after placing them.",
9191
GetLiveOrdersZodShape,
9292
async (args) => await handlers.getLiveOrders(args)

test/tool-handlers.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,17 @@ describe('ToolHandlers', () => {
192192
const result = await handlers.getLiveOrders({});
193193

194194
expect(result.content).toBeDefined();
195-
expect(mockIBClient.getOrders).toHaveBeenCalledWith(undefined);
195+
expect(mockIBClient.getOrders).toHaveBeenCalledWith();
196196
});
197197

198-
it('should return orders for specific account', async () => {
198+
it('should always fetch all orders without account parameter', async () => {
199199
const mockOrders = [{ orderId: '123', status: 'Working' }];
200200
mockIBClient.getOrders = vi.fn().mockResolvedValue(mockOrders);
201201

202-
const result = await handlers.getLiveOrders({ accountId: 'U12345' });
202+
const result = await handlers.getLiveOrders({});
203203

204-
expect(mockIBClient.getOrders).toHaveBeenCalledWith('U12345');
204+
expect(mockIBClient.getOrders).toHaveBeenCalledWith();
205+
expect(result.content).toBeDefined();
205206
});
206207
});
207208

0 commit comments

Comments
 (0)