> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/liquidity-provider-documentation/building-a-solver-on-symmio/5.-creating-the-apis/get-notional-cap.md).

# GET Notional Cap

### /notional\_cap

```json
/notional_cap/{symbol_id}
```

**Example Query:**

```
https://base-hedger82.rasa.capital/notional_cap/1
```

**Example Response:**

```json
{
  "total_cap": "2344336.83177192369792522000000000",
  "used": "17746.15500000000000000000000000"
}
```

#### **Data Source**

Values are configured and managed exclusively by the hedger. These caps are set per trading pair and reflect the hedger’s risk management strategy for individual assets.

## **Notional Cap Implementation (Rasa)**

### Router

```python
@common_router.get(
    '/notional_cap/{symbol_id}',
    responses={status.HTTP_200_OK: {"model": OpenInterestResponseSchema}},
    response_model=OpenInterestResponseSchema,
    dependencies=[
        Depends(CustomRateLimiter(times=1, seconds=1)),
        Depends(CustomRateLimiter(times=40, minutes=1)),
        Depends(CustomRateLimiter(times=1500, hours=1)),
    ]
)
@with_context_db_session
async def get_notional_cap(symbol_id: int):
    symbol_id_validator(symbol_id)
    total_cap, used = await OpenCapEngine.get_cap_and_used_amount_async(symbol_id, from_stats=True)
    apm.label(total_cap=total_cap, used=used)
    return {"total_cap": total_cap, "used": used}

```

### Logic

* Ensures the provided `symbol_id` exists and is well-formed; raises a 400/422 if not.
* Queries the hedger’s capacity engine for the per-symbol maximum notional cap and current usage.
* Emits metrics for monitoring and alerting.
* FastAPI serializes this to JSON matching `OpenInterestResponseSchema`:

```python
class OpenInterestResponseSchema(BaseModel):
    total_cap: Decimal
    used: Decimal
```

#### Steps to Implement Your Own Version

**Define the Response Schema**

```python
class OpenInterestResponseSchema(BaseModel):
    total_cap: Decimal
    used: Decimal
```

**Implement Symbol Validation**

* Write `symbol_id_validator(symbol_id: int)` that checks against your `Symbol` table or whitelist.

**Build The Capacity Engine**

* In `OpenCapEngine`, implement `get_cap_and_used_amount_async(symbol_id, from_stats=True)` to return `(Decimal total_cap, Decimal used)`, using:
  * **Per-symbol config** table for maximum caps.
  * **Positions** table to sum currently open notional on that symbol.

**Add the FastAPI Route**

* In your `common_router`, add the `GET /notional_cap/{symbol_id}` handler as shown, importing the schema, validator, and engine.
* Attach the same rate-limiting and `@with_context_db_session` decorators.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.symm.io/liquidity-provider-documentation/building-a-solver-on-symmio/5.-creating-the-apis/get-notional-cap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
