Add execution plan for sell decisions: amount, risk management, take-profit; include execution step in TradingGraph workflow
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -4,11 +4,11 @@ import { TechnicalAnalyst } from "./technical";
|
||||
import { SentimentAnalyst } from "./sentiment";
|
||||
import { BullishResearcher, BearishResearcher } from "./researchers";
|
||||
import { Trader } from "./trader";
|
||||
import type { AnalystReport, DebateRound, TradingDecision, AgentSignal } from "../types/agents";
|
||||
import type { AnalystReport, DebateRound, TradingDecision, AgentSignal, ExecutionPlan } from "../types/agents";
|
||||
|
||||
export interface GraphStep {
|
||||
step: "analysts" | "debate" | "trader";
|
||||
data: AnalystReport[] | DebateRound[] | TradingDecision;
|
||||
step: "analysts" | "debate" | "trader" | "execution";
|
||||
data: AnalystReport[] | DebateRound[] | TradingDecision | ExecutionPlan;
|
||||
}
|
||||
|
||||
export class TradingGraph {
|
||||
@@ -50,6 +50,21 @@ export class TradingGraph {
|
||||
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[] = [
|
||||
{ step: "analysts", data: reports },
|
||||
{ step: "debate", data: debates },
|
||||
{ step: "trader", data: decision },
|
||||
];
|
||||
|
||||
if (decision.action === 'sell' && 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user