{
  "openapi": "3.1.0",
  "info": {
    "title": "Central Command x402 Agent API",
    "version": "1.0.0",
    "description": "# Central Command — AI Trading Intelligence for Agents\n\nA comprehensive suite of **36 endpoints** providing real-time market data, proprietary trading signals, AI-powered analysis, strategy backtesting, and multi-chain execution infrastructure.\n\n## What We Offer\n\n| Category | Endpoints | Description |\n|----------|-----------|-------------|\n| **Market Data** | 16 | Real-time derivatives data, orderflow, sentiment, macro events |\n| **Signals** | 7 | Proprietary counter-trade alpha, fade signals, risk monitoring |\n| **Execution** | 3 | TWAP, smart routing, BloFin exchange access |\n| **AI Agents** | 2 | Autonomous trading agents with market analysis + execution |\n| **Strategy** | 6 | Backtesting, indicator generation, 25+ TA tools |\n| **Analytics** | 0 | Broker-wide performance, deep trader scanning |\n| **Web3** | 2 | Multi-chain RPC (Solana + 6 EVM chains) |\n| **Vault** | 0 | Copy-trading vault positions and management |\n\n## Unique Alpha\n\nOur **Counter-Fade Engine (CFE)** is proprietary intelligence no other provider offers:\n- Identifies statistically-proven bad traders (t-stat < -2.0)\n- Generates real-time inverse signals when they enter positions\n- Backtested: fading the bottom decile produces 2.1x Sharpe ratio\n\n## Pricing\n\nPay-per-call in USDC. No subscriptions required. Minimum topup: $1.\n\n| Tier | Balance Required | Rate Limit | Access |\n|------|-----------------|------------|--------|\n| Free | $0 (100 calls trial) | 10/min | Standard endpoints only |\n| Standard | $5+ | 60/min | All standard + some premium |\n| Premium | $20+ | 30/min | All endpoints including alpha signals |\n| Enterprise | $100+ | 10/min | Full autonomous agent access with execution |\n\n## Quick Start\n\n```bash\n# 1. Register\ncurl -X POST https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"my-trading-agent\"}'\n\n# 2. Browse catalog\ncurl https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/catalog\n\n# 3. Call an endpoint\ncurl -X POST https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/fear-greed \\\n  -H \"X-Api-Key: x402_your_key_here\" \\\n  -H \"Content-Type: application/json\"\n```\n",
    "contact": {
      "name": "Central Command",
      "url": "https://centralcommand.app"
    },
    "x-402-protocol": {
      "version": 2,
      "payment_currency": "USDC",
      "payment_networks": [
        "base",
        "solana",
        "ethereum"
      ],
      "payment_models": [
        "x402_exact",
        "prepaid_balance"
      ],
      "canonical": {
        "scheme": "exact",
        "network": "eip155:8453",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "how_to_pay": "Call any /x402-gateway/{slug} with an X-PAYMENT header (base64 x402 v2 PaymentPayload). Omit it to receive the 402 PaymentRequirements in `accepts`.",
        "well_known": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/well-known-x402"
      }
    }
  },
  "servers": [
    {
      "url": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway",
      "description": "Production Gateway"
    }
  ],
  "paths": {
    "/squirrel-chat-v2": {
      "post": {
        "operationId": "squirrel-chat-v2",
        "summary": "Autonomous Trading Agent",
        "description": "Full AI trading assistant powered by GPT that can analyze markets, compute indicators, fetch live data, place orders, manage positions, and provide strategic advice.",
        "tags": [
          "ai"
        ],
        "x-price-usdc": 0.03,
        "x-tier": "enterprise",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "message",
            "in": "body",
            "required": true,
            "description": "Natural language message to the AI agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversation_id",
            "in": "body",
            "required": false,
            "description": "Continue existing conversation",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "message": "Analyze BTC and tell me if I should be long or short right now"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Conversational AI response with embedded trade execution, market analysis, indicator computations, and chart drawing commands.",
            "content": {
              "application/json": {
                "example": {
                  "message": "BTC is currently at $67,500 showing bullish divergence on the 4H RSI (42 -> 48 while price made equal lows). Funding is slightly negative (-0.002%) suggesting shorts are paying. I lean long here with entry at current, SL at $66,200 (below the range low), TP1 at $69,000. Risk/reward: 2.3:1.",
                  "actions_executed": [
                    {
                      "action": "get_price",
                      "result": {
                        "price": 67500
                      }
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/openclaw-chat": {
      "post": {
        "operationId": "openclaw-chat",
        "summary": "OpenClaw Strategy Agent",
        "description": "Autonomous AI agent specialized in strategy development, backtesting, and continuous market monitoring. Uses indicator libraries, pattern recognition, and instrument specifications.",
        "tags": [
          "ai"
        ],
        "x-price-usdc": 0.025,
        "x-tier": "enterprise",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "message",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversation_id",
            "in": "body",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "message": "Create a mean-reversion strategy for ETH using Bollinger Bands and RSI"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured AI analysis with computed indicators, detected patterns, strategy recommendations, and task management for autonomous execution.",
            "content": {
              "application/json": {
                "example": {
                  "message": "Strategy created: ETH Mean Reversion v1. Entry: RSI < 30 AND price touches lower BB. Exit: RSI > 50 OR price hits middle BB. Backtested 90 days: 68% win rate, 1.8 Sharpe, max DD 4.2%.",
                  "task_proposal": {
                    "goal": "Monitor ETH for BB+RSI entry conditions",
                    "title": "ETH Mean Reversion Monitor"
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/trade-builder": {
      "post": {
        "operationId": "trade-builder",
        "summary": "AI Trade Constructor",
        "description": "Takes natural language or structured trade ideas, fetches live market context, and generates fully executable order parameters with AI reasoning.",
        "tags": [
          "execution"
        ],
        "x-price-usdc": 0.02,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "idea",
            "in": "body",
            "required": true,
            "description": "Natural language trade idea or structured params",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "risk_pct",
            "in": "body",
            "required": false,
            "description": "Max risk as % of account",
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "idea": "Long ETH if it breaks above 3500 with tight stop",
                "risk_pct": 1.5
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Complete trade specification: symbol, side, size, leverage, entry type, TP levels, SL level, AI reasoning for each parameter.",
            "content": {
              "application/json": {
                "example": {
                  "sl": 3450,
                  "tp": [
                    3600,
                    3700
                  ],
                  "side": "buy",
                  "symbol": "ETH-USDT",
                  "leverage": 10,
                  "reasoning": "Breakout setup above key resistance with defined risk.",
                  "entry_type": "limit",
                  "entry_price": 3505,
                  "size_contracts": 15
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/blofin-public": {
      "post": {
        "operationId": "blofin-public",
        "summary": "BloFin Public Market Data",
        "description": "Proxy to BloFin public API (tickers, instruments, orderbook, trades, candles) bypassing CORS restrictions.",
        "tags": [
          "execution"
        ],
        "x-price-usdc": 0.0005,
        "x-tier": "standard",
        "x-rate-limit": "120/min",
        "x-cache-ttl": 60,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "path",
            "in": "body",
            "required": true,
            "description": "BloFin API path e.g. /api/v1/market/tickers",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "params",
            "in": "body",
            "required": false,
            "schema": {
              "type": "object"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "path": "/api/v1/market/tickers",
                "params": {
                  "instId": "BTC-USDT"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Raw BloFin public API response for any public endpoint: real-time tickers, full orderbook depth, recent trades, OHLCV candles.",
            "content": {
              "application/json": {
                "example": {
                  "code": "0",
                  "data": [
                    {
                      "ask": "67500.9",
                      "bid": "67499.8",
                      "last": "67500.5",
                      "instId": "BTC-USDT",
                      "vol24h": "45000"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/twap-executor": {
      "post": {
        "operationId": "twap-executor",
        "summary": "TWAP Order Executor",
        "description": "Time-Weighted Average Price execution engine — splits large orders into smaller randomized slices over configurable time windows to minimize market impact.",
        "tags": [
          "execution"
        ],
        "x-price-usdc": 0.015,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "side",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "total_size",
            "in": "body",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "duration_minutes",
            "in": "body",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "slices",
            "in": "body",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "side": "buy",
                "slices": 10,
                "symbol": "BTC-USDT",
                "total_size": 1.5,
                "duration_minutes": 30
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Execution status: filled slices, average fill price, remaining quantity, estimated completion time.",
            "content": {
              "application/json": {
                "example": {
                  "status": "executing",
                  "avg_fill": 67480,
                  "remaining": 0.9,
                  "filled_slices": 4,
                  "est_completion": "2024-01-15T14:30:00Z"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/coinglass-data": {
      "post": {
        "operationId": "coinglass-data",
        "summary": "Aggregated Derivatives Intelligence",
        "description": "Comprehensive Coinglass derivatives data including open interest, liquidations, funding rates, and long/short ratios with 45-min caching and gzip compression.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.003,
        "x-tier": "standard",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 2700,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": false,
            "description": "Specific symbol to query (default: top 20)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Normalized market microstructure data across top crypto perpetual futures.",
            "content": {
              "application/json": {
                "example": {
                  "oi": {
                    "BTC": {
                      "total": 18500000000,
                      "change_24h": 2.3
                    }
                  },
                  "funding": {
                    "BTC": 0.0045
                  },
                  "liquidations_24h": {
                    "long": 45000000,
                    "short": 23000000
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/open-interest": {
      "post": {
        "operationId": "open-interest",
        "summary": "Aggregated Open Interest",
        "description": "Historical and current aggregated open interest across all major exchanges with 30-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "description": "Symbol to query e.g. BTC",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "interval",
            "in": "body",
            "required": false,
            "description": "Time interval: 1h, 4h, 1d",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC",
                "interval": "4h"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Time-series OI data plus current OI breakdown per exchange for requested symbol.",
            "content": {
              "application/json": {
                "example": {
                  "history": [
                    {
                      "oi": 18200000000,
                      "time": 1700000000
                    }
                  ],
                  "change_1h": 1.2,
                  "change_24h": -3.5,
                  "current_oi": 18500000000
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/market-news": {
      "post": {
        "operationId": "market-news",
        "summary": "AI-Curated Market News",
        "description": "Aggregated crypto and macro market news from multiple sources with relevance scoring and categorization.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.002,
        "x-tier": "standard",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "category",
            "in": "body",
            "required": false,
            "description": "Filter: btc, eth, sol, macro, all",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "category": "btc"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Categorized news articles: title, source, URL, relevance score, AI summary per category.",
            "content": {
              "application/json": {
                "example": {
                  "articles": [
                    {
                      "score": 0.92,
                      "title": "Bitcoin ETF sees record inflows",
                      "source": "CoinDesk",
                      "summary": "BlackRock IBIT saw $500M single-day inflow..."
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/etf-flows": {
      "post": {
        "operationId": "etf-flows",
        "summary": "Bitcoin ETF Flow Tracker",
        "description": "Real-time Bitcoin/crypto ETF inflow and outflow data tracking institutional positioning (GBTC, IBIT, FBTC, etc). 60-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.002,
        "x-tier": "standard",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 3600,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-ETF daily flow in USD with cumulative totals, showing institutional demand/supply dynamics.",
            "content": {
              "application/json": {
                "example": {
                  "date": "2024-01-15",
                  "etfs": [
                    {
                      "flow": 180000000,
                      "ticker": "IBIT"
                    },
                    {
                      "flow": -45000000,
                      "ticker": "GBTC"
                    }
                  ],
                  "total_flow_usd": 250000000
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/cme-gap": {
      "post": {
        "operationId": "cme-gap",
        "summary": "CME Futures Gap Detector",
        "description": "Detects and tracks CME Bitcoin futures gaps (Friday close vs Monday open) with fill status monitoring. Unique signal.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.002,
        "x-tier": "premium",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Array of detected gaps: direction, size, fill status, and dates. Gaps act as price magnets.",
            "content": {
              "application/json": {
                "example": {
                  "gaps": [
                    {
                      "status": "OPEN",
                      "gap_pct": 0.89,
                      "gap_size": 600,
                      "direction": "up",
                      "filled_at": null,
                      "monday_open": 67800,
                      "friday_close": 67200
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/fear-greed": {
      "post": {
        "operationId": "fear-greed",
        "summary": "Crypto Fear & Greed Index",
        "description": "Crypto market Fear & Greed composite index (0-100) with historical values and trend direction. 30-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.0005,
        "x-tier": "standard",
        "x-rate-limit": "120/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Current index value (0=extreme fear, 100=extreme greed) plus 7/30/90 day history.",
            "content": {
              "application/json": {
                "example": {
                  "value": 72,
                  "history": [
                    {
                      "date": "2024-01-15",
                      "value": 72
                    }
                  ],
                  "previous_day": 68,
                  "previous_week": 55,
                  "classification": "Greed"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/hyperliquid-data": {
      "post": {
        "operationId": "hyperliquid-data",
        "summary": "Hyperliquid Whale Intelligence",
        "description": "Whale positions and activity alerts from Hyperliquid DEX showing large trader positioning. 30-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.003,
        "x-tier": "premium",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Large positions (size, entry, PnL, leverage) plus recent whale open/close alerts.",
            "content": {
              "application/json": {
                "example": {
                  "alerts": [
                    {
                      "size": 2000000,
                      "type": "open",
                      "symbol": "ETH"
                    }
                  ],
                  "whale_positions": [
                    {
                      "side": "long",
                      "entry": 66800,
                      "symbol": "BTC",
                      "trader": "0xabc...def",
                      "pnl_pct": 2.3,
                      "size_usd": 5000000
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/liquidation-heatmap": {
      "post": {
        "operationId": "liquidation-heatmap",
        "summary": "Liquidation Heatmap",
        "description": "Liquidation cluster visualization data showing where leveraged positions would be force-closed at each price level.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "premium",
        "x-rate-limit": "20/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "range",
            "in": "body",
            "required": false,
            "description": "Price range: 5%, 10%, 20%",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "range": "10%",
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "3D matrix: price levels x leverage tiers x liquidation volume. Identifies magnetic price targets.",
            "content": {
              "application/json": {
                "example": {
                  "price_levels": [
                    67000,
                    67500,
                    68000
                  ],
                  "leverage_data": [
                    [
                      {
                        "volume": 5000000,
                        "leverage": "10x"
                      },
                      {
                        "volume": 12000000,
                        "leverage": "25x"
                      }
                    ]
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/long-short-account-ratio": {
      "post": {
        "operationId": "long-short-account-ratio",
        "summary": "Long/Short Account Ratio",
        "description": "Global long vs short account positioning ratio from Coinglass showing retail sentiment with 60-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 3600,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Time-series of long_percent, short_percent, and ratio showing crowd positioning shifts.",
            "content": {
              "application/json": {
                "example": {
                  "current": {
                    "ratio": 1.096,
                    "long_pct": 52.3,
                    "short_pct": 47.7
                  },
                  "history": [
                    {
                      "time": 1700000000,
                      "long_pct": 55.1,
                      "short_pct": 44.9
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/economic-calendar": {
      "post": {
        "operationId": "economic-calendar",
        "summary": "Macroeconomic Event Calendar",
        "description": "Upcoming high-impact macroeconomic events (CPI, FOMC, NFP, etc.) with forecast vs previous values. 60-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 3600,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Array of events with dates, countries, impact level, forecast/actual/previous values.",
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    {
                      "date": "2024-01-15T13:30:00Z",
                      "name": "US CPI YoY",
                      "impact": "high",
                      "country": "US",
                      "forecast": "3.2%",
                      "previous": "3.4%"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/liquidation-max-pain": {
      "post": {
        "operationId": "liquidation-max-pain",
        "summary": "Max Pain Liquidation Levels",
        "description": "Identifies the exact price levels where maximum liquidation cascades would trigger for both longs and shorts.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.003,
        "x-tier": "premium",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-symbol: long_max_pain_price, short_max_pain_price, current_price, distance_to_each.",
            "content": {
              "application/json": {
                "example": {
                  "symbol": "BTC",
                  "current_price": 67500,
                  "long_max_pain": 64200,
                  "short_max_pain": 71800,
                  "long_distance_pct": -4.9,
                  "short_distance_pct": 6.4
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/ma-fetch": {
      "post": {
        "operationId": "ma-fetch",
        "summary": "Moving Average Data",
        "description": "Multi-period moving average values (SMA/EMA at various lengths) via Coinglass with 30-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MA values at 7, 25, 50, 99, 200 periods across multiple timeframes for trend analysis.",
            "content": {
              "application/json": {
                "example": {
                  "ma_7": 67200,
                  "ma_25": 66500,
                  "ma_50": 64800,
                  "ma_99": 62100,
                  "ma_200": 58400,
                  "symbol": "BTC"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/asset-scanner": {
      "post": {
        "operationId": "asset-scanner",
        "summary": "Multi-Asset Technical Scanner",
        "description": "Scans 36 major crypto assets across BTC, ETH, SOL, alts, and memes for multi-timeframe technical signals including RSI, MACD, Bollinger Bands, ATR, and composite scores.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.002,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Array of per-symbol objects with indicator values, directional scores, and signal strength ratings. Cached 30 minutes.",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "price": 67500,
                      "rsi_1h": 48.7,
                      "symbol": "BTC-USDT",
                      "atr_pct": 1.8,
                      "rsi_15m": 55.2,
                      "bb_position": 0.62,
                      "macd_signal": "bullish",
                      "composite_score": 72
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/coinglass-footprint": {
      "post": {
        "operationId": "coinglass-footprint",
        "summary": "Orderflow Footprint Data",
        "description": "Fetches footprint/orderflow data showing buy vs sell volume imbalance at each price level. 5-minute cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "premium",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 300,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "description": "Trading pair e.g. BTC",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Orderflow footprint matrix: buy/sell volume at discrete price levels revealing absorption, exhaustion, and imbalance.",
            "content": {
              "application/json": {
                "example": {
                  "levels": [
                    {
                      "delta": 360000,
                      "price": 67500,
                      "buy_vol": 1250000,
                      "sell_vol": 890000,
                      "imbalance": "buy_dominant"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/funding-rates": {
      "post": {
        "operationId": "funding-rates",
        "summary": "Perpetual Funding Rates",
        "description": "Current and predicted perpetual futures funding rates across all major exchanges via Coinglass with 30-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 1800,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": false,
            "description": "Specific symbol (default: all major)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-symbol funding rate data with exchange-level breakdowns and predicted next funding.",
            "content": {
              "application/json": {
                "example": {
                  "BTC": {
                    "current": 0.0045,
                    "exchanges": {
                      "Bybit": 0.0048,
                      "BloFin": 0.0044,
                      "Binance": 0.0042
                    },
                    "predicted": 0.0038
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/traditional-markets": {
      "post": {
        "operationId": "traditional-markets",
        "summary": "Traditional Markets Dashboard",
        "description": "Live quotes for S&P 500, Nasdaq, Dow, VIX, Gold, Oil, US Bonds, DXY, and major forex pairs. 15-min cache.",
        "tags": [
          "market_data"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 900,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Multi-category quotes: indices, metals, energy, bonds, forex with price and change percentages.",
            "content": {
              "application/json": {
                "example": {
                  "forex": {
                    "DXY": {
                      "price": 104.2,
                      "change_pct": 0.08
                    }
                  },
                  "metals": {
                    "GOLD": {
                      "price": 2650,
                      "change_pct": -0.12
                    }
                  },
                  "indices": {
                    "SPX": {
                      "price": 5850,
                      "change_pct": 0.45
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/cfe-engine": {
      "post": {
        "operationId": "cfe-engine",
        "summary": "Counter-Fade Engine",
        "description": "Proprietary algorithm that identifies statistically proven bad traders (t-stat < -2.0) and generates inverse signals. Fade the crowd with mathematical edge.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.01,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 900,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-trader CFE scores: mean_return_adj, t_statistic, skewness, hit_rate, sample_size, per-symbol breakdown, and generated counter-signals.",
            "content": {
              "application/json": {
                "example": {
                  "targets": [
                    {
                      "t_stat": -2.45,
                      "trades": 156,
                      "hit_rate": 0.38,
                      "user_hash": "abc123",
                      "mean_return": -0.0032,
                      "top_fade_symbols": [
                        "ETH-USDT",
                        "SOL-USDT"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/counter-trade-monitor": {
      "post": {
        "operationId": "counter-trade-monitor",
        "summary": "Counter-Trade Position Monitor",
        "description": "Real-time monitoring of ranked counter-trade targets live positions on BloFin. Detects new entries for immediate fading.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.008,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 60,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-target: current open positions, entry prices, sides, leverage, unrealized PnL. Triggers on new entries.",
            "content": {
              "application/json": {
                "example": {
                  "targets": [
                    {
                      "positions": [
                        {
                          "side": "long",
                          "size": 5.2,
                          "entry": 3450,
                          "symbol": "ETH-USDT",
                          "leverage": "20x",
                          "unrealized_pnl": -120
                        }
                      ],
                      "user_hash": "abc"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/external-signal": {
      "post": {
        "operationId": "external-signal",
        "summary": "External Signal Webhook",
        "description": "Public-facing webhook endpoint for TradingView alerts, custom bots, and third-party signal providers. Normalizes and forwards to execution.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "standard",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "action",
            "in": "body",
            "required": true,
            "description": "buy, sell, close",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "size",
            "in": "body",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "size": 2,
                "action": "buy",
                "symbol": "ETHUSDT"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Proxied execution response: signal received, validated, normalized, and forwarded to trade engine.",
            "content": {
              "application/json": {
                "example": {
                  "received": true,
                  "forwarded": true,
                  "execution_id": "sig_abc123"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/cohort-fade-scanner": {
      "post": {
        "operationId": "cohort-fade-scanner",
        "summary": "Fadeable Cohort Scanner",
        "description": "Identifies entire cohorts of consistently underperforming traders whose positions can be faded for alpha. 15-min refresh.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.008,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 900,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked list of trader cohorts by negative alpha, with real-time position signals for fading.",
            "content": {
              "application/json": {
                "example": {
                  "cohorts": [
                    {
                      "cohort_id": "losing_leveraged",
                      "member_count": 23,
                      "avg_loss_rate": 0.67,
                      "current_positions": [
                        {
                          "symbol": "BTC-USDT",
                          "fade_signal": "short",
                          "consensus_side": "long"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/counter-trade-rankings": {
      "post": {
        "operationId": "counter-trade-rankings",
        "summary": "Inverse Alpha Leaderboard",
        "description": "Ranks all tracked traders by inverse performance — worst performers are best fade targets. Updated from live exchange data.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "standard",
        "x-rate-limit": "20/min",
        "x-cache-ttl": 900,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked array: user stats, cumulative PnL, win rate, trade count, sorted by worst-first. The anti-leaderboard.",
            "content": {
              "application/json": {
                "example": {
                  "rankings": [
                    {
                      "rank": 1,
                      "trades": 340,
                      "avg_loss": -132,
                      "win_rate": 0.28,
                      "pnl_total": -45000,
                      "user_hash": "worst_trader_1"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/cfe-risk-monitor": {
      "post": {
        "operationId": "cfe-risk-monitor",
        "summary": "Real-Time Risk Monitor",
        "description": "Checks portfolio risk in real-time: drawdown limits (-5%), daily loss caps (-$500), position count limits, and volatility regime awareness.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "premium",
        "x-rate-limit": "20/min",
        "x-cache-ttl": 60,
        "x-requires-credentials": false,
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Array of risk checks: name, passed/failed, current value, threshold, recommended action (halt/reduce/proceed).",
            "content": {
              "application/json": {
                "example": {
                  "checks": [
                    {
                      "name": "max_drawdown",
                      "value": -2.1,
                      "passed": true,
                      "threshold": -5
                    },
                    {
                      "name": "daily_loss",
                      "value": -180,
                      "passed": true,
                      "threshold": -500
                    },
                    {
                      "name": "position_count",
                      "value": 3,
                      "passed": true,
                      "threshold": 5
                    }
                  ],
                  "overall": "PROCEED"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/central-signal": {
      "post": {
        "operationId": "central-signal",
        "summary": "Universal Signal Router",
        "description": "Unified signal ingestion endpoint that normalizes symbols from any exchange format (Binance, Bybit, TradingView) to executable format and routes to execution.",
        "tags": [
          "signals"
        ],
        "x-price-usdc": 0.01,
        "x-tier": "premium",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "description": "Any format: BTCUSDT, BTC/USDT, BTC-USDT",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "side",
            "in": "body",
            "required": true,
            "description": "buy or sell",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "size",
            "in": "body",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "leverage",
            "in": "body",
            "required": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "side": "buy",
                "size": 0.1,
                "symbol": "BTCUSDT",
                "leverage": 10
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signal confirmation with execution status, order ID, fill price, and routing metadata.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "order_id": "123456",
                  "routed_to": "blofin",
                  "normalized_symbol": "BTC-USDT"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/indicator-generator": {
      "post": {
        "operationId": "indicator-generator",
        "summary": "AI Indicator Creator",
        "description": "Generates production-ready JavaScript chart indicator code from natural language descriptions. Outputs runnable indicator functions with parameters, overlays, and visualization config.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.02,
        "x-tier": "premium",
        "x-rate-limit": "10/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "description",
            "in": "body",
            "required": true,
            "description": "What the indicator should do",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "style",
            "in": "body",
            "required": false,
            "description": "overlay, oscillator, histogram",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "style": "histogram",
                "description": "Volume-weighted momentum oscillator that shows buying vs selling pressure as a histogram"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON: name, description, color, is_overlay, configurable_params, executable_code (JS function body), and explanation of the logic.",
            "content": {
              "application/json": {
                "example": {
                  "code": "function calc(candles, params) { ... }",
                  "name": "Volume Momentum",
                  "color": "#22d3ee",
                  "params": [
                    {
                      "name": "period",
                      "default": 14
                    }
                  ],
                  "is_overlay": false,
                  "description": "Shows net buying/selling pressure weighted by volume",
                  "explanation": "Computes delta between up-volume and down-volume, smoothed over the period."
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/strategy-backtest": {
      "post": {
        "operationId": "strategy-backtest",
        "summary": "AI Strategy Backtester",
        "description": "Takes a natural language strategy description, generates executable code, and runs it against historical OHLCV data with full TP/SL/trailing stop simulation.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.05,
        "x-tier": "premium",
        "x-rate-limit": "5/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "strategy",
            "in": "body",
            "required": true,
            "description": "Natural language strategy description",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timeframe",
            "in": "body",
            "required": false,
            "description": "1h, 4h, 1d",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "body",
            "required": false,
            "description": "History lookback (default: 90)",
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "days": 90,
                "symbol": "BTC-USDT",
                "strategy": "Buy when RSI crosses above 30 from below and MACD histogram turns positive. Sell at RSI > 70 or -2% stop loss.",
                "timeframe": "4h"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Complete backtest results: total trades, win rate, net PnL, max drawdown, Sharpe ratio, profit factor, and individual trade log with entry/exit details.",
            "content": {
              "application/json": {
                "example": {
                  "trades": [
                    {
                      "exit": 44100,
                      "side": "long",
                      "entry": 43200,
                      "pnl_pct": 2.08,
                      "exit_time": "2024-01-06T12:00:00Z",
                      "entry_time": "2024-01-05T08:00:00Z"
                    }
                  ],
                  "summary": {
                    "win_rate": 0.65,
                    "net_pnl_pct": 18.4,
                    "max_drawdown": -4.2,
                    "sharpe_ratio": 1.82,
                    "total_trades": 23,
                    "profit_factor": 2.1
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/auto-fetch-market-data": {
      "post": {
        "operationId": "auto-fetch-market-data",
        "summary": "Comprehensive Market Context",
        "description": "All-in-one market intelligence: OHLCV candles + computed indicators + Coinglass OI + news via Tavily. Everything an agent needs in one call.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.008,
        "x-tier": "premium",
        "x-rate-limit": "15/min",
        "x-cache-ttl": 300,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timeframe",
            "in": "body",
            "required": false,
            "description": "default: 1h",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "BTC-USDT",
                "timeframe": "4h"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Multi-section response: technical indicators, OHLCV data, market microstructure (OI/funding), and relevant news summaries.",
            "content": {
              "application/json": {
                "example": {
                  "news": [
                    {
                      "title": "BTC ETF record inflows",
                      "relevance": 0.9
                    }
                  ],
                  "candles": [
                    {
                      "c": 67500,
                      "h": 67800,
                      "l": 66900,
                      "o": 67000,
                      "t": 1700000000,
                      "v": 1200
                    }
                  ],
                  "technical": {
                    "rsi": 55,
                    "macd": "bullish",
                    "trend": "up"
                  },
                  "microstructure": {
                    "funding": 0.004,
                    "oi_change_4h": 2.1
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/strategy-data-parser": {
      "post": {
        "operationId": "strategy-data-parser",
        "summary": "Strategy Language Parser",
        "description": "Parses natural language strategy descriptions into structured executable specifications: timeframes, indicators, patterns, risk parameters, and entry/exit rules.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.01,
        "x-tier": "standard",
        "x-rate-limit": "20/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "description",
            "in": "body",
            "required": true,
            "description": "Natural language strategy description",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "description": "Swing trade BTC on 4H: enter long when price bounces off 50 EMA with RSI > 40, take profit at 2R, stop below EMA"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured strategy object: TimeframeReq[], IndicatorReq[], PatternReq[], RiskParams, entry_conditions, exit_conditions — ready for backtesting or live execution.",
            "content": {
              "application/json": {
                "example": {
                  "risk": {
                    "max_risk_pct": 1
                  },
                  "exit_rules": {
                    "tp_ratio": 2,
                    "sl_reference": "below_ema_50"
                  },
                  "indicators": [
                    {
                      "type": "EMA",
                      "period": 50
                    },
                    {
                      "type": "RSI",
                      "period": 14
                    }
                  ],
                  "timeframes": [
                    "4h"
                  ],
                  "entry_rules": [
                    {
                      "condition": "price_bounce_off",
                      "reference": "EMA_50"
                    },
                    {
                      "value": 40,
                      "condition": "rsi_above"
                    }
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/data-tools": {
      "post": {
        "operationId": "data-tools",
        "summary": "Technical Analysis Toolbox",
        "description": "Comprehensive TA computation engine: 25+ indicators (SMA, EMA, RSI, MACD, ATR, Bollinger, Stochastic, ADX, CCI, Ichimoku, VWAP, Volume Profile, Fibonacci, Pivots, etc.) on any OHLCV data.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.005,
        "x-tier": "standard",
        "x-rate-limit": "30/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "symbol",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timeframe",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "indicators",
            "in": "body",
            "required": true,
            "description": "List of indicators to compute",
            "schema": {
              "type": "array"
            }
          },
          {
            "name": "candles",
            "in": "body",
            "required": false,
            "description": "Provide your own OHLCV data instead of fetching",
            "schema": {
              "type": "array"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "symbol": "ETH-USDT",
                "timeframe": "1h",
                "indicators": [
                  "RSI",
                  "MACD",
                  "BB",
                  "ATR",
                  "ADX"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Full indicator suite output for all requested tools: computed values, signals, divergences, and crossovers at every data point.",
            "content": {
              "application/json": {
                "example": {
                  "BB": {
                    "lower": 3440,
                    "upper": 3520,
                    "width": 2.3,
                    "middle": 3480
                  },
                  "ADX": {
                    "trend": "moderate",
                    "value": 28
                  },
                  "ATR": {
                    "pct": 1.3,
                    "value": 45.2
                  },
                  "RSI": {
                    "value": 55.2,
                    "signal": "neutral",
                    "divergence": null
                  },
                  "MACD": {
                    "line": 12.5,
                    "signal": 10.2,
                    "crossover": "bullish",
                    "histogram": 2.3
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/wallet-browser-proxy": {
      "post": {
        "operationId": "wallet-browser-proxy",
        "summary": "Multi-Chain EVM RPC Gateway",
        "description": "Multi-chain EVM RPC forwarder supporting Ethereum, Base, Arbitrum, Optimism, Polygon, and BSC. One endpoint, six chains.",
        "tags": [
          "web3"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "120/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "chain",
            "in": "body",
            "required": true,
            "description": "ethereum, base, arbitrum, optimism, polygon, bsc",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "method",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "params",
            "in": "body",
            "required": true,
            "schema": {
              "type": "array"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "chain": "base",
                "method": "eth_getBalance",
                "params": [
                  "0xabc...",
                  "latest"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Standard EVM JSON-RPC response for any method on any supported chain.",
            "content": {
              "application/json": {
                "example": {
                  "id": 1,
                  "result": "0x1234567890",
                  "jsonrpc": "2.0"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/solana-rpc": {
      "post": {
        "operationId": "solana-rpc",
        "summary": "Solana Multi-RPC Proxy",
        "description": "Multi-endpoint Solana RPC proxy with automatic failover (Alchemy, public, Ankr) for any JSON-RPC method. Reliable Solana access.",
        "tags": [
          "web3"
        ],
        "x-price-usdc": 0.001,
        "x-tier": "standard",
        "x-rate-limit": "120/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": false,
        "parameters": [
          {
            "name": "method",
            "in": "body",
            "required": true,
            "description": "Solana RPC method",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "params",
            "in": "body",
            "required": true,
            "schema": {
              "type": "array"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "method": "getBalance",
                "params": [
                  "DRpbCBMxVnDK7maPM5tGv6MvB3v1sRMC86PZ8okm21hy"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Standard Solana JSON-RPC response for any method: getBalance, getTokenAccounts, getTransaction, etc.",
            "content": {
              "application/json": {
                "example": {
                  "id": 1,
                  "result": {
                    "value": 1500000000
                  },
                  "jsonrpc": "2.0"
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/agent-strategy": {
      "post": {
        "operationId": "agent-strategy",
        "summary": "Agent Strategy Console",
        "description": "Full agent console — mint/link keys, paper deploy, portfolio. Linked keys FREE. Pay-per-use $0.002 USDC.",
        "tags": [
          "strategy"
        ],
        "x-price-usdc": 0.002,
        "x-tier": "free",
        "x-rate-limit": "60/min",
        "x-cache-ttl": 0,
        "x-requires-credentials": true,
        "parameters": [
          {
            "name": "action",
            "in": "body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "action": "guide"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON console responses",
            "content": {
              "application/json": {
                "example": {
                  "ok": true
                }
              }
            }
          },
          "402": {
            "description": "Payment required — register and fund your account"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Your x402 API key obtained from /register"
      }
    }
  },
  "tags": [
    {
      "name": "ai",
      "description": "AI-powered autonomous trading agents with analysis and execution"
    },
    {
      "name": "execution",
      "description": "Trade execution infrastructure: smart orders, exchange proxies"
    },
    {
      "name": "market_data",
      "description": "Real-time market data feeds: derivatives, sentiment, macro, orderflow"
    },
    {
      "name": "signals",
      "description": "Proprietary trading signals and counter-trade alpha intelligence"
    },
    {
      "name": "strategy",
      "description": "Strategy development tools: backtesting, parsing, indicator generation"
    },
    {
      "name": "web3",
      "description": "Multi-chain blockchain RPC access (Solana + EVM)"
    }
  ],
  "x-pricing": {
    "protocol": "x402",
    "models": [
      "pay_per_use",
      "prepaid_plans",
      "linked_connect"
    ],
    "pay_per_use": {
      "description": "No account. Call any endpoint → HTTP 402 accepts[] → settle Base USDC → retry with X-PAYMENT. Prices are the catalog price_usdc values ($0.0005–$0.05).",
      "network": "eip155:8453",
      "currency": "USDC",
      "pay_to": "0x4562679A63C7Fc3569cF505D9a1Ac9dB06fADb3d",
      "well_known": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/well-known-x402"
    },
    "prepaid_plans": {
      "free": {
        "topup_usdc": 0,
        "unlocks": "free endpoints + 100 standard trial data calls"
      },
      "standard": {
        "topup_usdc": 5,
        "unlocks": "all free + standard market data (fixed USDC/call)"
      },
      "premium": {
        "topup_usdc": 20,
        "unlocks": "signals, builders, backtests, AI per-token"
      },
      "enterprise": {
        "topup_usdc": 100,
        "unlocks": "full catalog"
      },
      "ai_endpoints": "per-token from prepaid token balance (topup with credit:'tokens'); x402 flat price also accepted",
      "data_endpoints": "fixed price_usdc per call from prepaid USDC balance"
    },
    "linked_connect": {
      "price_usdc": 0,
      "description": "Mint while signed in (Account → Connect Claude / Tasks → Connect). Free for entire catalog."
    },
    "register": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/register",
    "topup": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/topup",
    "balance": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/balance",
    "catalog": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/catalog"
  },
  "x-agent-console": {
    "endpoint": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/agent-strategy",
    "catalog": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-gateway/catalog",
    "actions": [
      "guide",
      "mint_key",
      "link_account",
      "whoami",
      "auth_status",
      "connect_strategy",
      "connect_blofin",
      "balance",
      "portfolio",
      "positions",
      "orders",
      "place_order",
      "close_position",
      "cancel_order",
      "strategies",
      "list_strategies",
      "get_strategy",
      "create_strategy",
      "update_strategy",
      "deploy",
      "pause",
      "execute",
      "run_once",
      "backtest",
      "get_backtest",
      "results",
      "logs"
    ],
    "hard_rules": [
      "deploy ALWAYS leaves strategy STOPPED (paused); write/register only — no real-money transfer",
      "USER turns strategies on via Tasks → Go Live",
      "Prefer task_type paper; if refusing real money, force paper + execute force_paper:true",
      "place_order/close_position/cancel_order require confirm_live:true",
      "Linked keys are FREE for all agent-strategy actions AND all gateway catalog endpoints"
    ],
    "description": "Full LLM/agent console fed from Tasks → Connect / Strategy Builder → Deploy via LLM. Copy-paste includes EVERY agent-strategy action example + EVERY gateway catalog endpoint. Agents write+deploy STOPPED strategies and paper-execute without moving capital. Linked keys are FREE and show strategies on the user dashboard.",
    "ui": "Tasks → Connect  |  Strategy Builder → Deploy via LLM",
    "free": "linked_user_id keys bypass billing for agent-strategy + catalog"
  },
  "x-discovery": {
    "llms_txt": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-docs/llms.txt",
    "manifest": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/x402-docs/manifest",
    "well_known_x402": "https://rtcelwjnrbmfmrywacky.supabase.co/functions/v1/well-known-x402",
    "cdp_bazaar": "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources"
  }
}