{
  "openapi": "3.1.1",
  "info": {
    "title": "Trade Style API",
    "description": "Read your strategies, accounts, trading plans and performance, and record trades, from your own scripts.\n\n**Base URL:** `https://api.tradestyle.io`\n\nAuthenticate with the API key you generate on the Developer page of your account settings, sent as a bearer token: `Authorization: Bearer <your key>`. The API is available on the Pro and Premium tiers.\n\n**AI assistants:** the same key connects an MCP client (Claude, Cursor, VS Code, ...) to the MCP server at `/mcp`, which offers these operations as tools, plus ready-made review prompts.\n\n**Rate limits:** 60 requests per minute on Pro and 300 on Premium (fair use), counted per user and refilled continuously, so a full minute's allowance can be spent in a burst. Over the limit the API answers `429` with a `Retry-After` header giving the seconds to wait. Every rate-limited response carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the allowance is full again), so a script can pace itself before it is refused.",
    "version": "v1"
  },
  "paths": {
    "/v1/strategies": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "List your strategies",
        "description": "Returns every strategy you own, capped at your tier's maximum.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfStrategyDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "List your accounts",
        "description": "Returns every trading account you own, each with its own currency. Never truncated.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfAccountDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get one of your accounts",
        "description": "Returns one account exactly as it appears in the account list, balance included.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/trading-plans": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "List your trading plans",
        "description": "Returns every plan under one of your strategies, capped at your tier's maximum. Each plan reports the strategy it belongs to and the accounts it is assigned to.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfTradingPlanDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/trading-plans/{tradingPlanId}": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get one of your trading plans",
        "description": "Returns one plan exactly as it appears in the plan list. A plan the list hides because it is beyond your tier's maximum is not found here either.",
        "parameters": [
          {
            "name": "tradingPlanId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradingPlanDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/trades": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "List the trades on an account",
        "description": "Returns the account's trades, newest first. This is the only paged collection. Optional filters narrow it by trading plan, symbol and a date range (on the exit time, or the recording time for a trade without one; 'from' inclusive, 'to' exclusive); the page is taken after filtering. 'total' counts every matching trade, and 'nextOffset' is the offset of the next page, or null on the last one.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "tradingPlanId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "symbol",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelopeOfTradeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Workspace"
        ],
        "summary": "Record a trade",
        "description": "Records a trade against one of your accounts. The trading plan must already be assigned to that account. Profit or loss is recorded as sent, never derived from the prices. The Location header points at the new trade. Send an Idempotency-Key header to make it safe to retry: a repeat with the same key and body within 24 hours returns the first response (marked Idempotent-Replayed: true) and records nothing; the same key with a different body is 422. Without the header, every request records a trade.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Makes the request safe to retry. A repeat with the same key and body within 24 hours returns the first response, marked Idempotent-Replayed: true, and records nothing; the same key with a different body is 422. Use a new random value (for example a UUID) per request.",
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The trade to record. tradingPlanId, symbol, type and profitOrLoss are required.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "tradingPlanId",
                  "symbol",
                  "type",
                  "profitOrLoss"
                ],
                "type": "object",
                "properties": {
                  "tradingPlanId": {
                    "type": [
                      "null",
                      "string"
                    ],
                    "format": "uuid"
                  },
                  "symbol": {
                    "type": [
                      "null",
                      "string"
                    ]
                  },
                  "type": {
                    "type": [
                      "null",
                      "string"
                    ]
                  },
                  "profitOrLoss": {
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                    "type": [
                      "null",
                      "number",
                      "string"
                    ],
                    "format": "double"
                  },
                  "entryPrice": {
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                    "type": [
                      "null",
                      "number",
                      "string"
                    ],
                    "format": "double"
                  },
                  "exitPrice": {
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                    "type": [
                      "null",
                      "number",
                      "string"
                    ],
                    "format": "double"
                  },
                  "entryAt": {
                    "type": [
                      "null",
                      "string"
                    ],
                    "format": "date-time"
                  },
                  "exitAt": {
                    "type": [
                      "null",
                      "string"
                    ],
                    "format": "date-time"
                  },
                  "note": {
                    "type": [
                      "null",
                      "string"
                    ]
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Media Type",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/trades/batch": {
      "post": {
        "tags": [
          "Workspace"
        ],
        "summary": "Record several trades at once",
        "description": "Records up to 500 trades against one of your accounts in one request, each validated exactly like a single trade and each naming its own trading plan. All or nothing: if any trade is refused, none is stored. Counts as one request against your rate limit. Takes an Idempotency-Key header exactly like the single create; without one, repeating a request records the trades again.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Makes the request safe to retry. A repeat with the same key and body within 24 hours returns the first response, marked Idempotent-Replayed: true, and records nothing; the same key with a different body is 422. Use a new random value (for example a UUID) per request.",
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The trades to record, 1 to 500, each with the same fields as a single trade.",
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "trades"
                ],
                "type": "object",
                "properties": {
                  "trades": {
                    "type": [
                      "null",
                      "array"
                    ],
                    "items": {
                      "required": [
                        "tradingPlanId",
                        "symbol",
                        "type",
                        "profitOrLoss"
                      ],
                      "type": "object",
                      "properties": {
                        "tradingPlanId": {
                          "type": [
                            "null",
                            "string"
                          ],
                          "format": "uuid"
                        },
                        "symbol": {
                          "type": [
                            "null",
                            "string"
                          ]
                        },
                        "type": {
                          "type": [
                            "null",
                            "string"
                          ]
                        },
                        "profitOrLoss": {
                          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                          "type": [
                            "null",
                            "number",
                            "string"
                          ],
                          "format": "double"
                        },
                        "entryPrice": {
                          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                          "type": [
                            "null",
                            "number",
                            "string"
                          ],
                          "format": "double"
                        },
                        "exitPrice": {
                          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
                          "type": [
                            "null",
                            "number",
                            "string"
                          ],
                          "format": "double"
                        },
                        "entryAt": {
                          "type": [
                            "null",
                            "string"
                          ],
                          "format": "date-time"
                        },
                        "exitAt": {
                          "type": [
                            "null",
                            "string"
                          ],
                          "format": "date-time"
                        },
                        "note": {
                          "type": [
                            "null",
                            "string"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfTradeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported Media Type",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/trades/{tradeId}": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get one trade",
        "description": "Returns one trade on one of your accounts, exactly as it appears in the trade list. A trade that is not on that account is not found, even when it is on another of yours.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tradeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradeDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Workspace"
        ],
        "summary": "Delete a trade",
        "description": "Removes one trade from one of your accounts, for good. Answers 204 with no body. Deleting a trade that is already gone is 404, so a repeated request is never mistaken for a success.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tradeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/statistics": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get statistics for an account",
        "description": "Returns totals, win rate, profit factor, expectancy, average and largest win and loss, maximum drawdown, win and loss streaks and average holding time over the account's trades, in the account's currency. Takes the same optional filters as the trade list. Per account because accounts can hold different currencies.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tradingPlanId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "symbol",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatisticsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/equity-curve": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get an account's equity curve",
        "description": "Returns the account's balance over time, starting from its initial balance, one point per 'trade', 'day', 'week' (ISO, Monday first) or 'month' that holds a trade (default 'day', in UTC), each with its drawdown from the peak so far. Takes the same optional filters as the trade list. At most 1000 points: a longer curve is refused with 400, asking for a coarser interval.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "interval",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tradingPlanId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "symbol",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EquityCurveDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{accountId}/breakdown": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Break an account's results down",
        "description": "Groups the account's trades by 'symbol', 'side' (long or short), 'tradingPlan', 'weekday' or 'hour', with statistics per group, in the account's currency. Weekday and hour are those of the exit time (or the recording time) in 'timeZone', an IANA id, UTC by default. Takes the same optional filters as the trade list.",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "by",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "timeZone",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tradingPlanId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "symbol",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BreakdownDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/portfolio": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Get your portfolio",
        "description": "Returns every account's balance in its own currency, and their total converted into one currency, the preferred currency from your settings unless 'currency' names another, at the stored exchange rates (their capture time is in 'ratesAsOf'). The only cross-account total the API gives.",
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortfolioDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "List your organizations",
        "description": "Premium. Returns the organizations you own, each with its number of accepted members. You can own one, so the list holds at most one item. Organizations you are only a member of are not listed.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfOrganizationDto"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{organizationId}": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "Get your organization",
        "description": "Premium. Returns one organization you own, exactly as it appears in the list.",
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{organizationId}/members": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "List your organization's members",
        "description": "Premium. Returns the members who have accepted their invitation, oldest first. Pending invitations are not listed: until a member accepts, none of their data is shared.",
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeOfOrganizationMemberDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/v1/organizations/{organizationId}/members/{memberId}/statistics": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "Get a member's statistics",
        "description": "Premium. Returns one accepted member's results: each of their accounts in its own currency, with the same statistics as the account statistics route, and their balances converted into one currency, your preferred currency unless 'currency' names another. 'from' and 'to' narrow the statistics; the balances always cover every trade. Account names are not included.",
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemberStatisticsDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccountDto": {
        "required": [
          "id",
          "name",
          "initialBalance",
          "currency",
          "createdAt",
          "tradingPlans",
          "balance"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "currency": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "tradingPlans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradingPlanSummaryDto"
            }
          },
          "balance": {
            "$ref": "#/components/schemas/BalanceDto"
          }
        }
      },
      "BalanceDto": {
        "required": [
          "currentBalance",
          "profitOrLoss",
          "returnPercentage"
        ],
        "type": "object",
        "properties": {
          "currentBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "returnPercentage": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "BreakdownDto": {
        "required": [
          "accountId",
          "currency",
          "by",
          "timeZone",
          "groups"
        ],
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "by": {
            "type": "string"
          },
          "timeZone": {
            "type": "string"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BreakdownGroupDto"
            }
          }
        }
      },
      "BreakdownGroupDto": {
        "required": [
          "key",
          "totalTrades",
          "winningTrades",
          "losingTrades",
          "netProfitOrLoss",
          "winRate",
          "profitFactor",
          "expectancy",
          "averageWin",
          "averageLoss"
        ],
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "totalTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "winningTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "losingTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "netProfitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "winRate": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitFactor": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "expectancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averageWin": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averageLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "CommodityDto": {
        "required": [
          "symbol",
          "notes"
        ],
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string"
          },
          "notes": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "EnvelopeOfAccountDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EnvelopeOfOrganizationDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrganizationDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EnvelopeOfOrganizationMemberDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrganizationMemberDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EnvelopeOfStrategyDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StrategyDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EnvelopeOfTradeDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradeDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EnvelopeOfTradingPlanDto": {
        "required": [
          "items",
          "count"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradingPlanDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "EquityCurveDto": {
        "required": [
          "accountId",
          "currency",
          "interval",
          "initialBalance",
          "finalBalance",
          "maxDrawdown",
          "maxDrawdownPercent",
          "points"
        ],
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "interval": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "finalBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "maxDrawdown": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "maxDrawdownPercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "points": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EquityPointDto"
            }
          }
        }
      },
      "EquityPointDto": {
        "required": [
          "periodStart",
          "at",
          "trades",
          "profitOrLoss",
          "cumulativeProfitOrLoss",
          "balance",
          "drawdown",
          "drawdownPercent"
        ],
        "type": "object",
        "properties": {
          "periodStart": {
            "type": "string",
            "format": "date-time"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "trades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "cumulativeProfitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "balance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "drawdown": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "drawdownPercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "MemberAccountStatisticsDto": {
        "required": [
          "accountId",
          "currency",
          "initialBalance",
          "currentBalance",
          "profitOrLoss",
          "returnPercentage",
          "statistics"
        ],
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "currentBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "returnPercentage": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "statistics": {
            "$ref": "#/components/schemas/StatisticsDto"
          }
        }
      },
      "MemberStatisticsDto": {
        "required": [
          "memberId",
          "name",
          "currency",
          "initialBalance",
          "currentBalance",
          "profitOrLoss",
          "returnPercentage",
          "ratesAsOf",
          "accounts"
        ],
        "type": "object",
        "properties": {
          "memberId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "currentBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "returnPercentage": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "ratesAsOf": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MemberAccountStatisticsDto"
            }
          }
        }
      },
      "OrganizationDto": {
        "required": [
          "id",
          "name",
          "email",
          "createdAt",
          "memberCount"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "memberCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "OrganizationMemberDto": {
        "required": [
          "userId",
          "name",
          "email",
          "joinedAt"
        ],
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "null",
              "string"
            ]
          },
          "joinedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PagedEnvelopeOfTradeDto": {
        "required": [
          "items",
          "count",
          "total",
          "nextOffset"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradeDto"
            }
          },
          "count": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "total": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "nextOffset": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "PortfolioAccountDto": {
        "required": [
          "accountId",
          "name",
          "currency",
          "initialBalance",
          "currentBalance",
          "profitOrLoss",
          "returnPercentage"
        ],
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "currentBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "returnPercentage": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          }
        }
      },
      "PortfolioDto": {
        "required": [
          "currency",
          "initialBalance",
          "currentBalance",
          "profitOrLoss",
          "returnPercentage",
          "ratesAsOf",
          "accounts"
        ],
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "initialBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "currentBalance": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "returnPercentage": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "ratesAsOf": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortfolioAccountDto"
            }
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "StatisticsDto": {
        "required": [
          "accountId",
          "currency",
          "totalTrades",
          "winningTrades",
          "losingTrades",
          "evenTrades",
          "totalProfit",
          "totalLoss",
          "netProfitOrLoss",
          "winRate",
          "averageWin",
          "averageLoss",
          "profitFactor",
          "largestWin",
          "largestLoss",
          "firstTradeAt",
          "lastTradeAt",
          "expectancy",
          "maxDrawdown",
          "maxDrawdownPercent",
          "longestWinStreak",
          "longestLossStreak",
          "averageHoldingTime",
          "tradesWithHoldingTime"
        ],
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "totalTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "winningTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "losingTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "evenTrades": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "totalProfit": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "totalLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "netProfitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "winRate": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averageWin": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "averageLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitFactor": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "largestWin": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "largestLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "firstTradeAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "lastTradeAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "expectancy": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "maxDrawdown": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "maxDrawdownPercent": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "longestWinStreak": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "longestLossStreak": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "averageHoldingTime": {
            "type": [
              "null",
              "string"
            ]
          },
          "tradesWithHoldingTime": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "StrategyDto": {
        "required": [
          "id",
          "name",
          "type",
          "style",
          "description",
          "commodityTypeId",
          "createdAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "style": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "commodityTypeId": {
            "type": "string",
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TradeDto": {
        "required": [
          "id",
          "accountId",
          "tradingPlanId",
          "symbol",
          "type",
          "entryPrice",
          "exitPrice",
          "profitOrLoss",
          "entryAt",
          "exitAt",
          "note",
          "createdAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "tradingPlanId": {
            "type": "string",
            "format": "uuid"
          },
          "symbol": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "entryPrice": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "exitPrice": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "profitOrLoss": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "entryAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "exitAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "note": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TradingPlanDto": {
        "required": [
          "id",
          "strategyId",
          "accountIds",
          "alias",
          "holdingPeriod",
          "commoditySelection",
          "entrySignal",
          "entryStyle",
          "exitSignal",
          "exitStyle",
          "positionSizing",
          "stopLoss",
          "takeLossStyle",
          "bailOutIndicator",
          "notes",
          "createdAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "strategyId": {
            "type": "string",
            "format": "uuid"
          },
          "accountIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "alias": {
            "type": [
              "null",
              "string"
            ]
          },
          "holdingPeriod": {
            "type": "string"
          },
          "commoditySelection": {
            "type": "string"
          },
          "entrySignal": {
            "type": "string"
          },
          "entryStyle": {
            "type": "string"
          },
          "exitSignal": {
            "type": "string"
          },
          "exitStyle": {
            "type": "string"
          },
          "positionSizing": {
            "type": "string"
          },
          "stopLoss": {
            "type": "string"
          },
          "takeLossStyle": {
            "type": "string"
          },
          "bailOutIndicator": {
            "type": "string"
          },
          "notes": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TradingPlanSummaryDto": {
        "required": [
          "id",
          "strategyId",
          "alias",
          "commoditySelection",
          "commodities"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "strategyId": {
            "type": "string",
            "format": "uuid"
          },
          "alias": {
            "type": [
              "null",
              "string"
            ]
          },
          "commoditySelection": {
            "type": "string"
          },
          "commodities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommodityDto"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "description": "The API key from your Developer page, e.g. `tl_…`, sent as `Authorization: Bearer tl_…`.",
        "scheme": "bearer",
        "bearerFormat": "API key"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "Workspace"
    },
    {
      "name": "Organizations"
    }
  ]
}