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:
@@ -0,0 +1,30 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { TradingGraph } from "../tradingGraph";
|
||||
|
||||
describe("TradingGraph execution step", () => {
|
||||
it("returns executionPlan when model provides it", async () => {
|
||||
const mockClient = {
|
||||
createChatCompletion: vi.fn().mockResolvedValue({
|
||||
choices: [{ message: { content: JSON.stringify({
|
||||
action: "sell",
|
||||
confidence: 0.85,
|
||||
reasoning: "Test sell",
|
||||
executionPlan: { amount: 100, riskManagement: { maxLossPercent: 2 }, takeProfit: 200 }
|
||||
}) } }]
|
||||
}),
|
||||
};
|
||||
|
||||
const mockInput = {
|
||||
financialData: "...",
|
||||
technicalData: { prices: [1,2,3], sma: 1, ema: 1, rsi: 50, macd: 0 },
|
||||
sentimentData: { headlines: ["h"], source: "news" },
|
||||
};
|
||||
|
||||
const graph = new TradingGraph(mockClient as any);
|
||||
const decision = await graph.propagate("AAPL", mockInput as any);
|
||||
|
||||
expect(decision.action).toBe("sell");
|
||||
expect(decision.executionPlan).toBeDefined();
|
||||
expect(decision.executionPlan?.amount).toBe(100);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user