openapi: 3.1.0 info: title: Api version: 0.1.0 description: AI Trading Agent API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: agent description: Agent identity and configuration - name: market description: Market data and analysis - name: trades description: Trade management and execution - name: positions description: Open positions - name: risk description: Risk management - name: reputation description: ERC-8004 reputation and identity - name: dashboard description: Dashboard summaries and analytics paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /agent/config: get: operationId: getAgentConfig tags: [agent] summary: Get agent configuration responses: "200": description: Agent configuration content: application/json: schema: $ref: "#/components/schemas/AgentConfig" patch: operationId: updateAgentConfig tags: [agent] summary: Update agent configuration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateAgentConfigBody" responses: "200": description: Updated agent configuration content: application/json: schema: $ref: "#/components/schemas/AgentConfig" /agent/status: get: operationId: getAgentStatus tags: [agent] summary: Get agent running status responses: "200": description: Agent status content: application/json: schema: $ref: "#/components/schemas/AgentStatus" /agent/start: post: operationId: startAgent tags: [agent] summary: Start the trading agent responses: "200": description: Agent started content: application/json: schema: $ref: "#/components/schemas/AgentStatus" /agent/stop: post: operationId: stopAgent tags: [agent] summary: Stop the trading agent responses: "200": description: Agent stopped content: application/json: schema: $ref: "#/components/schemas/AgentStatus" /market/tickers: get: operationId: getMarketTickers tags: [market] summary: Get market tickers for configured pairs responses: "200": description: Market ticker data content: application/json: schema: type: array items: $ref: "#/components/schemas/MarketTicker" /market/analysis: get: operationId: getMarketAnalysis tags: [market] summary: Get AI analysis of current market conditions responses: "200": description: Market analysis content: application/json: schema: $ref: "#/components/schemas/MarketAnalysis" /market/signals: get: operationId: getMarketSignals tags: [market] summary: Get current trading signals responses: "200": description: Trading signals content: application/json: schema: type: array items: $ref: "#/components/schemas/TradingSignal" /trades: get: operationId: listTrades tags: [trades] summary: List all trades parameters: - name: limit in: query schema: type: integer default: 50 - name: offset in: query schema: type: integer default: 0 - name: pair in: query schema: type: ["string", "null"] - name: status in: query schema: type: ["string", "null"] responses: "200": description: List of trades content: application/json: schema: type: array items: $ref: "#/components/schemas/Trade" post: operationId: createTrade tags: [trades] summary: Create and submit a trade requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateTradeBody" responses: "201": description: Trade created content: application/json: schema: $ref: "#/components/schemas/Trade" "400": description: Invalid trade parameters content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /trades/{id}: get: operationId: getTrade tags: [trades] summary: Get a specific trade parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Trade details content: application/json: schema: $ref: "#/components/schemas/Trade" "404": description: Trade not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /positions: get: operationId: listPositions tags: [positions] summary: List all open positions responses: "200": description: List of open positions content: application/json: schema: type: array items: $ref: "#/components/schemas/Position" /positions/{id}/close: post: operationId: closePosition tags: [positions] summary: Close a position parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Position closed content: application/json: schema: $ref: "#/components/schemas/Position" "404": description: Position not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /risk/metrics: get: operationId: getRiskMetrics tags: [risk] summary: Get current risk metrics responses: "200": description: Risk metrics content: application/json: schema: $ref: "#/components/schemas/RiskMetrics" /risk/limits: get: operationId: getRiskLimits tags: [risk] summary: Get risk limits configuration responses: "200": description: Risk limits content: application/json: schema: $ref: "#/components/schemas/RiskLimits" patch: operationId: updateRiskLimits tags: [risk] summary: Update risk limits requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateRiskLimitsBody" responses: "200": description: Updated risk limits content: application/json: schema: $ref: "#/components/schemas/RiskLimits" /reputation/identity: get: operationId: getAgentIdentity tags: [reputation] summary: Get ERC-8004 agent identity responses: "200": description: Agent identity content: application/json: schema: $ref: "#/components/schemas/AgentIdentity" /reputation/score: get: operationId: getReputationScore tags: [reputation] summary: Get agent reputation score responses: "200": description: Reputation score content: application/json: schema: $ref: "#/components/schemas/ReputationScore" /reputation/attestations: get: operationId: listAttestations tags: [reputation] summary: List validation attestations responses: "200": description: List of attestations content: application/json: schema: type: array items: $ref: "#/components/schemas/Attestation" /dashboard/summary: get: operationId: getDashboardSummary tags: [dashboard] summary: Get dashboard summary with key metrics responses: "200": description: Dashboard summary content: application/json: schema: $ref: "#/components/schemas/DashboardSummary" /dashboard/pnl-history: get: operationId: getPnlHistory tags: [dashboard] summary: Get PnL over time parameters: - name: period in: query schema: type: string enum: [1d, 7d, 30d] default: 7d responses: "200": description: PnL history content: application/json: schema: type: array items: $ref: "#/components/schemas/PnlDataPoint" /dashboard/activity: get: operationId: getRecentActivity tags: [dashboard] summary: Get recent trading activity feed responses: "200": description: Recent activity content: application/json: schema: type: array items: $ref: "#/components/schemas/ActivityEvent" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error AgentConfig: type: object properties: id: type: integer name: type: string strategy: type: string enum: [momentum, mean_reversion, trend_following, scalping] tradingPairs: type: array items: type: string maxPositionSize: type: number tradeFrequency: type: string enum: [high, medium, low] aiModel: type: string krakenApiKey: type: ["string", "null"] autoTrade: type: boolean createdAt: type: string updatedAt: type: string required: - id - name - strategy - tradingPairs - maxPositionSize - tradeFrequency - aiModel - krakenApiKey - autoTrade - createdAt - updatedAt UpdateAgentConfigBody: type: object properties: name: type: string strategy: type: string enum: [momentum, mean_reversion, trend_following, scalping] tradingPairs: type: array items: type: string maxPositionSize: type: number tradeFrequency: type: string enum: [high, medium, low] aiModel: type: string krakenApiKey: type: ["string", "null"] autoTrade: type: boolean AgentStatus: type: object properties: running: type: boolean uptime: type: ["integer", "null"] lastAction: type: ["string", "null"] lastActionTime: type: ["string", "null"] tradesExecuted: type: integer currentCycle: type: ["integer", "null"] required: - running - uptime - lastAction - lastActionTime - tradesExecuted - currentCycle MarketTicker: type: object properties: pair: type: string price: type: number bid: type: number ask: type: number volume24h: type: number change24h: type: number high24h: type: number low24h: type: number timestamp: type: string required: - pair - price - bid - ask - volume24h - change24h - high24h - low24h - timestamp MarketAnalysis: type: object properties: summary: type: string sentiment: type: string enum: [bullish, bearish, neutral] confidence: type: number keyFactors: type: array items: type: string recommendation: type: string analyzedAt: type: string required: - summary - sentiment - confidence - keyFactors - recommendation - analyzedAt TradingSignal: type: object properties: pair: type: string direction: type: string enum: [buy, sell, hold] strength: type: number indicator: type: string value: type: number threshold: type: number timestamp: type: string required: - pair - direction - strength - indicator - value - threshold - timestamp Trade: type: object properties: id: type: integer pair: type: string side: type: string enum: [buy, sell] type: type: string enum: [market, limit] quantity: type: number price: type: ["number", "null"] executedPrice: type: ["number", "null"] status: type: string enum: [pending, open, filled, cancelled, failed] pnl: type: ["number", "null"] fee: type: ["number", "null"] strategy: type: string aiSignalId: type: ["string", "null"] krakenOrderId: type: ["string", "null"] tradeIntentHash: type: ["string", "null"] createdAt: type: string updatedAt: type: string required: - id - pair - side - type - quantity - price - executedPrice - status - pnl - fee - strategy - aiSignalId - krakenOrderId - tradeIntentHash - createdAt - updatedAt CreateTradeBody: type: object properties: pair: type: string side: type: string enum: [buy, sell] type: type: string enum: [market, limit] quantity: type: number price: type: ["number", "null"] strategy: type: string required: - pair - side - type - quantity - strategy Position: type: object properties: id: type: integer pair: type: string side: type: string enum: [long, short] quantity: type: number entryPrice: type: number currentPrice: type: number unrealizedPnl: type: number unrealizedPnlPct: type: number leverage: type: number margin: type: number stopLoss: type: ["number", "null"] takeProfit: type: ["number", "null"] openedAt: type: string updatedAt: type: string required: - id - pair - side - quantity - entryPrice - currentPrice - unrealizedPnl - unrealizedPnlPct - leverage - margin - stopLoss - takeProfit - openedAt - updatedAt RiskMetrics: type: object properties: totalExposure: type: number dailyPnl: type: number dailyDrawdown: type: number maxDrawdown: type: number sharpeRatio: type: number winRate: type: number profitFactor: type: number totalTrades: type: integer openPositions: type: integer riskScore: type: number circuitBreakerTripped: type: boolean updatedAt: type: string required: - totalExposure - dailyPnl - dailyDrawdown - maxDrawdown - sharpeRatio - winRate - profitFactor - totalTrades - openPositions - riskScore - circuitBreakerTripped - updatedAt RiskLimits: type: object properties: id: type: integer maxDailyLoss: type: number maxDrawdown: type: number maxPositionSize: type: number maxLeverage: type: number maxOpenPositions: type: integer stopLossDefault: type: number takeProfitDefault: type: number dailyTradeLimit: type: integer updatedAt: type: string required: - id - maxDailyLoss - maxDrawdown - maxPositionSize - maxLeverage - maxOpenPositions - stopLossDefault - takeProfitDefault - dailyTradeLimit - updatedAt UpdateRiskLimitsBody: type: object properties: maxDailyLoss: type: number maxDrawdown: type: number maxPositionSize: type: number maxLeverage: type: number maxOpenPositions: type: integer stopLossDefault: type: number takeProfitDefault: type: number dailyTradeLimit: type: integer AgentIdentity: type: object properties: agentId: type: string walletAddress: type: string tokenId: type: ["string", "null"] registryAddress: type: ["string", "null"] chainId: type: integer capabilities: type: array items: type: string registeredAt: type: ["string", "null"] metadataUri: type: ["string", "null"] required: - agentId - walletAddress - tokenId - registryAddress - chainId - capabilities - registeredAt - metadataUri ReputationScore: type: object properties: overall: type: number pnlScore: type: number riskScore: type: number validationScore: type: number consistency: type: number totalValidations: type: integer rank: type: ["integer", "null"] updatedAt: type: string required: - overall - pnlScore - riskScore - validationScore - consistency - totalValidations - rank - updatedAt Attestation: type: object properties: id: type: integer type: type: string enum: [trade_intent, risk_check, strategy_checkpoint, pnl_report] hash: type: string signature: type: string tradeId: type: ["integer", "null"] data: type: string validatorAddress: type: ["string", "null"] score: type: ["number", "null"] createdAt: type: string required: - id - type - hash - signature - tradeId - data - validatorAddress - score - createdAt DashboardSummary: type: object properties: totalPnl: type: number totalPnlPct: type: number dailyPnl: type: number weeklyPnl: type: number totalTrades: type: integer winningTrades: type: integer losingTrades: type: integer winRate: type: number openPositions: type: integer totalExposure: type: number reputationScore: type: number agentRunning: type: boolean sharpeRatio: type: number maxDrawdown: type: number required: - totalPnl - totalPnlPct - dailyPnl - weeklyPnl - totalTrades - winningTrades - losingTrades - winRate - openPositions - totalExposure - reputationScore - agentRunning - sharpeRatio - maxDrawdown PnlDataPoint: type: object properties: date: type: string pnl: type: number cumulativePnl: type: number trades: type: integer required: - date - pnl - cumulativePnl - trades ActivityEvent: type: object properties: id: type: integer type: type: string enum: [trade_opened, trade_closed, position_opened, position_closed, signal_generated, risk_alert, agent_started, agent_stopped] message: type: string pair: type: ["string", "null"] pnl: type: ["number", "null"] severity: type: string enum: [info, warning, success, error] createdAt: type: string required: - id - type - message - pair - pnl - severity - createdAt