# Trade History

## Get all trade history

> Retrieve all trade history for the authenticated user with detailed trade information including fees, PnL, and asset-level data

```json
{"openapi":"3.0.0","info":{"title":"Pear Protocol Trading API","version":"1.0.0"},"servers":[{"url":"https://hl-v2.pearprotocol.io","description":"Production (Mainnet)"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"scheme":"bearer","bearerFormat":"JWT","type":"http"}},"schemas":{"TradeHistoryDataDto":{"type":"object","properties":{"tradeHistoryId":{"type":"string","description":"Trade history ID"},"positionId":{"type":"string","description":"Associated position ID"},"address":{"type":"string","description":"User wallet address"},"externalFeePaid":{"type":"number","description":"Total fee paid to DEX Engine"},"builderFeePaid":{"type":"number","description":"Total fee paid to builder"},"realizedPnl":{"type":"number","description":"Total realized PnL value"},"realizedPnlPercentage":{"type":"number","description":"Total realized PnL percentage"},"totalValue":{"type":"number","description":"Total trade value in USD"},"totalEntryValue":{"type":"number","description":"Total entry value in USD (sum of size * entry price per asset)"},"entryRatio":{"type":"number","description":"Entry ratio for the trade"},"exitRatio":{"type":"number","description":"Exit ratio for the trade"},"closedLongAssets":{"description":"Long assets in the trade","type":"array","items":{"$ref":"#/components/schemas/TradeHistoryAssetDataDto"}},"closedShortAssets":{"description":"Short assets in the trade","type":"array","items":{"$ref":"#/components/schemas/TradeHistoryAssetDataDto"}},"positionLongAssets":{"description":"List of long token symbols from position at time of trade","type":"array","items":{"type":"string"}},"positionShortAssets":{"description":"List of short token symbols from position at time of trade","type":"array","items":{"type":"string"}},"createdAt":{"type":"string","description":"Trade timestamp"}},"required":["tradeHistoryId","positionId","address","externalFeePaid","builderFeePaid","realizedPnl","realizedPnlPercentage","totalValue","totalEntryValue","entryRatio","exitRatio","closedLongAssets","createdAt"]},"TradeHistoryAssetDataDto":{"type":"object","properties":{"coin":{"type":"string","description":"Asset symbol"},"leverage":{"type":"number","description":"Leverage used for this asset"},"entryPrice":{"type":"number","description":"Entry price for this asset"},"entryWeight":{"type":"number","description":"Entry weight for this asset"},"limitPrice":{"type":"number","description":"Limit price for this asset"},"size":{"type":"number","description":"Trade size for this asset"},"externalFeePaid":{"type":"number","description":"Fee paid to DEX Engine"},"builderFeePaid":{"type":"number","description":"Fee paid to builder"},"realizedPnl":{"type":"number","description":"Realized PnL percentage for this asset"}},"required":["coin","leverage","entryPrice","entryWeight","limitPrice","size","externalFeePaid","builderFeePaid","realizedPnl"]}}},"paths":{"/trade-history":{"get":{"description":"Retrieve all trade history for the authenticated user with detailed trade information including fees, PnL, and asset-level data","operationId":"TradeHistoryController_getTradeHistory","parameters":[{"name":"limit","required":false,"in":"query","description":"Maximum number of records to return (maximum 100).","schema":{"type":"number"}},{"name":"startDate","required":false,"in":"query","description":"Filter trades created on/after this time. Accepts ISO string or ms timestamp.","schema":{"type":"string"}},{"name":"endDate","required":false,"in":"query","description":"Filter trades created on/before this time. Accepts ISO string or ms timestamp.","schema":{"type":"string"}}],"responses":{"200":{"description":"Trade history retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TradeHistoryDataDto"}}}}},"404":{"description":"No trade history found"}},"summary":"Get all trade history","tags":["Trade History"]}}}}
```


---

# Agent Instructions: 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:

```
GET https://docs.pearprotocol.io/api-integration/api-specification/trade-history.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
