{
  "openapi": "3.0.3",
  "info": {
    "title": "Pnaac Journal Trade Intelligence API",
    "description": "Standardized OpenAPI 3.0 specification for Pnaac Journal trade logging, Binance WebSockets, BingX webhooks, position sizing calculations, and AI sentiment scoring.",
    "version": "1.0.0",
    "contact": {
      "name": "Pnaac Engineering Team",
      "email": "contact@pnaac.com",
      "url": "https://journal.pnaac.com"
    }
  },
  "servers": [
    {
      "url": "https://journal.pnaac.com/api",
      "description": "Production API Server"
    },
    {
      "url": "http://localhost:5173/api",
      "description": "Local Development Server"
    }
  ],
  "paths": {
    "/webhook": {
      "post": {
        "summary": "BingX & Custom TradingView Webhook Signal",
        "description": "Receives automated execution signals from BingX or TradingView alerts to create trade entries.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["symbol", "action", "price"],
                "properties": {
                  "symbol": { "type": "string", "example": "BTCUSDT" },
                  "action": { "type": "string", "enum": ["BUY", "SELL", "CLOSE"], "example": "BUY" },
                  "price": { "type": "number", "example": 68412.30 },
                  "leverage": { "type": "integer", "example": 10 },
                  "stopLoss": { "type": "number", "example": 67500.00 },
                  "takeProfit": { "type": "number", "example": 71000.00 },
                  "secret": { "type": "string", "example": "your_webhook_secret_key" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signal received and logged successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "tradeId": { "type": "string", "example": "trd_89f120" }
                  }
                }
              }
            }
          },
          "401": { "description": "Invalid webhook secret authentication" }
        }
      }
    },
    "/symbols/search": {
      "get": {
        "summary": "Search Tickers across Crypto & Stock Markets",
        "description": "Queries Binance, NASDAQ, and NSE ticker symbols for real-time price feeds.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "example": "BTC" }
          },
          {
            "name": "market",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["crypto", "stocks", "forex"], "example": "crypto" }
          }
        ],
        "responses": {
          "200": {
            "description": "List of matching symbols",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "symbol": { "type": "string", "example": "BTCUSDT" },
                      "name": { "type": "string", "example": "Bitcoin / TetherUS" },
                      "price": { "type": "number", "example": 68412.30 },
                      "change24h": { "type": "number", "example": 3.42 }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
