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

41 lines
1.2 KiB
TypeScript

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