feat: wire TradingGraph to use settings for model, temperature, and risk config

This commit is contained in:
2026-05-16 21:37:27 +02:00
parent ae45071973
commit 2ab55060f3
5 changed files with 50 additions and 16 deletions
+4 -5
View File
@@ -17,8 +17,7 @@ export async function action({ request }: { request: Request }) {
}
// Load server-only modules dynamically to prevent them from being included in client bundles
const { OpenRouterClient } = await import("../../lib/openrouter");
const { TradingGraph } = await import("../../agents/tradingGraph");
const { buildTradingGraph } = await import("../../lib/tradingConfig.server");
const { db } = await import("../../lib/db.server");
const { fetchAccount, fetchRecentCloses, fetchBars } = await import("../../lib/alpacaClient");
@@ -59,8 +58,8 @@ export async function action({ request }: { request: Request }) {
return Response.json(mockDecision);
}
const client = new OpenRouterClient(apiKey);
const graph = new TradingGraph(client);
const { graph, config } = await buildTradingGraph(apiKey);
console.log("[analyze] Trading config:", config);
// Fetch latest Alpaca account and recent prices; abort if unavailable
let account: any = undefined;
@@ -124,7 +123,7 @@ export async function action({ request }: { request: Request }) {
// Optionally ask LLM to verify/adjust the computed plan if API key is present
if (process.env.OPENROUTER_API_KEY) {
try {
decision = await verifyExecutionPlanWithLLM(decision, input);
decision = await verifyExecutionPlanWithLLM(decision, input, config.model);
} catch (e) {
console.warn("LLM verification failed:", e);
}