/** * Type definitions for SKAI Training Hub API * * Training Hub provides AI-powered trading signal generation, model training, * and automated trading execution across multiple brokers. */ export interface TradingConfig { capital_allocation_pct?: number; buy_allocation?: number; sell_allocation?: number; min_confidence?: number; max_position_size?: number; take_profit_pct?: number; stop_loss_pct?: number; } export interface BrokerCredentials { api_key?: string; api_secret?: string; paper?: boolean; [key: string]: unknown; } export interface TrainingRequest { broker_name?: string; credentials?: BrokerCredentials; trading_config?: TradingConfig; } export interface SignalsRequest { broker_name: string; credentials: BrokerCredentials; trading_config?: TradingConfig; } export interface CompleteTradingRequest { broker_name: string; credentials: BrokerCredentials; trading_config?: TradingConfig; ticker_universe?: string[]; min_trade_value?: number; paper_trading?: boolean; training_window_days?: number; model_type?: string; current_positions?: unknown; } export interface AccountRequest { broker_name: string; credentials: BrokerCredentials; } export interface OrdersRequest extends AccountRequest { after?: Date; limit?: number; status?: string; } export interface EquityHistoryRequest extends AccountRequest { period?: string; timeframe?: string; } export interface PlaceOrderRequest { side: string; ticker: string; quantity: number; order_type?: string; price?: number; stop_price?: number; time_in_force?: string; } export interface RebalanceRequest extends AccountRequest { trim_fraction?: number; min_trade_value?: number; } export interface FollowSignalsRequest { source_user_id: string; broker_name: string; credentials: BrokerCredentials; } export interface TrainingJobStartResponse { job_id: string; message: string; } export interface TrainingJobStatusResponse { job_id: string; status: string; error?: string; } export interface TradingSignal { ticker: string; action: 'buy' | 'sell' | 'hold'; confidence: number; current_price: number; recommended_quantity: string; reasoning: string; } export interface SignalsResponse { signals: TradingSignal[]; timestamp: string; model_version: string; universe_size: number; } export interface CachedSignal { id: string; ticker: string; action: string; confidence: number; current_price: number; recommended_quantity: string; reasoning: string; timestamp: string; } export interface TradeExecution { ticker: string; action: string; shares: number; price: number; value: number; success: boolean; reason: string; timestamp: string; } export interface CompleteTradingResponse { broker: string; workflow_summary: { signals_generated: number; orders_attempted: number; orders_successful: number; total_trade_volume: number; success_rate: number; }; signals_generated: TradingSignal[]; trades_executed: TradeExecution[]; timestamp: string; } export interface AsyncJobResponse { job_id: string; message: string; } export interface JobStatusResponse { job_id: string; status: string; result?: unknown; error?: string; } export interface Position { symbol: string; quantity: string; market_value: string; avg_entry_price: string; unrealized_pl: string; unrealized_plpc: string; } export interface AccountSnapshot { broker: string; account: { cash: number; equity: number; buying_power: number; day_trade_buying_power: number; currency: string; }; positions: Position[]; positions_count: number; timestamp: string; } export interface BrokerOrder { id: string; symbol: string; quantity: number; side: 'buy' | 'sell'; status: string; order_type: string; submitted_at: string; } export interface OrderResponse { status: string; order_id: string; side: string; ticker: string; quantity: number; order_type: string; price?: number; time_in_force: string; timestamp: string; reason?: string; broker_details?: unknown; } export interface RebalanceExecution { ticker: string; action: string; quantity: string; value: number; reason: string; } export interface RebalanceResponse { rebalance_summary: { positions_reviewed: number; positions_over_limit: number; trades_executed: number; total_trim_value: number; }; trades_executed: RebalanceExecution[]; timestamp: string; } export interface SignalExecution { ticker: string; action: string; confidence: number; executed: boolean; order_id?: string; reason: string; timestamp: string; } export interface FollowSignalsResponse { source_user_id: string; follower_user_id: string; broker: string; execution_summary: { signals_available: number; signals_executed: number; orders_successful: number; orders_failed: number; success_rate: number; total_trade_volume: number; }; signals_processed: SignalExecution[]; timestamp: string; }