/** * Trading view/formatter helpers. * * Anything that turns engine state into human/agent-readable markdown * belongs here. Split out of `trading-execute.ts` so the tool handlers in * `trading-router.ts` stay focused on request handling and the engine * stays free of presentation concerns. This mirrors the view/controller * separation OpenBB enforces between `standard_models` (data) and the * router-side rendering that happens in their MCP layer. */ import type { Position } from '../trading/portfolio.js'; import type { Portfolio } from '../trading/portfolio.js'; import type { RiskConfig } from '../trading/risk.js'; import type { BlockKind } from '../trading/engine.js'; import type { TradeLogEntry } from '../trading/trade-log.js'; export declare function formatUsd(n: number): string; export declare function formatPct(n: number): string; export declare function formatPositionLine(p: Position & { markUsd: number; unrealizedPnlUsd: number; }): string; export declare function formatTradeLine(entry: TradeLogEntry): string; /** Parse a window string ("24h", "7d", "all") into a lower-bound timestamp. */ export declare function windowToSince(window: string, now: number): number; export interface PortfolioSnapshot { cashUsd: number; equityUsd: number; unrealizedPnlUsd: number; realizedPnlUsd: number; positions: (Position & { markUsd: number; unrealizedPnlUsd: number; })[]; } export declare function renderPortfolio(snap: PortfolioSnapshot, riskConfig?: RiskConfig): string; export declare function renderOrderFilled(params: { symbol: string; fill: { qty: number; priceUsd: number; feeUsd: number; }; portfolio: Portfolio; warnings?: string[]; }): string; /** * Advice the model gets after a block depends on WHY it was blocked. * "Try a smaller qty" is right for a risk refusal and actively wrong for a * fee-quote outage (it makes the agent shrink and retry, generating repeated * — and for a real adapter, billed — quote calls). */ export declare function blockAdvice(kind: BlockKind | undefined): string; export declare function renderOrderBlocked(params: { symbol: string; qty: number; priceUsd: number; reason: string; kind?: BlockKind; }): string; export declare function renderCloseBlocked(params: { symbol: string; qty?: number; reason: string; kind?: BlockKind; }): string; /** * Post-execution warnings are rendered ABOVE the fill details so the model * cannot miss them: the trade is booked, but the venue did not deliver what * the risk check approved. */ export declare function renderWarnings(warnings: string[] | undefined): string; export declare function renderPositionClosed(params: { symbol: string; fill: { qty: number; priceUsd: number; feeUsd: number; }; tradeRealized: number; portfolio: Portfolio; warnings?: string[]; }): string; export declare function renderTradeHistory(params: { windowRaw: string; entries: TradeLogEntry[]; realized: number; }): string;