Files
AITrader/app/agents/__tests__/tradingGraph.test.ts
T

32 lines
960 B
TypeScript

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");
});
});