feat: add trading graph orchestrator

This commit is contained in:
2026-05-14 08:04:14 +02:00
parent 86fe670ca0
commit 0930e11495
2 changed files with 108 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { describe, it, expect, vi } from "vitest";
import { TradingGraph } from "../tradingGraph";
describe("TradingGraph", () => {
const mockClient = {
createChatCompletion: vi.fn().mockResolvedValue({
choices: [{ message: { content: '{"signal":"bullish","confidence":0.8,"reasoning":"Test"}' } }],
}),
};
const mockInput = {
financialData: "Revenue: 1B, Growth: 10%, Debt: low",
technicalData: {
prices: [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],
sma: 105,
ema: 106,
rsi: 65,
macd: 2.5,
},
sentimentData: {
headlines: ["Company beats earnings expectations"],
source: "news" as const,
},
};
it("should run full analysis", async () => {
const graph = new TradingGraph(mockClient as any);
const decision = await graph.propagate("AAPL", mockInput);
expect(decision).toHaveProperty("action");
expect(decision).toHaveProperty("confidence");
});
});