{
 "components": {
  "schemas": {
   "Error": {
    "properties": {
     "error": {
      "properties": {
       "codigo": {
        "type": "string"
       },
       "mensaje": {
        "type": "string"
       }
      },
      "required": [
       "codigo",
       "mensaje"
      ],
      "type": "object"
     }
    },
    "required": [
     "error"
    ],
    "type": "object"
   }
  },
  "securitySchemes": {
   "apiKey": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "bearer": {
    "scheme": "bearer",
    "type": "http"
   }
  }
 },
 "info": {
  "description": "Describe la estadística del sistema de trading del propio usuario: audita si el backtest resiste pruebas de sobreajuste y avisa cuando el rendimiento en vivo sale de lo que el backtest permitía. No recomienda operar, comprar ni vender nada. Cada salida es determinística y lleva certificate_id. Precios de prueba.",
  "title": "Edge Monitor",
  "version": "0.2.0"
 },
 "openapi": "3.1.0",
 "paths": {
  "/llms.txt": {
   "get": {
    "operationId": "llms_txt",
    "responses": {
     "200": {
      "description": "texto"
     }
    },
    "summary": "Guía para agentes de IA"
   }
  },
  "/mcp": {
   "post": {
    "operationId": "mcp",
    "responses": {
     "200": {
      "description": "respuesta JSON-RPC"
     }
    },
    "summary": "MCP por JSON-RPC 2.0 (initialize, tools/list, tools/call)"
   }
  },
  "/v1/capabilities": {
   "get": {
    "operationId": "capabilities",
    "responses": {
     "200": {
      "description": "catálogo del producto"
     }
    },
    "summary": "Capacidades, planes y contratos del producto"
   }
  },
  "/v1/edge_check": {
   "post": {
    "operationId": "edge_check",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "backtest_pnl": {
          "items": {
           "type": "number"
          },
          "type": "array"
         },
         "live_pnl": {
          "items": {
           "type": "number"
          },
          "type": "array"
         },
         "seed": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
         }
        },
        "required": [
         "backtest_pnl",
         "live_pnl"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "status": {
           "enum": [
            "OK",
            "WATCH",
            "ALERT",
            "INSUFFICIENT"
           ]
          }
         },
         "required": [
          "capability",
          "engine_version",
          "input_sha256",
          "seed",
          "certificate_id",
          "n_backtest",
          "n_live",
          "live_sum",
          "live_percentile",
          "t_stat",
          "p_value_mean_gt_0",
          "status"
         ],
         "type": "object"
        }
       }
      },
      "description": "salida determinística del motor (con certificate_id)"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "entrada inválida"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "sin API key válida"
     },
     "402": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "cuota del plan agotada"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "el plan no incluye la capacidad"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "Avisa si el rendimiento en vivo sale de lo que el backtest permitía (bootstrap y prueba t).",
    "x-planes": {
     "gratis": "3 llamadas por día UTC",
     "informe": "1 llamadas por mes UTC",
     "monitor": "2000 llamadas por mes UTC",
     "pago_por_uso": "sin cuota"
    }
   }
  },
  "/v1/pago": {
   "post": {
    "operationId": "pago",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "plan": {
          "enum": [
           "gratis",
           "informe",
           "monitor",
           "pago_por_uso"
          ]
         }
        },
        "required": [
         "plan"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "recibo"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "sin API key válida"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "Cambia de plan (cobro de prueba, sin dinero real)"
   }
  },
  "/v1/prop_challenge_sim": {
   "post": {
    "operationId": "prop_challenge_sim",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "daily_pnl": {
          "items": {
           "type": "number"
          },
          "minItems": 1,
          "type": "array"
         },
         "rules": {
          "properties": {
           "account_size": {
            "exclusiveMinimum": 0,
            "type": "number"
           },
           "drawdown_mode": {
            "enum": [
             "static",
             "trailing"
            ]
           },
           "max_daily_loss_pct": {
            "exclusiveMinimum": 0,
            "type": "number"
           },
           "max_days": {
            "minimum": 1,
            "type": "integer"
           },
           "max_drawdown_pct": {
            "exclusiveMinimum": 0,
            "type": "number"
           },
           "min_days": {
            "minimum": 0,
            "type": "integer"
           },
           "profit_target_pct": {
            "exclusiveMinimum": 0,
            "type": "number"
           }
          },
          "required": [
           "account_size",
           "profit_target_pct",
           "max_daily_loss_pct",
           "max_drawdown_pct",
           "drawdown_mode",
           "min_days",
           "max_days"
          ],
          "type": "object"
         },
         "seed": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
         }
        },
        "required": [
         "daily_pnl",
         "rules"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "required": [
          "capability",
          "engine_version",
          "input_sha256",
          "seed",
          "certificate_id",
          "n_sims",
          "p_pass",
          "p_daily_breach",
          "p_total_breach",
          "p_timeout",
          "median_days_to_pass"
         ],
         "type": "object"
        }
       }
      },
      "description": "salida determinística del motor (con certificate_id)"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "entrada inválida"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "sin API key válida"
     },
     "402": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "cuota del plan agotada"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "el plan no incluye la capacidad"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "Simula la probabilidad de aprobar un desafío de cuenta fondeada con el P&L diario histórico.",
    "x-planes": {
     "monitor": "2000 llamadas por mes UTC",
     "pago_por_uso": "sin cuota"
    }
   }
  },
  "/v1/registro": {
   "post": {
    "operationId": "registro",
    "responses": {
     "201": {
      "description": "api_key, cliente y plan"
     }
    },
    "summary": "Crea una API key de prueba en el plan por defecto"
   }
  },
  "/v1/strategy_audit": {
   "post": {
    "operationId": "strategy_audit",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "required": [
           "returns"
          ]
         },
         {
          "required": [
           "trades",
           "capital"
          ]
         }
        ],
        "properties": {
         "capital": {
          "exclusiveMinimum": 0,
          "type": "number"
         },
         "cost_per_period": {
          "minimum": 0,
          "type": "number"
         },
         "dates": {
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "n_trials": {
          "minimum": 1,
          "type": "integer"
         },
         "periodicity": {
          "enum": [
           "daily",
           "weekly",
           "monthly",
           "trade"
          ]
         },
         "returns": {
          "items": {
           "type": "number"
          },
          "minItems": 2,
          "type": "array"
         },
         "seed": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
         },
         "trades": {
          "items": {
           "properties": {
            "date": {
             "type": "string"
            },
            "pnl": {
             "type": "number"
            }
           },
           "required": [
            "date",
            "pnl"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "variant_returns": {
          "description": "matriz T x N (filas = períodos)",
          "items": {
           "items": {
            "type": "number"
           },
           "type": "array"
          },
          "type": "array"
         }
        },
        "required": [
         "periodicity",
         "n_trials"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "cost_sensitivity": {
           "required": [
            "x0",
            "x1",
            "x2"
           ],
           "type": "object"
          },
          "pbo": {
           "type": [
            "number",
            "null"
           ]
          },
          "verdict": {
           "enum": [
            "RESISTE",
            "NO_CONCLUYENTE",
            "NO_RESISTE",
            "INSUFFICIENT"
           ]
          }
         },
         "required": [
          "capability",
          "engine_version",
          "input_sha256",
          "seed",
          "certificate_id",
          "n_obs",
          "periods_per_year",
          "sharpe_annual",
          "psr",
          "n_trials_effective",
          "sr0_annual",
          "dsr",
          "mdd_observed",
          "mdd_p50",
          "mdd_p95",
          "cost_sensitivity",
          "pbo",
          "verdict",
          "cost_fragile"
         ],
         "type": "object"
        }
       }
      },
      "description": "salida determinística del motor (con certificate_id)"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "entrada inválida"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "sin API key válida"
     },
     "402": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "cuota del plan agotada"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      },
      "description": "el plan no incluye la capacidad"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "Audita si un backtest resiste pruebas de sobreajuste (PSR, DSR, drawdown Monte Carlo, PBO, costos).",
    "x-planes": {
     "gratis": "3 llamadas por día UTC",
     "informe": "1 llamadas por mes UTC",
     "monitor": "2000 llamadas por mes UTC",
     "pago_por_uso": "sin cuota"
    }
   }
  }
 },
 "servers": [
  {
   "url": "/"
  }
 ]
}
