34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
/* TRADINGGRAPH related file */
|
|
|
|
import { describe, it, expect, vi } from "vitest";
|
|
import { TradingGraph } from "../tradingGraph";
|
|
|
|
describe("TradingGraph execution step", () => {
|
|
it("returns executionPlan when model provides it", async () => {
|
|
const mockClient = {
|
|
createChatCompletion: vi.fn().mockResolvedValue({
|
|
choices: [{ message: { content: JSON.stringify({
|
|
action: "sell",
|
|
confidence: 0.85,
|
|
reasoning: "Test sell",
|
|
executionPlan: { amount: 100, riskManagement: { maxLossPercent: 2 }, takeProfit: 200 }
|
|
}) } }]
|
|
}),
|
|
};
|
|
|
|
const mockInput = {
|
|
financialData: "...",
|
|
technicalData: { prices: [1,2,3], sma: 1, ema: 1, rsi: 50, macd: 0 },
|
|
sentimentData: { headlines: ["h"], source: "news" },
|
|
};
|
|
|
|
const graph = new TradingGraph(mockClient as any);
|
|
const decision = await graph.propagate("AAPL", mockInput as any);
|
|
|
|
expect(decision.action).toBe("sell");
|
|
expect(decision.executionPlan).toBeDefined();
|
|
expect(decision.executionPlan?.amount).toBe(100);
|
|
});
|
|
});
|
|
|