feat(settings): add settings route and API updates\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This commit is contained in:
2026-05-16 20:19:35 +02:00
parent 9b63d981b0
commit 0ee89cf052
38 changed files with 1426 additions and 562 deletions
+13 -15
View File
@@ -1,3 +1,5 @@
/* TRADINGGRAPH related file */
import { OpenRouterClient } from "../lib/openrouter";
import { FundamentalsAnalyst } from "./fundamentals";
import { TechnicalAnalyst } from "./technical";
@@ -41,14 +43,14 @@ export class TradingGraph {
sentimentData: { headlines: string[]; source?: "news" | "social" | "stocktwits" };
}
): Promise<TradingDecision> {
console.log(`[TradingGraph] Starting analysis for ${ticker} with model ${this.model}`);
const reports = await this.runAnalysts(ticker, input);
const debates = await this.runDebate(ticker, reports);
const decision = await this.trader.decide(ticker, reports, debates);
console.log(`[TradingGraph] Analysis complete for ${ticker}`);
console.log(`[TradingGraph] Decision: ${decision.action} (confidence: ${decision.confidence})`);
// Build workflow steps for observability. Include an execution step when selling.
const steps: GraphStep[] = [
@@ -57,13 +59,13 @@ export class TradingGraph {
{ step: "trader", data: decision },
];
if (decision.action === 'sell' && decision.executionPlan) {
if (decision.executionPlan) {
steps.push({ step: "execution", data: decision.executionPlan });
console.log(`[TradingGraph] Execution plan: ${JSON.stringify(decision.executionPlan)}`);
}
// Log steps for debugging; external systems can be extended to consume GraphStep sequence.
console.log(`[TradingGraph] Workflow steps: ${JSON.stringify(steps)}`);
return decision;
}
@@ -76,7 +78,7 @@ export class TradingGraph {
sentimentData: { headlines: string[]; source?: "news" | "social" | "stocktwits" };
}
): Promise<AnalystReport[]> {
console.log(`[TradingGraph] Running analysts for ${ticker}...`);
const [fundamentals, technical, sentiment] = await Promise.all([
this.fundamentalsAnalyst.analyze(ticker, input.financialData),
@@ -84,24 +86,20 @@ export class TradingGraph {
this.sentimentAnalyst.analyze(ticker, input.sentimentData),
]);
console.log(`[TradingGraph] Analyst reports complete:`, {
fundamentals: fundamentals.signal,
technical: technical.signal,
sentiment: sentiment.signal,
});
return [fundamentals, technical, sentiment];
}
private async runDebate(ticker: string, reports: AnalystReport[]): Promise<DebateRound[]> {
console.log(`[TradingGraph] Running debate for ${ticker}...`);
const [bullish, bearish] = await Promise.all([
this.bullishResearcher.research(ticker, reports),
this.bearishResearcher.research(ticker, reports),
]);
console.log(`[TradingGraph] Debate complete`);
return [
{
@@ -111,4 +109,4 @@ export class TradingGraph {
},
];
}
}
}