feat: add technical analyst agent

This commit is contained in:
2026-05-14 07:55:42 +02:00
parent 55d6ba4fee
commit 3536193746
2 changed files with 133 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { describe, it, expect } from "vitest";
import { TechnicalAnalyst } from "../technical";
import type { OpenRouterClient } from "../../lib/openrouter";
describe("TechnicalAnalyst", () => {
it("should analyze technical indicators", async () => {
const mockClient = {
createChatCompletion: async () => ({
choices: [
{
message: {
content:
'{"signal":"bullish","confidence":0.85,"reasoning":"Strong technical setup"}',
},
},
],
}),
} as unknown as OpenRouterClient;
const analyst = new TechnicalAnalyst(mockClient);
const result = await analyst.analyze("AAPL", {
prices: [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],
sma: 105,
ema: 106,
rsi: 65,
macd: 2.5,
});
expect(result.analyst).toBe("technical");
expect(result.signal.signal).toBe("bullish");
});
it("should use specified model", () => {
const mockClient = {} as unknown as OpenRouterClient;
const analyst = new TechnicalAnalyst(mockClient, {
model: "custom/model",
});
expect(analyst.getModel()).toBe("custom/model");
});
});