mirror of
https://github.com/saymrwulf/alpha-arena.git
synced 2026-07-23 19:12:17 +00:00
A comprehensive autonomous trading system for Polymarket prediction markets featuring multi-LLM provider support, a native macOS menu bar app, and a web-based control dashboard. Key features: - Multi-agent trading system (Research, Risk, Execution, Reflection agents) - LLM provider flexibility (Anthropic, OpenAI, Google, xAI, Local models) - Automatic provider fallback chain for resilience - Native Swift/SwiftUI macOS menu bar application - FastAPI web dashboard with real-time WebSocket updates - Risk management with kill switch - Technical indicators and market analysis
90 lines
2 KiB
Swift
90 lines
2 KiB
Swift
import Foundation
|
|
|
|
/// Trading mode
|
|
enum TradingMode: String, Codable {
|
|
case simulation
|
|
case live
|
|
}
|
|
|
|
/// Trading state
|
|
enum TradingState: String, Codable {
|
|
case active
|
|
case stopped
|
|
case paused
|
|
}
|
|
|
|
/// Response from /api/trading/status
|
|
struct TradingStatusResponse: Codable {
|
|
let isActive: Bool
|
|
let mode: String?
|
|
let totalPnL: Double?
|
|
let dailyPnL: Double?
|
|
let openPositions: Int?
|
|
let lastCycleTime: String?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case isActive = "is_active"
|
|
case mode
|
|
case totalPnL = "total_pnl"
|
|
case dailyPnL = "daily_pnl"
|
|
case openPositions = "open_positions"
|
|
case lastCycleTime = "last_cycle_time"
|
|
}
|
|
}
|
|
|
|
/// Trading status for display
|
|
struct TradingStatus: Equatable {
|
|
var isActive: Bool = false
|
|
var mode: TradingMode = .simulation
|
|
var totalPnL: Double = 0.0
|
|
var dailyPnL: Double = 0.0
|
|
var openPositions: Int = 0
|
|
var lastUpdate: Date?
|
|
|
|
var pnlFormatted: String {
|
|
let sign = totalPnL >= 0 ? "+" : ""
|
|
return String(format: "%@$%.2f", sign, totalPnL)
|
|
}
|
|
|
|
var dailyPnLFormatted: String {
|
|
let sign = dailyPnL >= 0 ? "+" : ""
|
|
return String(format: "%@$%.2f", sign, dailyPnL)
|
|
}
|
|
|
|
var statusText: String {
|
|
isActive ? "Trading Active" : "Trading Stopped"
|
|
}
|
|
}
|
|
|
|
/// WebSocket message types
|
|
enum WebSocketMessageType: String, Codable {
|
|
case `init`
|
|
case tradingStarted = "trading_started"
|
|
case tradingStopped = "trading_stopped"
|
|
case killSwitch = "kill_switch"
|
|
case cycleComplete = "cycle_complete"
|
|
case positionUpdate = "position_update"
|
|
case error
|
|
}
|
|
|
|
/// WebSocket message structure
|
|
struct WebSocketMessage: Codable {
|
|
let type: String
|
|
let data: WebSocketData?
|
|
}
|
|
|
|
struct WebSocketData: Codable {
|
|
let pnl: Double?
|
|
let positions: Int?
|
|
let mode: String?
|
|
let reason: String?
|
|
let message: String?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case pnl
|
|
case positions
|
|
case mode
|
|
case reason
|
|
case message
|
|
}
|
|
}
|