feat: add trader agent

This commit is contained in:
2026-05-14 08:01:59 +02:00
parent e913b32f34
commit 86fe670ca0
2 changed files with 123 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { describe, it, expect, vi } from "vitest";
import { Trader } from "../trader";
import type { AnalystReport, DebateRound } from "../../types/agents";
describe("Trader", () => {
const mockClient = {
createChatCompletion: vi.fn().mockResolvedValue({
choices: [{ message: { content: '{"action": "buy", "confidence": 0.75, "reasoning": "Strong bullish signals"}' } }],
}),
};
const mockReports: AnalystReport[] = [
{
analyst: "fundamentals",
report: "Strong earnings growth",
signal: {
agent: "fundamentals",
signal: "bullish",
confidence: 0.8,
reasoning: "Revenue up 20%",
timestamp: "2024-01-01",
},
},
];
const mockDebates: DebateRound[] = [
{
bullishView: "Strong fundamentals",
bearishView: "Market volatility",
researcher: "bullish",
},
];
it("should make trading decision", async () => {
const trader = new Trader(mockClient as any);
const decision = await trader.decide("AAPL", mockReports, mockDebates);
expect(decision.action).toBe("buy");
});
});