Display executionPlan in UI; add tests for Trader executionPlan parsing and TradingGraph execution step
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -36,4 +36,32 @@ describe("Trader", () => {
|
||||
const decision = await trader.decide("AAPL", mockReports, mockDebates);
|
||||
expect(decision.action).toBe("buy");
|
||||
});
|
||||
|
||||
it("parses executionPlan on sell", async () => {
|
||||
const mockSellClient = {
|
||||
createChatCompletion: vi.fn().mockResolvedValue({
|
||||
choices: [{ message: { content: JSON.stringify({
|
||||
action: "sell",
|
||||
confidence: 0.9,
|
||||
reasoning: "Exit position",
|
||||
executionPlan: {
|
||||
amount: 50,
|
||||
riskManagement: { maxLossPercent: 1.5, method: "trailing" },
|
||||
takeProfit: 150,
|
||||
note: "Test plan"
|
||||
}
|
||||
}) } }]
|
||||
}),
|
||||
};
|
||||
|
||||
const trader = new Trader(mockSellClient as any);
|
||||
const decision = await trader.decide("AAPL", mockReports, mockDebates);
|
||||
|
||||
expect(decision.action).toBe("sell");
|
||||
expect(decision.executionPlan).toBeDefined();
|
||||
expect(decision.executionPlan?.amount).toBe(50);
|
||||
expect(decision.executionPlan?.takeProfit).toBe(150);
|
||||
expect(decision.executionPlan?.riskManagement?.maxLossPercent).toBe(1.5);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user