{
    "openapi": "3.1.0",
    "info": {
        "title": "PaperTrade BD — Mobile API",
        "version": "1.0.0",
        "description": "A JSON API for **PaperTrade BD**, a Dhaka Stock Exchange paper-trading platform. Everything the\nwebsite can do — browse the market, place simulated trades, track a portfolio, read buy/sell\nsignals and candlestick patterns, and work through the bilingual Trading Academy — is available\nhere too, so a native app (Android, iOS, or anything else) can be built entirely against this API.\n\n## Authentication\n\nRegister or log in to get a bearer token (a Laravel Sanctum personal-access token, one per\ndevice, valid 90 days by default). Send it on every request after that:\n\n```\nAuthorization: Bearer <token>\n```\n\nUntil the account's email is verified, market data and `GET /me` still work; trading,\nportfolio, signals, patterns and learning answer `403 email_unverified`.\n\n## Conventions\n\n| | |\n|---|---|\n| Language | `Accept-Language: en` or `bn`. Text comes back translated; `Content-Language` says which was used |\n| Errors | Always `{ \"message\": \"...\", \"code\": \"...\", \"errors\": { \"field\": [\"...\"] } }`. Switch on `code`, show `message` to the user |\n| Pagination | `?page=&per_page=` (max 100). List endpoints answer `{ \"data\": [...], \"meta\": { \"page\", \"per_page\", \"total\", \"last_page\", \"has_more\" } }` |\n| Numbers | Plain JSON numbers; currency is BDT. Timestamps are ISO 8601 |\n| Idempotency | `POST /orders` accepts an `Idempotency-Key: <uuid>` header — the same key and body returns the original answer again (`Idempotent-Replayed: true`) instead of placing a second order |\n| Rate limits | login 5/min, register 10/hour, trading writes 30/min, everything else 120/min. A `429` comes with `Retry-After` |\n| Caching | lessons and the glossary send an `ETag`; send it back as `If-None-Match` to get a `304` |\n\n### Error codes worth handling specifically\n\n`unauthenticated` (401 — sign in again) · `email_unverified` (403) · `invalid_credentials` (401) ·\n`validation_failed` (422, see `errors`) · `too_many_requests` (429) · `not_found` (404) ·\n`insufficient_buying_power`, `insufficient_shares`, `lot_size`, `tick_size`, `circuit_limit`,\n`price_required`, `no_price`, `not_tradable`, `invalid_quantity`, `order_not_cancellable` (422,\ntrading-specific) · `idempotency_conflict` (422) · `invalid_reset_token` (422) · `server_error` (500)\n\n## A trade, end to end\n\n```bash\nTOKEN=\"…from /auth/login or /auth/register…\"\nH=\"Authorization: Bearer $TOKEN\"\nBASE=\"https://trading.bazardev.com/api/v1\"\n\ncurl \"$BASE/stocks?q=bracbank&per_page=5\" -H \"$H\"                     # find the stock\ncurl \"$BASE/stocks/BRACBANK/state\" -H \"$H\"                            # quote, my position, buying power\n\ncurl -X POST \"$BASE/orders/preview\" -H \"$H\" -H 'Content-Type: application/json' \\\n  -d '{\"code\":\"BRACBANK\",\"side\":\"buy\",\"type\":\"market\",\"qty\":100}'     # cost, fee, buying power after\n\ncurl -X POST \"$BASE/orders\" -H \"$H\" -H 'Content-Type: application/json' \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\"code\":\"BRACBANK\",\"side\":\"buy\",\"type\":\"limit\",\"limit_price\":52.5,\"qty\":100,\"tif\":\"gtc\"}'\n\ncurl \"$BASE/orders?status=open\" -H \"$H\"                                # resting orders\ncurl -X DELETE \"$BASE/orders/42\" -H \"$H\"                               # cancel (cash released)\ncurl \"$BASE/portfolio\" -H \"$H\"                                         # holdings, P&L, allocation\n```\n\n## The Trading Academy\n\n```bash\ncurl \"$BASE/learn\" -H \"$H\"                                   # tracks, next lesson, missions, level\ncurl \"$BASE/learn/tracks/basics\" -H \"$H\"                      # lessons in a track\ncurl \"$BASE/learn/lessons/risk-per-trade?html=0\" -H \"$H\"\ncurl -X POST \"$BASE/learn/lessons/risk-per-trade/quiz\" -H \"$H\" -H 'Content-Type: application/json' \\\n  -d '{\"answers\":{\"0\":1,\"1\":0}}'\ncurl \"$BASE/learn/sync?since=2026-10-12T00:00:00Z\" -H \"$H\"    # offline cache: what changed\n```\n\nA lesson comes back as `blocks` (render natively) and, unless `?html=0`, a ready-made `html`\nstring. Quiz answers never leave the server — the quiz endpoint grades and awards XP itself.\n\n## Not built yet\n\nPush notifications are stored (`POST /me/devices`) but nothing is sent yet. Also planned:\na 6-digit email code as an alternative to the link, Google login, live price streaming,\na trading journal, and class replays."
    },
    "servers": [
        {
            "url": "https://trading.bazardev.com/api/v1",
            "description": "Production"
        }
    ],
    "security": [
        {
            "http": []
        }
    ],
    "paths": {
        "/auth/register": {
            "post": {
                "operationId": "auth.register",
                "tags": [
                    "Auth"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 255
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "maxLength": 255
                                    },
                                    "password": {
                                        "type": "string"
                                    },
                                    "device_name": {
                                        "type": "string",
                                        "maxLength": 100
                                    }
                                },
                                "required": [
                                    "name",
                                    "email",
                                    "password",
                                    "device_name"
                                ]
                            },
                            "example": {
                                "name": "Rafi Ahmed",
                                "email": "rafi@example.com",
                                "password": "Str0ng!Passw0rd",
                                "device_name": "Pixel 8"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                },
                                "example": {
                                    "token": "1|abcdef...",
                                    "token_type": "Bearer",
                                    "expires_at": "2027-02-24T10:00:00+06:00",
                                    "user": {
                                        "id": 501,
                                        "name": "Rafi Ahmed",
                                        "email": "rafi@example.com",
                                        "verified": true,
                                        "locale": "en",
                                        "joined_at": "2026-10-14T09:12:00+06:00"
                                    },
                                    "message": "Account created. Check your email and tap the link to verify it."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                },
                "summary": "Create an account",
                "description": "Creates the account and signs the new device in straight away — the account starts unverified."
            }
        },
        "/auth/login": {
            "post": {
                "operationId": "auth.login",
                "tags": [
                    "Auth"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "password": {
                                        "type": "string"
                                    },
                                    "device_name": {
                                        "type": "string",
                                        "maxLength": 100
                                    }
                                },
                                "required": [
                                    "email",
                                    "password",
                                    "device_name"
                                ]
                            },
                            "example": {
                                "email": "rafi@example.com",
                                "password": "Str0ng!Passw0rd",
                                "device_name": "Pixel 8"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "token": {
                                            "type": "string"
                                        },
                                        "token_type": {
                                            "type": "string",
                                            "const": "Bearer"
                                        },
                                        "expires_at": {
                                            "type": "string"
                                        },
                                        "user": {
                                            "$ref": "#/components/schemas/UserResource"
                                        }
                                    },
                                    "required": [
                                        "token",
                                        "token_type",
                                        "expires_at",
                                        "user"
                                    ]
                                },
                                "example": {
                                    "token": "2|ghijkl...",
                                    "token_type": "Bearer",
                                    "expires_at": "2027-02-24T10:00:00+06:00",
                                    "user": {
                                        "id": 501,
                                        "name": "Rafi Ahmed",
                                        "email": "rafi@example.com",
                                        "verified": true,
                                        "locale": "en",
                                        "joined_at": "2026-10-14T09:12:00+06:00"
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                },
                "summary": "Sign in",
                "description": "Signs in on a named device and returns a fresh bearer token for it."
            }
        },
        "/auth/forgot-password": {
            "post": {
                "operationId": "auth.forgotPassword",
                "summary": "Always the same answer, so the endpoint cannot be used to find out who has an account",
                "tags": [
                    "Auth"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    }
                                },
                                "required": [
                                    "email"
                                ]
                            },
                            "example": {
                                "email": "rafi@example.com"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "If that email has an account, a reset link is on its way."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "If that email has an account, a reset link is on its way."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/auth/reset-password": {
            "post": {
                "operationId": "auth.resetPassword",
                "summary": "For apps that handle the reset link themselves (deep link), instead of the website page",
                "tags": [
                    "Auth"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "token": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "password": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "token",
                                    "email",
                                    "password"
                                ]
                            },
                            "example": {
                                "token": "abc123",
                                "email": "rafi@example.com",
                                "password": "N3wStr0ng!Pass"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Password changed. Please sign in."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Password changed. Please sign in."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/auth/logout": {
            "post": {
                "operationId": "auth.logout",
                "tags": [
                    "Auth"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Signed out."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Signed out."
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Sign out this device",
                "description": "Revokes the token used on this request; other signed-in devices are unaffected."
            }
        },
        "/auth/logout-all": {
            "post": {
                "operationId": "auth.logoutAll",
                "tags": [
                    "Auth"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Signed out everywhere."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Signed out everywhere."
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Sign out every device"
            }
        },
        "/auth/tokens": {
            "get": {
                "operationId": "auth.tokens",
                "summary": "The devices that are signed in",
                "tags": [
                    "Auth"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 9,
                                            "device": "Pixel 8",
                                            "current": true,
                                            "last_used_at": "2026-11-26T09:00:00+06:00",
                                            "created_at": "2026-10-14T09:12:00+06:00",
                                            "expires_at": "2027-02-24T10:00:00+06:00"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                }
            }
        },
        "/auth/tokens/{id}": {
            "delete": {
                "operationId": "auth.revokeToken",
                "tags": [
                    "Auth"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Device signed out."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Device signed out."
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Sign out one device by its token id"
            }
        },
        "/auth/email/resend": {
            "post": {
                "operationId": "auth.resendVerification",
                "tags": [
                    "Auth"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "anyOf": [
                                        {
                                            "type": "object",
                                            "properties": {
                                                "message": {
                                                    "type": "string",
                                                    "const": "Verification email sent."
                                                },
                                                "verified": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "message",
                                                "verified"
                                            ]
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "message": {
                                                    "type": "string",
                                                    "const": "Your email is already verified."
                                                },
                                                "verified": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "message",
                                                "verified"
                                            ]
                                        }
                                    ]
                                },
                                "example": {
                                    "message": "Verification email sent.",
                                    "verified": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Resend the verification email",
                "description": "Resends the verification email; answers straight away if the account is already verified."
            }
        },
        "/app/config": {
            "get": {
                "operationId": "v1.config",
                "tags": [
                    "Config"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "api_version": {
                                            "type": "integer",
                                            "const": 1
                                        },
                                        "min_app_version": {
                                            "type": "string"
                                        },
                                        "locales": {
                                            "type": "string"
                                        },
                                        "currency": {
                                            "type": "string",
                                            "const": "BDT"
                                        },
                                        "market": {
                                            "type": "object",
                                            "properties": {
                                                "open": {
                                                    "type": "boolean"
                                                },
                                                "status": {
                                                    "type": "string"
                                                },
                                                "timezone": {
                                                    "type": "string",
                                                    "const": "Asia/Dhaka"
                                                },
                                                "next_open": {
                                                    "type": "string"
                                                },
                                                "trading_days": {
                                                    "type": "array",
                                                    "prefixItems": [
                                                        {
                                                            "type": "string",
                                                            "const": "sun"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "mon"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "tue"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "wed"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "thu"
                                                        }
                                                    ],
                                                    "minItems": 5,
                                                    "maxItems": 5
                                                }
                                            },
                                            "required": [
                                                "open",
                                                "status",
                                                "timezone",
                                                "next_open",
                                                "trading_days"
                                            ]
                                        },
                                        "trading": {
                                            "type": "object",
                                            "properties": {
                                                "starting_cash": {
                                                    "type": "number"
                                                },
                                                "fee_pct": {
                                                    "type": "number"
                                                },
                                                "order_types": {
                                                    "type": "array",
                                                    "prefixItems": [
                                                        {
                                                            "type": "string",
                                                            "const": "market"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "limit"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "stop"
                                                        }
                                                    ],
                                                    "minItems": 3,
                                                    "maxItems": 3
                                                },
                                                "time_in_force": {
                                                    "type": "array",
                                                    "prefixItems": [
                                                        {
                                                            "type": "string",
                                                            "const": "day"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "gtc"
                                                        }
                                                    ],
                                                    "minItems": 2,
                                                    "maxItems": 2
                                                },
                                                "sides": {
                                                    "type": "array",
                                                    "prefixItems": [
                                                        {
                                                            "type": "string",
                                                            "const": "buy"
                                                        },
                                                        {
                                                            "type": "string",
                                                            "const": "sell"
                                                        }
                                                    ],
                                                    "minItems": 2,
                                                    "maxItems": 2
                                                }
                                            },
                                            "required": [
                                                "starting_cash",
                                                "fee_pct",
                                                "order_types",
                                                "time_in_force",
                                                "sides"
                                            ]
                                        },
                                        "learning": {
                                            "type": "object",
                                            "properties": {
                                                "pass_mark": {
                                                    "type": "string"
                                                },
                                                "tracks": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object",
                                                        "properties": {
                                                            "key": {
                                                                "type": "string"
                                                            },
                                                            "name": {
                                                                "type": "string"
                                                            },
                                                            "about": {
                                                                "type": "string"
                                                            },
                                                            "level": {
                                                                "type": "string"
                                                            },
                                                            "icon": {
                                                                "type": "string"
                                                            }
                                                        },
                                                        "required": [
                                                            "key",
                                                            "name",
                                                            "about",
                                                            "level",
                                                            "icon"
                                                        ]
                                                    }
                                                },
                                                "levels": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object",
                                                        "properties": {
                                                            "number": {
                                                                "type": "string"
                                                            },
                                                            "xp": {
                                                                "type": "string"
                                                            },
                                                            "title": {
                                                                "type": "string"
                                                            }
                                                        },
                                                        "required": [
                                                            "number",
                                                            "xp",
                                                            "title"
                                                        ]
                                                    }
                                                }
                                            },
                                            "required": [
                                                "pass_mark",
                                                "tracks",
                                                "levels"
                                            ]
                                        },
                                        "features": {
                                            "type": "object",
                                            "properties": {
                                                "push": {
                                                    "type": "boolean"
                                                },
                                                "google_login": {
                                                    "type": "boolean"
                                                },
                                                "journal": {
                                                    "type": "boolean"
                                                },
                                                "replay": {
                                                    "type": "boolean"
                                                },
                                                "classes": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "push",
                                                "google_login",
                                                "journal",
                                                "replay",
                                                "classes"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "api_version",
                                        "min_app_version",
                                        "locales",
                                        "currency",
                                        "market",
                                        "trading",
                                        "learning",
                                        "features"
                                    ]
                                }
                            }
                        }
                    }
                },
                "summary": "App bootstrap config",
                "description": "Public, no token needed — call before login so the app knows the current rules, locales and whether the market is open."
            }
        },
        "/learn": {
            "get": {
                "operationId": "learn.home",
                "tags": [
                    "Learn"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "level": {
                                            "type": "object",
                                            "properties": {
                                                "index": {
                                                    "type": "string"
                                                },
                                                "number": {
                                                    "type": "number"
                                                },
                                                "title": {
                                                    "type": "string"
                                                },
                                                "xp": {
                                                    "type": "integer"
                                                },
                                                "floor": {
                                                    "type": "string"
                                                },
                                                "next": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ]
                                                },
                                                "progress": {
                                                    "type": "integer"
                                                },
                                                "max": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "index",
                                                "number",
                                                "title",
                                                "xp",
                                                "floor",
                                                "next",
                                                "progress",
                                                "max"
                                            ]
                                        },
                                        "streak": {
                                            "type": "integer"
                                        },
                                        "completed": {
                                            "type": "integer"
                                        },
                                        "total_lessons": {
                                            "type": "integer",
                                            "minimum": 0
                                        },
                                        "next": {
                                            "type": [
                                                "object",
                                                "null"
                                            ],
                                            "properties": {
                                                "slug": {
                                                    "type": "string"
                                                },
                                                "track": {
                                                    "type": "string"
                                                },
                                                "title": {
                                                    "type": "string"
                                                },
                                                "summary": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ]
                                                },
                                                "level": {
                                                    "type": "string"
                                                },
                                                "minutes": {
                                                    "type": "integer"
                                                },
                                                "xp": {
                                                    "type": "integer"
                                                },
                                                "has_quiz": {
                                                    "type": "boolean"
                                                },
                                                "translated": {
                                                    "type": "boolean"
                                                },
                                                "verified": {
                                                    "type": "boolean"
                                                },
                                                "completed": {
                                                    "type": "boolean"
                                                },
                                                "best_score": {
                                                    "type": [
                                                        "integer",
                                                        "null"
                                                    ]
                                                },
                                                "attempts": {
                                                    "type": "integer"
                                                }
                                            },
                                            "required": [
                                                "slug",
                                                "track",
                                                "title",
                                                "summary",
                                                "level",
                                                "minutes",
                                                "xp",
                                                "has_quiz",
                                                "translated",
                                                "verified",
                                                "completed",
                                                "best_score",
                                                "attempts"
                                            ]
                                        },
                                        "tracks": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "key": {
                                                        "type": "string"
                                                    },
                                                    "name": {
                                                        "type": "string"
                                                    },
                                                    "about": {
                                                        "type": "string"
                                                    },
                                                    "level": {
                                                        "type": "string"
                                                    },
                                                    "icon": {
                                                        "type": "string"
                                                    },
                                                    "total": {
                                                        "type": "integer",
                                                        "minimum": 0
                                                    },
                                                    "done": {
                                                        "type": "integer",
                                                        "minimum": 0
                                                    },
                                                    "planned": {
                                                        "type": "integer"
                                                    }
                                                },
                                                "required": [
                                                    "key",
                                                    "name",
                                                    "about",
                                                    "level",
                                                    "icon",
                                                    "total",
                                                    "done",
                                                    "planned"
                                                ]
                                            }
                                        },
                                        "missions": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "key": {
                                                        "type": "string"
                                                    },
                                                    "name": {
                                                        "type": "string"
                                                    },
                                                    "about": {
                                                        "type": "string"
                                                    },
                                                    "xp": {
                                                        "type": "string"
                                                    },
                                                    "lesson": {
                                                        "type": "string"
                                                    },
                                                    "done": {
                                                        "type": "string"
                                                    }
                                                },
                                                "required": [
                                                    "key",
                                                    "name",
                                                    "about",
                                                    "xp",
                                                    "lesson",
                                                    "done"
                                                ]
                                            }
                                        },
                                        "badges": {
                                            "type": "object",
                                            "additionalProperties": []
                                        }
                                    },
                                    "required": [
                                        "level",
                                        "streak",
                                        "completed",
                                        "total_lessons",
                                        "next",
                                        "tracks",
                                        "missions",
                                        "badges"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Academy home",
                "description": "Level, streak, every track with its own progress, the next recommended lesson, missions and badges."
            }
        },
        "/learn/progress": {
            "get": {
                "operationId": "learn.progress",
                "tags": [
                    "Learn"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "level": {
                                            "type": "object",
                                            "properties": {
                                                "index": {
                                                    "type": "string"
                                                },
                                                "number": {
                                                    "type": "number"
                                                },
                                                "title": {
                                                    "type": "string"
                                                },
                                                "xp": {
                                                    "type": "integer"
                                                },
                                                "floor": {
                                                    "type": "string"
                                                },
                                                "next": {
                                                    "type": [
                                                        "string",
                                                        "null"
                                                    ]
                                                },
                                                "progress": {
                                                    "type": "integer"
                                                },
                                                "max": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "index",
                                                "number",
                                                "title",
                                                "xp",
                                                "floor",
                                                "next",
                                                "progress",
                                                "max"
                                            ]
                                        },
                                        "streak": {
                                            "type": "integer"
                                        },
                                        "completed": {
                                            "type": "integer",
                                            "minimum": 0
                                        },
                                        "missions": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "key": {
                                                        "type": "string"
                                                    },
                                                    "name": {
                                                        "type": "string"
                                                    },
                                                    "about": {
                                                        "type": "string"
                                                    },
                                                    "xp": {
                                                        "type": "string"
                                                    },
                                                    "lesson": {
                                                        "type": "string"
                                                    },
                                                    "done": {
                                                        "type": "string"
                                                    }
                                                },
                                                "required": [
                                                    "key",
                                                    "name",
                                                    "about",
                                                    "xp",
                                                    "lesson",
                                                    "done"
                                                ]
                                            }
                                        },
                                        "badges": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "key": {
                                                        "type": "string"
                                                    },
                                                    "icon": {
                                                        "type": "string"
                                                    },
                                                    "name": {
                                                        "type": "string"
                                                    },
                                                    "about": {
                                                        "type": "string"
                                                    },
                                                    "awarded_at": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    }
                                                },
                                                "required": [
                                                    "key",
                                                    "icon",
                                                    "name",
                                                    "about",
                                                    "awarded_at"
                                                ]
                                            }
                                        },
                                        "events": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "type": {
                                                        "type": "string"
                                                    },
                                                    "ref": {
                                                        "type": "string"
                                                    },
                                                    "xp": {
                                                        "type": "integer"
                                                    },
                                                    "at": {
                                                        "type": [
                                                            "string",
                                                            "null"
                                                        ]
                                                    }
                                                },
                                                "required": [
                                                    "type",
                                                    "ref",
                                                    "xp",
                                                    "at"
                                                ]
                                            }
                                        },
                                        "levels": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "number": {
                                                        "type": "string"
                                                    },
                                                    "xp": {
                                                        "type": "string"
                                                    },
                                                    "title": {
                                                        "type": "string"
                                                    }
                                                },
                                                "required": [
                                                    "number",
                                                    "xp",
                                                    "title"
                                                ]
                                            }
                                        }
                                    },
                                    "required": [
                                        "level",
                                        "streak",
                                        "completed",
                                        "missions",
                                        "badges",
                                        "events",
                                        "levels"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Learning progress and XP history"
            }
        },
        "/learn/sync": {
            "get": {
                "operationId": "learn.sync",
                "summary": "Offline sync",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "since",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "server_time": {
                                            "type": "string"
                                        },
                                        "changed": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "all": {
                                            "type": "object",
                                            "additionalProperties": []
                                        }
                                    },
                                    "required": [
                                        "server_time",
                                        "changed",
                                        "all"
                                    ]
                                },
                                "example": {
                                    "server_time": "2026-11-26T14:00:00+06:00",
                                    "changed": [
                                        {
                                            "slug": "risk-per-trade",
                                            "updated_at": "2026-11-20T08:00:00+06:00"
                                        }
                                    ],
                                    "all": [
                                        "risk-per-trade",
                                        "reading-candles"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Lessons changed since `?since=<ISO time>` plus the full list of currently-published slugs, so the app can drop ones that were unpublished."
            }
        },
        "/learn/glossary": {
            "get": {
                "operationId": "learn.glossary",
                "tags": [
                    "Learn"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "slug": "rsi",
                                            "term": "RSI",
                                            "short": "A 0-100 momentum indicator.",
                                            "category": "indicators"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Full glossary",
                "description": "All terms; optionally filtered with `?q=`."
            }
        },
        "/learn/glossary/{slug}": {
            "get": {
                "operationId": "learn.term",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "slug",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": [
                                        "object",
                                        "null"
                                    ],
                                    "properties": {
                                        "slug": {
                                            "type": "string"
                                        },
                                        "term": {
                                            "type": "string"
                                        },
                                        "short": {
                                            "type": "string"
                                        },
                                        "long": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "category": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "lesson_slug": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "slug",
                                        "term",
                                        "short",
                                        "long",
                                        "category",
                                        "lesson_slug"
                                    ]
                                },
                                "example": {
                                    "slug": "rsi",
                                    "term": "RSI",
                                    "short": "A 0-100 momentum indicator.",
                                    "long": "Relative Strength Index — compares recent gains to recent losses to flag overbought or oversold conditions.",
                                    "category": "indicators",
                                    "lesson_slug": "reading-candles"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "One glossary term"
            }
        },
        "/learn/tracks/{track}": {
            "get": {
                "operationId": "learn.track",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "track",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "key": {
                                            "type": "string"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "about": {
                                            "type": "string"
                                        },
                                        "level": {
                                            "type": "string"
                                        },
                                        "icon": {
                                            "type": "string"
                                        },
                                        "next": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "lessons": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "planned": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "key",
                                        "name",
                                        "about",
                                        "level",
                                        "icon",
                                        "next",
                                        "lessons",
                                        "planned"
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "One track and its lessons"
            }
        },
        "/learn/lessons/{lesson}": {
            "get": {
                "operationId": "learn.lesson",
                "summary": "One lesson",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "lesson",
                        "in": "path",
                        "required": true,
                        "description": "The lesson slug",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Comes back as `blocks` (render natively, cache offline) and, unless `?html=0`, a ready-made `html` string. Quiz questions are included; answers never are."
            }
        },
        "/learn/lessons/{lesson}/quiz": {
            "post": {
                "operationId": "learn.quiz",
                "summary": "Grade a quiz",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "lesson",
                        "in": "path",
                        "required": true,
                        "description": "The lesson slug",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Body is `{\"answers\": {\"<question index>\": <chosen option index>}}`. Grading and XP stay on the server."
            }
        },
        "/learn/lessons/{lesson}/complete": {
            "post": {
                "operationId": "learn.complete",
                "tags": [
                    "Learn"
                ],
                "parameters": [
                    {
                        "name": "lesson",
                        "in": "path",
                        "required": true,
                        "description": "The lesson slug",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Mark a lesson read"
            }
        },
        "/market/summary": {
            "get": {
                "operationId": "market.summary",
                "tags": [
                    "Market"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "open": {
                                            "type": "boolean"
                                        },
                                        "status": {
                                            "type": "string"
                                        },
                                        "next_open": {
                                            "type": "string"
                                        },
                                        "indices": {
                                            "anyOf": [
                                                {
                                                    "type": "array",
                                                    "prefixItems": [
                                                        {
                                                            "type": "object",
                                                            "properties": {
                                                                "key": {
                                                                    "type": "string",
                                                                    "const": "DSEX"
                                                                },
                                                                "value": {
                                                                    "type": "number"
                                                                },
                                                                "change": {
                                                                    "type": "number"
                                                                },
                                                                "pct": {
                                                                    "type": "number"
                                                                }
                                                            },
                                                            "required": [
                                                                "key",
                                                                "value",
                                                                "change",
                                                                "pct"
                                                            ]
                                                        },
                                                        {
                                                            "type": "object",
                                                            "properties": {
                                                                "key": {
                                                                    "type": "string",
                                                                    "const": "DS30"
                                                                },
                                                                "value": {
                                                                    "type": "number"
                                                                },
                                                                "change": {
                                                                    "type": "number"
                                                                },
                                                                "pct": {
                                                                    "type": "number"
                                                                }
                                                            },
                                                            "required": [
                                                                "key",
                                                                "value",
                                                                "change",
                                                                "pct"
                                                            ]
                                                        },
                                                        {
                                                            "type": "object",
                                                            "properties": {
                                                                "key": {
                                                                    "type": "string",
                                                                    "const": "DSES"
                                                                },
                                                                "value": {
                                                                    "type": "number"
                                                                },
                                                                "change": {
                                                                    "type": "number"
                                                                },
                                                                "pct": {
                                                                    "type": "number"
                                                                }
                                                            },
                                                            "required": [
                                                                "key",
                                                                "value",
                                                                "change",
                                                                "pct"
                                                            ]
                                                        }
                                                    ],
                                                    "minItems": 3,
                                                    "maxItems": 3
                                                },
                                                {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "minItems": 0,
                                                    "maxItems": 0
                                                }
                                            ]
                                        },
                                        "breadth": {
                                            "type": [
                                                "object",
                                                "null"
                                            ],
                                            "properties": {
                                                "up": {
                                                    "type": "integer"
                                                },
                                                "down": {
                                                    "type": "integer"
                                                },
                                                "flat": {
                                                    "type": "integer"
                                                }
                                            },
                                            "required": [
                                                "up",
                                                "down",
                                                "flat"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "open",
                                        "status",
                                        "next_open",
                                        "indices",
                                        "breadth"
                                    ]
                                },
                                "example": {
                                    "open": true,
                                    "status": "Open",
                                    "next_open": "2026-11-27T10:00:00+06:00",
                                    "indices": [
                                        {
                                            "key": "DSEX",
                                            "value": 5230.4,
                                            "change": 12.6,
                                            "pct": 0.24
                                        },
                                        {
                                            "key": "DS30",
                                            "value": 1980.1,
                                            "change": -3.2,
                                            "pct": -0.16
                                        },
                                        {
                                            "key": "DSES",
                                            "value": 1142.9,
                                            "change": 1.1,
                                            "pct": 0.1
                                        }
                                    ],
                                    "breadth": {
                                        "up": 180,
                                        "down": 140,
                                        "flat": 32
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Market status and indices",
                "description": "Whether the market is open, DSEX/DS30/DSES, and today's advancers/decliners/unchanged."
            }
        },
        "/market/movers": {
            "get": {
                "operationId": "market.movers",
                "summary": "Home-screen gainers/losers/active",
                "tags": [
                    "Market"
                ],
                "parameters": [
                    {
                        "name": "type",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "type": {
                                            "type": [
                                                "array",
                                                "null",
                                                "string"
                                            ]
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "type",
                                        "data"
                                    ]
                                },
                                "example": {
                                    "type": "gainers",
                                    "data": [
                                        {
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "company_name": "BRAC Bank PLC",
                                            "sector": "Bank",
                                            "category": "A",
                                            "board": "PUBLIC",
                                            "lot": 1,
                                            "tick": 0.1,
                                            "quote": {
                                                "ltp": 52.5,
                                                "ycp": 51.9,
                                                "change": 0.6,
                                                "pct": 1.16,
                                                "open": 52,
                                                "high": 53.1,
                                                "low": 51.8,
                                                "volume": 1250300,
                                                "value_mn": 65.7,
                                                "trades": 842,
                                                "lower": 49.3,
                                                "upper": 54.5,
                                                "updated_at": "2026-11-26T13:58:00+06:00"
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Pass `?type=gainers|losers|active&limit=` (default 10, max 30)."
            }
        },
        "/sectors": {
            "get": {
                "operationId": "market.sectors",
                "tags": [
                    "Market"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "additionalProperties": []
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        "Bank",
                                        "Pharmaceuticals",
                                        "Telecommunication",
                                        "Engineering"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "List of sectors",
                "description": "A plain list of sector names, for a filter dropdown."
            }
        },
        "/stocks": {
            "get": {
                "operationId": "market.index",
                "summary": "Search / list stocks",
                "tags": [
                    "Market"
                ],
                "parameters": [
                    {
                        "name": "view",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "meta": {
                                            "type": "object",
                                            "properties": {
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "per_page": {
                                                    "type": "integer"
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "last_page": {
                                                    "type": "integer"
                                                },
                                                "has_more": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "page",
                                                "per_page",
                                                "total",
                                                "last_page",
                                                "has_more"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "data",
                                        "meta"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "company_name": "BRAC Bank PLC",
                                            "sector": "Bank",
                                            "category": "A",
                                            "board": "PUBLIC",
                                            "lot": 1,
                                            "tick": 0.1,
                                            "quote": {
                                                "ltp": 52.5,
                                                "ycp": 51.9,
                                                "change": 0.6,
                                                "pct": 1.16,
                                                "open": 52,
                                                "high": 53.1,
                                                "low": 51.8,
                                                "volume": 1250300,
                                                "value_mn": 65.7,
                                                "trades": 842,
                                                "lower": 49.3,
                                                "upper": 54.5,
                                                "updated_at": "2026-11-26T13:58:00+06:00"
                                            }
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 30,
                                        "total": 342,
                                        "last_page": 12,
                                        "has_more": true
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Filter with `?q=&sector=&category=&view=all|gainers|losers|active`, sort with `&sort=&dir=`, paginate with `&page=&per_page=`."
            }
        },
        "/stocks/{stock}": {
            "get": {
                "operationId": "market.show",
                "tags": [
                    "Market"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                },
                                "example": {
                                    "code": "BRACBANK",
                                    "name": "BRAC Bank PLC",
                                    "company_name": "BRAC Bank PLC",
                                    "sector": "Bank",
                                    "category": "A",
                                    "board": "PUBLIC",
                                    "lot": 1,
                                    "tick": 0.1,
                                    "quote": {
                                        "ltp": 52.5,
                                        "ycp": 51.9,
                                        "change": 0.6,
                                        "pct": 1.16,
                                        "open": 52,
                                        "high": 53.1,
                                        "low": 51.8,
                                        "volume": 1250300,
                                        "value_mn": 65.7,
                                        "trades": 842,
                                        "lower": 49.3,
                                        "upper": 54.5,
                                        "updated_at": "2026-11-26T13:58:00+06:00"
                                    },
                                    "stats": {
                                        "week52_low": 38.2,
                                        "week52_high": 58.9,
                                        "avg_volume_30d": 980000,
                                        "market_cap_mn": 42000,
                                        "nav_per_share": 31.4,
                                        "pe_ratio": 9.8,
                                        "face_value": 10,
                                        "listing_year": 2003,
                                        "paid_up_capital_mn": 8000
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "One stock, with 52-week stats"
            }
        },
        "/stocks/{stock}/candles": {
            "get": {
                "operationId": "market.candles",
                "tags": [
                    "Market"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "anyOf": [
                                        {
                                            "type": "object",
                                            "properties": {
                                                "tf": {
                                                    "type": "string",
                                                    "const": "1D"
                                                },
                                                "intraday": {
                                                    "type": "boolean"
                                                },
                                                "candles": {
                                                    "type": "array",
                                                    "items": []
                                                }
                                            },
                                            "required": [
                                                "tf",
                                                "intraday",
                                                "candles"
                                            ]
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "tf": {
                                                    "type": "string",
                                                    "const": "1D"
                                                },
                                                "intraday": {
                                                    "type": "boolean"
                                                },
                                                "candles": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "minItems": 0,
                                                    "maxItems": 0
                                                }
                                            },
                                            "required": [
                                                "tf",
                                                "intraday",
                                                "candles"
                                            ]
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "tf": {
                                                    "type": "string"
                                                },
                                                "intraday": {
                                                    "type": "boolean"
                                                },
                                                "candles": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object",
                                                        "properties": {
                                                            "time": {
                                                                "type": "string"
                                                            },
                                                            "open": {
                                                                "type": "number"
                                                            },
                                                            "high": [],
                                                            "low": [],
                                                            "close": {
                                                                "type": "number"
                                                            },
                                                            "volume": {
                                                                "type": "integer"
                                                            }
                                                        },
                                                        "required": [
                                                            "time",
                                                            "open",
                                                            "high",
                                                            "low",
                                                            "close",
                                                            "volume"
                                                        ]
                                                    }
                                                }
                                            },
                                            "required": [
                                                "tf",
                                                "intraday",
                                                "candles"
                                            ]
                                        }
                                    ]
                                },
                                "example": {
                                    "tf": "3M",
                                    "intraday": false,
                                    "candles": [
                                        {
                                            "time": "2026-11-25",
                                            "open": 51.8,
                                            "high": 52.9,
                                            "low": 51.5,
                                            "close": 52.5,
                                            "volume": 1180400
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Candle history for the chart",
                "description": "Pass `?tf=1D|1W|1M|3M|1Y|…` (default `3M`). `1D` is built from the day's intraday ticks while the market is open."
            }
        },
        "/stocks/{stock}/peers": {
            "get": {
                "operationId": "market.peers",
                "tags": [
                    "Market"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "company_name": "BRAC Bank PLC",
                                            "sector": "Bank",
                                            "category": "A",
                                            "board": "PUBLIC",
                                            "lot": 1,
                                            "tick": 0.1,
                                            "quote": {
                                                "ltp": 52.5,
                                                "ycp": 51.9,
                                                "change": 0.6,
                                                "pct": 1.16,
                                                "open": 52,
                                                "high": 53.1,
                                                "low": 51.8,
                                                "volume": 1250300,
                                                "value_mn": 65.7,
                                                "trades": 842,
                                                "lower": 49.3,
                                                "upper": 54.5,
                                                "updated_at": "2026-11-26T13:58:00+06:00"
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Other stocks in the same sector"
            }
        },
        "/me": {
            "get": {
                "operationId": "me.show",
                "tags": [
                    "Me"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "user": {
                                            "$ref": "#/components/schemas/UserResource"
                                        },
                                        "account": {
                                            "type": "object",
                                            "properties": {
                                                "buying_power": {
                                                    "type": "number"
                                                },
                                                "cash": {
                                                    "type": "number"
                                                },
                                                "reserved": {
                                                    "type": "number"
                                                },
                                                "equity": {
                                                    "type": "number"
                                                },
                                                "total_pnl": {
                                                    "type": "number"
                                                },
                                                "total_pct": {
                                                    "type": "number"
                                                },
                                                "day_pnl": {
                                                    "type": "number"
                                                }
                                            },
                                            "required": [
                                                "buying_power",
                                                "cash",
                                                "reserved",
                                                "equity",
                                                "total_pnl",
                                                "total_pct",
                                                "day_pnl"
                                            ]
                                        },
                                        "learning": {
                                            "type": "object",
                                            "properties": {
                                                "level": {
                                                    "type": "object",
                                                    "properties": {
                                                        "index": {
                                                            "type": "string"
                                                        },
                                                        "number": {
                                                            "type": "number"
                                                        },
                                                        "title": {
                                                            "type": "string"
                                                        },
                                                        "xp": {
                                                            "type": "integer"
                                                        },
                                                        "floor": {
                                                            "type": "string"
                                                        },
                                                        "next": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ]
                                                        },
                                                        "progress": {
                                                            "type": "integer"
                                                        },
                                                        "max": {
                                                            "type": "boolean"
                                                        }
                                                    },
                                                    "required": [
                                                        "index",
                                                        "number",
                                                        "title",
                                                        "xp",
                                                        "floor",
                                                        "next",
                                                        "progress",
                                                        "max"
                                                    ]
                                                },
                                                "streak": {
                                                    "type": "integer"
                                                },
                                                "lessons_completed": {
                                                    "type": "integer",
                                                    "minimum": 0
                                                }
                                            },
                                            "required": [
                                                "level",
                                                "streak",
                                                "lessons_completed"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "user",
                                        "account",
                                        "learning"
                                    ]
                                },
                                "example": {
                                    "user": {
                                        "id": 501,
                                        "name": "Rafi Ahmed",
                                        "email": "rafi@example.com",
                                        "verified": true,
                                        "locale": "en",
                                        "joined_at": "2026-10-14T09:12:00+06:00"
                                    },
                                    "account": {
                                        "cash": 948745,
                                        "reserved": 5255,
                                        "buying_power": 943490,
                                        "holdings_value": 51200,
                                        "invested": 50000,
                                        "equity": 1000000,
                                        "starting_cash": 1000000,
                                        "total_pnl": 1200,
                                        "total_pct": 0.12,
                                        "unrealized": 1200,
                                        "realized": 0,
                                        "fees": 48,
                                        "day_pnl": 320
                                    },
                                    "learning": {
                                        "level": {
                                            "index": "3",
                                            "number": 3,
                                            "title": "Day Trader",
                                            "xp": 1240,
                                            "floor": "1000",
                                            "next": "2000",
                                            "progress": 24,
                                            "max": false
                                        },
                                        "streak": 4,
                                        "lessons_completed": 9
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Current user, account and learning summary"
            },
            "patch": {
                "operationId": "me.update",
                "tags": [
                    "Me"
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 255
                                    },
                                    "locale": {
                                        "type": "string",
                                        "enum": [
                                            "en",
                                            "bn"
                                        ]
                                    }
                                }
                            },
                            "example": {
                                "name": "Rafi Ahmed",
                                "locale": "bn"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "user": {
                                            "$ref": "#/components/schemas/UserResource"
                                        }
                                    },
                                    "required": [
                                        "user"
                                    ]
                                },
                                "example": {
                                    "user": {
                                        "id": 501,
                                        "name": "Rafi Ahmed",
                                        "email": "rafi@example.com",
                                        "verified": true,
                                        "locale": "en",
                                        "joined_at": "2026-10-14T09:12:00+06:00"
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Update name or language"
            },
            "delete": {
                "operationId": "me.destroy",
                "tags": [
                    "Me"
                ],
                "parameters": [
                    {
                        "name": "password",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Your account was deleted."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Your account was deleted."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Delete the account",
                "description": "Permanent — requires the current password to confirm."
            }
        },
        "/me/password": {
            "put": {
                "operationId": "me.password",
                "tags": [
                    "Me"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "current_password": {
                                        "type": "string"
                                    },
                                    "password": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "current_password",
                                    "password"
                                ]
                            },
                            "example": {
                                "current_password": "Str0ng!Passw0rd",
                                "password": "N3wStr0ng!Pass"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Password changed."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Password changed."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Change password",
                "description": "Every other signed-in device is signed out; this one keeps working."
            }
        },
        "/me/devices": {
            "post": {
                "operationId": "me.registerDevice",
                "summary": "Register a device for push",
                "tags": [
                    "Me"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "token": {
                                        "type": "string",
                                        "maxLength": 255
                                    },
                                    "platform": {
                                        "type": "string",
                                        "enum": [
                                            "android",
                                            "ios",
                                            "web"
                                        ]
                                    },
                                    "app_version": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 20
                                    }
                                },
                                "required": [
                                    "token",
                                    "platform"
                                ]
                            },
                            "example": {
                                "token": "fcm-device-token",
                                "platform": "android",
                                "app_version": "1.2.0"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Device registered."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Device registered."
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Calling again with the same `token` just refreshes it — nothing is sent yet (push is not wired up server-side)."
            },
            "delete": {
                "operationId": "me.removeDevice",
                "tags": [
                    "Me"
                ],
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Device removed."
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                },
                                "example": {
                                    "message": "Device removed."
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Remove a device token"
            }
        },
        "/patterns": {
            "get": {
                "operationId": "pattern.index",
                "summary": "Candlestick pattern scanner",
                "tags": [
                    "Pattern"
                ],
                "parameters": [
                    {
                        "name": "bias",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Filter with `?pattern=&bias=bullish|bearish|neutral&days=1|3|5&sector=&q=`."
            }
        },
        "/patterns/scorecard": {
            "get": {
                "operationId": "pattern.scorecard",
                "tags": [
                    "Pattern"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "patterns": {
                                            "type": "array",
                                            "items": []
                                        },
                                        "all": {
                                            "type": "string"
                                        },
                                        "horizons": {
                                            "type": "array",
                                            "prefixItems": [
                                                {
                                                    "type": "integer",
                                                    "const": 1
                                                },
                                                {
                                                    "type": "integer",
                                                    "const": 3
                                                },
                                                {
                                                    "type": "integer",
                                                    "const": 5
                                                },
                                                {
                                                    "type": "integer",
                                                    "const": 10
                                                }
                                            ],
                                            "minItems": 4,
                                            "maxItems": 4
                                        },
                                        "stocks": {
                                            "type": "integer"
                                        },
                                        "from": {
                                            "type": "null"
                                        },
                                        "to": {
                                            "type": "null"
                                        },
                                        "min_sample": {
                                            "type": "integer",
                                            "const": 30
                                        },
                                        "computed_at": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "patterns",
                                        "all",
                                        "horizons",
                                        "stocks",
                                        "from",
                                        "to",
                                        "min_sample",
                                        "computed_at"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "How each pattern has performed historically"
            }
        },
        "/stocks/{stock}/patterns": {
            "get": {
                "operationId": "pattern.show",
                "tags": [
                    "Pattern"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Pattern hits for one stock"
            }
        },
        "/portfolio": {
            "get": {
                "operationId": "portfolio.show",
                "tags": [
                    "Portfolio"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "cash": {
                                            "type": "number"
                                        },
                                        "reserved": {
                                            "type": "number"
                                        },
                                        "buying_power": {
                                            "type": "number"
                                        },
                                        "holdings_value": {
                                            "type": "number"
                                        },
                                        "invested": {
                                            "type": "number"
                                        },
                                        "equity": {
                                            "type": "number"
                                        },
                                        "starting_cash": {
                                            "type": "number"
                                        },
                                        "total_pnl": {
                                            "type": "number"
                                        },
                                        "total_pct": {
                                            "type": "number"
                                        },
                                        "unrealized": {
                                            "type": "number"
                                        },
                                        "realized": {
                                            "type": "number"
                                        },
                                        "fees": {
                                            "type": "number"
                                        },
                                        "day_pnl": {
                                            "type": "number"
                                        },
                                        "holdings": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "sectors": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    },
                                    "required": [
                                        "cash",
                                        "reserved",
                                        "buying_power",
                                        "holdings_value",
                                        "invested",
                                        "equity",
                                        "starting_cash",
                                        "total_pnl",
                                        "total_pct",
                                        "unrealized",
                                        "realized",
                                        "fees",
                                        "day_pnl",
                                        "holdings",
                                        "sectors"
                                    ]
                                },
                                "example": {
                                    "cash": 948745,
                                    "reserved": 5255,
                                    "buying_power": 943490,
                                    "holdings_value": 51200,
                                    "invested": 50000,
                                    "equity": 1000000,
                                    "starting_cash": 1000000,
                                    "total_pnl": 1200,
                                    "total_pct": 0.12,
                                    "unrealized": 1200,
                                    "realized": 0,
                                    "fees": 48,
                                    "day_pnl": 320,
                                    "holdings": [
                                        {
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "sector": "Bank",
                                            "qty": 100,
                                            "avg_cost": 50,
                                            "last": 52.5,
                                            "value": 5250,
                                            "cost": 5000,
                                            "pnl": 250,
                                            "pnl_pct": 5,
                                            "day_pnl": 60,
                                            "day_pct": 1.16,
                                            "weight": 10.25
                                        }
                                    ],
                                    "sectors": [
                                        {
                                            "sector": "Bank",
                                            "value": 5250
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Holdings, P&L and allocation"
            }
        },
        "/portfolio/equity-curve": {
            "get": {
                "operationId": "portfolio.equityCurve",
                "tags": [
                    "Portfolio"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "range": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": []
                                        }
                                    },
                                    "required": [
                                        "range",
                                        "data"
                                    ]
                                },
                                "example": {
                                    "range": "1m",
                                    "data": [
                                        {
                                            "time": "2026-11-25",
                                            "equity": 1000200
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Equity over time",
                "description": "Pass `?range=1m|3m|6m|1y` (default: everything)."
            }
        },
        "/leaderboard": {
            "get": {
                "operationId": "portfolio.leaderboard",
                "tags": [
                    "Portfolio"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "total": {
                                            "type": "integer",
                                            "minimum": 0
                                        },
                                        "me": {
                                            "type": [
                                                "object",
                                                "null"
                                            ],
                                            "properties": {
                                                "rank": {
                                                    "type": "integer"
                                                },
                                                "name": {
                                                    "type": "string"
                                                },
                                                "equity": {
                                                    "type": "number"
                                                },
                                                "return_pct": {
                                                    "type": "number"
                                                },
                                                "trades": {
                                                    "type": "integer"
                                                },
                                                "me": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "rank",
                                                "name",
                                                "equity",
                                                "return_pct",
                                                "trades",
                                                "me"
                                            ]
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "rank": {
                                                        "type": "integer"
                                                    },
                                                    "name": {
                                                        "type": "string"
                                                    },
                                                    "equity": {
                                                        "type": "number"
                                                    },
                                                    "return_pct": {
                                                        "type": "number"
                                                    },
                                                    "trades": {
                                                        "type": "integer"
                                                    },
                                                    "me": {
                                                        "type": "boolean"
                                                    }
                                                },
                                                "required": [
                                                    "rank",
                                                    "name",
                                                    "equity",
                                                    "return_pct",
                                                    "trades",
                                                    "me"
                                                ]
                                            }
                                        }
                                    },
                                    "required": [
                                        "total",
                                        "me",
                                        "data"
                                    ]
                                },
                                "example": {
                                    "total": 812,
                                    "me": {
                                        "rank": 46,
                                        "name": "Rafi Ahmed",
                                        "equity": 1000200,
                                        "return_pct": 0.02,
                                        "trades": 7,
                                        "me": true
                                    },
                                    "data": [
                                        {
                                            "rank": 1,
                                            "name": "Nabila T.",
                                            "equity": 1452000,
                                            "return_pct": 45.2,
                                            "trades": 58,
                                            "me": false
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Top traders by return",
                "description": "Includes the caller's own rank (`me`) even if it falls outside the top 50 returned in `data`."
            }
        },
        "/signals": {
            "get": {
                "operationId": "signal.index",
                "summary": "Daily buy/sell signal scanner",
                "tags": [
                    "Signal"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Filter with `?filter=all|buy|sell|hold&sector=&q=&liquid=1`."
            }
        },
        "/signals/performance": {
            "get": {
                "operationId": "signal.performance",
                "summary": "Does following the signals actually work?",
                "tags": [
                    "Signal"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "rows": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "horizons": {
                                            "type": "array",
                                            "prefixItems": [
                                                {
                                                    "type": "integer",
                                                    "const": 5
                                                },
                                                {
                                                    "type": "integer",
                                                    "const": 10
                                                },
                                                {
                                                    "type": "integer",
                                                    "const": 20
                                                }
                                            ],
                                            "minItems": 3,
                                            "maxItems": 3
                                        },
                                        "stocks": {
                                            "type": "integer"
                                        },
                                        "from": {
                                            "type": "null"
                                        },
                                        "to": {
                                            "type": "null"
                                        },
                                        "computed_at": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "rows",
                                        "horizons",
                                        "stocks",
                                        "from",
                                        "to",
                                        "computed_at"
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "A market-wide scorecard of what price did after each signal, 1/3/5/10 sessions out."
            }
        },
        "/stocks/{stock}/signal": {
            "get": {
                "operationId": "signal.show",
                "summary": "Today's signal for one stock",
                "tags": [
                    "Signal"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string"
                                        },
                                        "analysis": {
                                            "type": "string"
                                        },
                                        "backtest": {
                                            "type": "string"
                                        },
                                        "markers": {
                                            "type": "string"
                                        },
                                        "indicators": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "code",
                                        "analysis",
                                        "backtest",
                                        "markers",
                                        "indicators"
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Add `?indicators=1` for the full RSI/MACD series behind it (bigger payload)."
            }
        },
        "/stocks/{stock}/state": {
            "get": {
                "operationId": "trading.state",
                "summary": "Everything a trade screen needs for one stock",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Quote, my position, my open orders on it, and buying power — what the trade screen refreshes on a timer."
            }
        },
        "/orders/preview": {
            "post": {
                "operationId": "trading.preview",
                "summary": "Preview an order before placing it",
                "tags": [
                    "Trading"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "code": {
                                        "type": "string"
                                    },
                                    "side": {
                                        "type": "string",
                                        "enum": [
                                            "buy",
                                            "sell"
                                        ]
                                    },
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "market",
                                            "limit",
                                            "stop"
                                        ]
                                    },
                                    "qty": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 100000000
                                    },
                                    "limit_price": {
                                        "type": [
                                            "number",
                                            "null"
                                        ]
                                    },
                                    "stop_price": {
                                        "type": [
                                            "number",
                                            "null"
                                        ]
                                    },
                                    "tif": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "day",
                                            "gtc",
                                            null
                                        ]
                                    }
                                },
                                "required": [
                                    "code",
                                    "side",
                                    "type",
                                    "qty"
                                ]
                            },
                            "example": {
                                "code": "BRACBANK",
                                "side": "buy",
                                "type": "limit",
                                "qty": 100,
                                "limit_price": 52.5,
                                "stop_price": null,
                                "tif": "gtc"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string"
                                        },
                                        "side": {
                                            "type": "string"
                                        },
                                        "type": {
                                            "type": "string"
                                        },
                                        "qty": {
                                            "type": "integer"
                                        },
                                        "price": {
                                            "type": "number"
                                        },
                                        "gross": {
                                            "type": "number"
                                        },
                                        "fee": {
                                            "type": "number"
                                        },
                                        "fee_pct": {
                                            "type": "number"
                                        },
                                        "total": {
                                            "type": "number"
                                        },
                                        "buying_power_now": {
                                            "type": "number"
                                        },
                                        "buying_power_after": {
                                            "type": "number"
                                        },
                                        "can_place": {
                                            "type": "boolean"
                                        },
                                        "problem": {
                                            "type": [
                                                "object",
                                                "null"
                                            ],
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            },
                                            "required": [
                                                "code",
                                                "message"
                                            ]
                                        },
                                        "sell": {
                                            "type": "object",
                                            "properties": {
                                                "avg_cost": {
                                                    "type": "number"
                                                },
                                                "gain_after_fee": {
                                                    "type": "number"
                                                },
                                                "gain_pct": {
                                                    "type": "number"
                                                }
                                            },
                                            "required": [
                                                "avg_cost",
                                                "gain_after_fee",
                                                "gain_pct"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "code",
                                        "side",
                                        "type",
                                        "qty",
                                        "price",
                                        "gross",
                                        "fee",
                                        "fee_pct",
                                        "total",
                                        "buying_power_now",
                                        "buying_power_after",
                                        "can_place",
                                        "problem",
                                        "sell"
                                    ]
                                },
                                "example": {
                                    "code": "BRACBANK",
                                    "side": "buy",
                                    "type": "limit",
                                    "qty": 100,
                                    "price": 52.5,
                                    "gross": 5250,
                                    "fee": 21,
                                    "fee_pct": 0.4,
                                    "total": 5271,
                                    "buying_power_now": 943490,
                                    "buying_power_after": 938219,
                                    "can_place": true,
                                    "problem": null
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Same validation as `POST /orders`, without placing anything — the numbers behind the \"cost\" / \"if this sells\" box, including whether it `can_place`."
            }
        },
        "/orders": {
            "post": {
                "operationId": "trading.storeOrder",
                "tags": [
                    "Trading"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "code": {
                                        "type": "string"
                                    },
                                    "side": {
                                        "type": "string",
                                        "enum": [
                                            "buy",
                                            "sell"
                                        ]
                                    },
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "market",
                                            "limit",
                                            "stop"
                                        ]
                                    },
                                    "qty": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 100000000
                                    },
                                    "limit_price": {
                                        "type": [
                                            "number",
                                            "null"
                                        ]
                                    },
                                    "stop_price": {
                                        "type": [
                                            "number",
                                            "null"
                                        ]
                                    },
                                    "tif": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "day",
                                            "gtc",
                                            null
                                        ]
                                    }
                                },
                                "required": [
                                    "code",
                                    "side",
                                    "type",
                                    "qty"
                                ]
                            },
                            "example": {
                                "code": "BRACBANK",
                                "side": "buy",
                                "type": "limit",
                                "qty": 100,
                                "limit_price": 52.5,
                                "stop_price": null,
                                "tif": "gtc"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "order": {
                                            "type": "array",
                                            "items": []
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "account": {
                                            "type": "object",
                                            "properties": {
                                                "buying_power": {
                                                    "type": "number"
                                                },
                                                "cash": {
                                                    "type": "number"
                                                },
                                                "reserved": {
                                                    "type": "number"
                                                },
                                                "equity": {
                                                    "type": "number"
                                                },
                                                "total_pnl": {
                                                    "type": "number"
                                                },
                                                "total_pct": {
                                                    "type": "number"
                                                },
                                                "day_pnl": {
                                                    "type": "number"
                                                }
                                            },
                                            "required": [
                                                "buying_power",
                                                "cash",
                                                "reserved",
                                                "equity",
                                                "total_pnl",
                                                "total_pct",
                                                "day_pnl"
                                            ]
                                        },
                                        "rewards": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "order",
                                        "message",
                                        "account",
                                        "rewards"
                                    ]
                                },
                                "example": {
                                    "order": {
                                        "id": 4821,
                                        "code": "BRACBANK",
                                        "name": "BRAC Bank PLC",
                                        "side": "buy",
                                        "type": "limit",
                                        "label": "Limit",
                                        "tif": "gtc",
                                        "qty": 100,
                                        "limit_price": 52.5,
                                        "stop_price": null,
                                        "status": "pending",
                                        "open": true,
                                        "reserved_amount": 5255,
                                        "filled_price": null,
                                        "fee": null,
                                        "reject_reason": null,
                                        "session_date": "2026-11-26",
                                        "placed_at": "2026-11-26T10:14:02+06:00",
                                        "filled_at": null
                                    },
                                    "message": "Limit order for 100 BRACBANK placed (waiting to fill)",
                                    "account": {
                                        "cash": 948745,
                                        "reserved": 5255,
                                        "buying_power": 943490,
                                        "holdings_value": 51200,
                                        "invested": 50000,
                                        "equity": 1000000,
                                        "starting_cash": 1000000,
                                        "total_pnl": 1200,
                                        "total_pct": 0.12,
                                        "unrealized": 1200,
                                        "realized": 0,
                                        "fees": 48,
                                        "day_pnl": 320
                                    },
                                    "rewards": []
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Place an order",
                "description": "Market fills immediately at the last traded price; limit/stop orders rest until triggered. Send an `Idempotency-Key` header so a retried request cannot double-place the order."
            },
            "get": {
                "operationId": "trading.orders",
                "summary": "List orders",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "meta": {
                                            "type": "object",
                                            "properties": {
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "per_page": {
                                                    "type": "integer"
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "last_page": {
                                                    "type": "integer"
                                                },
                                                "has_more": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "page",
                                                "per_page",
                                                "total",
                                                "last_page",
                                                "has_more"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "data",
                                        "meta"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 4821,
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "side": "buy",
                                            "type": "limit",
                                            "label": "Limit",
                                            "tif": "gtc",
                                            "qty": 100,
                                            "limit_price": 52.5,
                                            "stop_price": null,
                                            "status": "pending",
                                            "open": true,
                                            "reserved_amount": 5255,
                                            "filled_price": null,
                                            "fee": null,
                                            "reject_reason": null,
                                            "session_date": "2026-11-26",
                                            "placed_at": "2026-11-26T10:14:02+06:00",
                                            "filled_at": null
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 30,
                                        "total": 3,
                                        "last_page": 1,
                                        "has_more": false
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Pass `?status=open|history|all` (default `open`)."
            }
        },
        "/orders/{order}": {
            "get": {
                "operationId": "trading.showOrder",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "order",
                        "in": "path",
                        "required": true,
                        "description": "The order ID",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": []
                                },
                                "example": {
                                    "id": 4821,
                                    "code": "BRACBANK",
                                    "name": "BRAC Bank PLC",
                                    "side": "buy",
                                    "type": "limit",
                                    "label": "Limit",
                                    "tif": "gtc",
                                    "qty": 100,
                                    "limit_price": 52.5,
                                    "stop_price": null,
                                    "status": "pending",
                                    "open": true,
                                    "reserved_amount": 5255,
                                    "filled_price": null,
                                    "fee": null,
                                    "reject_reason": null,
                                    "session_date": "2026-11-26",
                                    "placed_at": "2026-11-26T10:14:02+06:00",
                                    "filled_at": null,
                                    "fills": []
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "One order, with any fills"
            },
            "delete": {
                "operationId": "trading.cancelOrder",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "order",
                        "in": "path",
                        "required": true,
                        "description": "The order ID",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Order cancelled"
                                        },
                                        "order": {
                                            "type": "array",
                                            "items": []
                                        },
                                        "account": {
                                            "type": "object",
                                            "properties": {
                                                "buying_power": {
                                                    "type": "number"
                                                },
                                                "cash": {
                                                    "type": "number"
                                                },
                                                "reserved": {
                                                    "type": "number"
                                                },
                                                "equity": {
                                                    "type": "number"
                                                },
                                                "total_pnl": {
                                                    "type": "number"
                                                },
                                                "total_pct": {
                                                    "type": "number"
                                                },
                                                "day_pnl": {
                                                    "type": "number"
                                                }
                                            },
                                            "required": [
                                                "buying_power",
                                                "cash",
                                                "reserved",
                                                "equity",
                                                "total_pnl",
                                                "total_pct",
                                                "day_pnl"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "message",
                                        "order",
                                        "account"
                                    ]
                                },
                                "example": {
                                    "message": "Order cancelled",
                                    "order": {
                                        "id": 4821,
                                        "code": "BRACBANK",
                                        "name": "BRAC Bank PLC",
                                        "side": "buy",
                                        "type": "limit",
                                        "label": "Limit",
                                        "tif": "gtc",
                                        "qty": 100,
                                        "limit_price": 52.5,
                                        "stop_price": null,
                                        "status": "pending",
                                        "open": true,
                                        "reserved_amount": 5255,
                                        "filled_price": null,
                                        "fee": null,
                                        "reject_reason": null,
                                        "session_date": "2026-11-26",
                                        "placed_at": "2026-11-26T10:14:02+06:00",
                                        "filled_at": null
                                    },
                                    "account": {
                                        "cash": 948745,
                                        "reserved": 5255,
                                        "buying_power": 943490,
                                        "holdings_value": 51200,
                                        "invested": 50000,
                                        "equity": 1000000,
                                        "starting_cash": 1000000,
                                        "total_pnl": 1200,
                                        "total_pct": 0.12,
                                        "unrealized": 1200,
                                        "realized": 0,
                                        "fees": 48,
                                        "day_pnl": 320
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Cancel a resting order",
                "description": "Only works while the order is still `pending`; reserved cash or shares are released back."
            }
        },
        "/trades": {
            "get": {
                "operationId": "trading.trades",
                "tags": [
                    "Trading"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "string"
                                            }
                                        },
                                        "meta": {
                                            "type": "object",
                                            "properties": {
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "per_page": {
                                                    "type": "integer"
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "last_page": {
                                                    "type": "integer"
                                                },
                                                "has_more": {
                                                    "type": "boolean"
                                                }
                                            },
                                            "required": [
                                                "page",
                                                "per_page",
                                                "total",
                                                "last_page",
                                                "has_more"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "data",
                                        "meta"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "id": 9001,
                                            "order_id": 4821,
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "side": "buy",
                                            "qty": 100,
                                            "price": 52.5,
                                            "fee": 21,
                                            "amount": 5271,
                                            "realized_pnl": null,
                                            "traded_at": "2026-11-26T10:14:05+06:00"
                                        }
                                    ],
                                    "meta": {
                                        "page": 1,
                                        "per_page": 30,
                                        "total": 1,
                                        "last_page": 1,
                                        "has_more": false
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Trade history (fills)"
            }
        },
        "/watchlist": {
            "get": {
                "operationId": "trading.watchlist",
                "tags": [
                    "Trading"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                },
                                "example": {
                                    "data": [
                                        {
                                            "code": "BRACBANK",
                                            "name": "BRAC Bank PLC",
                                            "company_name": "BRAC Bank PLC",
                                            "sector": "Bank",
                                            "category": "A",
                                            "board": "PUBLIC",
                                            "lot": 1,
                                            "tick": 0.1,
                                            "quote": {
                                                "ltp": 52.5,
                                                "ycp": 51.9,
                                                "change": 0.6,
                                                "pct": 1.16,
                                                "open": 52,
                                                "high": 53.1,
                                                "low": 51.8,
                                                "volume": 1250300,
                                                "value_mn": 65.7,
                                                "trades": 842,
                                                "lower": 49.3,
                                                "upper": 54.5,
                                                "updated_at": "2026-11-26T13:58:00+06:00"
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "My watchlist"
            }
        },
        "/watchlist/{stock}": {
            "post": {
                "operationId": "trading.toggleWatch",
                "summary": "Toggle a stock on the watchlist",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "watching": {
                                            "type": "boolean"
                                        },
                                        "rewards": {
                                            "anyOf": [
                                                {
                                                    "type": "string"
                                                },
                                                {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "minItems": 0,
                                                    "maxItems": 0
                                                }
                                            ]
                                        }
                                    },
                                    "required": [
                                        "watching",
                                        "rewards"
                                    ]
                                },
                                "example": {
                                    "watching": true,
                                    "rewards": []
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Adds it if missing, removes it if already there — one endpoint for both directions."
            },
            "delete": {
                "operationId": "trading.unwatch",
                "tags": [
                    "Trading"
                ],
                "parameters": [
                    {
                        "name": "stock",
                        "in": "path",
                        "required": true,
                        "description": "The stock code",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "watching": {
                                            "type": "boolean"
                                        }
                                    },
                                    "required": [
                                        "watching"
                                    ]
                                },
                                "example": {
                                    "watching": false
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/ModelNotFoundException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "summary": "Remove a stock from the watchlist"
            }
        },
        "/account/reset": {
            "post": {
                "operationId": "trading.resetAccount",
                "summary": "Reset the paper account",
                "tags": [
                    "Trading"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "password": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "password"
                                ]
                            },
                            "example": {
                                "password": "Str0ng!Passw0rd"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "const": "Account reset."
                                        },
                                        "account": {
                                            "type": "object",
                                            "properties": {
                                                "buying_power": {
                                                    "type": "number"
                                                },
                                                "cash": {
                                                    "type": "number"
                                                },
                                                "reserved": {
                                                    "type": "number"
                                                },
                                                "equity": {
                                                    "type": "number"
                                                },
                                                "total_pnl": {
                                                    "type": "number"
                                                },
                                                "total_pct": {
                                                    "type": "number"
                                                },
                                                "day_pnl": {
                                                    "type": "number"
                                                }
                                            },
                                            "required": [
                                                "buying_power",
                                                "cash",
                                                "reserved",
                                                "equity",
                                                "total_pnl",
                                                "total_pct",
                                                "day_pnl"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "message",
                                        "account"
                                    ]
                                },
                                "example": {
                                    "message": "Account reset.",
                                    "account": {
                                        "cash": 948745,
                                        "reserved": 5255,
                                        "buying_power": 943490,
                                        "holdings_value": 51200,
                                        "invested": 50000,
                                        "equity": 1000000,
                                        "starting_cash": 1000000,
                                        "total_pnl": 1200,
                                        "total_pct": 0.12,
                                        "unrealized": 1200,
                                        "realized": 0,
                                        "fees": 48,
                                        "day_pnl": 320
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    },
                    "401": {
                        "$ref": "#/components/responses/AuthenticationException"
                    }
                },
                "description": "Wipes all orders/trades/holdings and starts over with the default virtual cash. Requires the current password to confirm — this cannot be undone."
            }
        }
    },
    "components": {
        "securitySchemes": {
            "http": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "UserResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "verified": {
                        "type": "boolean"
                    },
                    "locale": {
                        "type": "string"
                    },
                    "joined_at": {
                        "type": "string"
                    }
                },
                "required": [
                    "id",
                    "name",
                    "email",
                    "verified",
                    "locale",
                    "joined_at"
                ],
                "title": "UserResource",
                "example": {
                    "id": 501,
                    "name": "Rafi Ahmed",
                    "email": "rafi@example.com",
                    "verified": true,
                    "locale": "en",
                    "joined_at": "2026-10-14T09:12:00+06:00"
                }
            }
        },
        "responses": {
            "ValidationException": {
                "description": "Validation error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Errors overview."
                                },
                                "errors": {
                                    "type": "object",
                                    "description": "A detailed description of each field that failed validation.",
                                    "additionalProperties": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "required": [
                                "message",
                                "errors"
                            ]
                        },
                        "example": {
                            "message": "The given data was invalid.",
                            "code": "validation_failed",
                            "errors": {
                                "qty": [
                                    "The qty field is required."
                                ]
                            }
                        }
                    }
                }
            },
            "AuthenticationException": {
                "description": "Unauthenticated",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Error overview."
                                }
                            },
                            "required": [
                                "message"
                            ]
                        },
                        "example": {
                            "message": "Please sign in again.",
                            "code": "unauthenticated"
                        }
                    }
                }
            },
            "ModelNotFoundException": {
                "description": "Not found",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Error overview."
                                }
                            },
                            "required": [
                                "message"
                            ]
                        },
                        "example": {
                            "message": "Not found.",
                            "code": "not_found"
                        }
                    }
                }
            }
        }
    }
}