Positions
Get P&L
Realized and unrealized profit, rolled up to a level, with a firm total.
GET/pnlself-hosted · access token · view
Self-hosted. Served by synpath serve on your own machine or host, which must be running; the engine and its order types live there. Nothing on this page runs on Synpath's servers.
Unrealized profit needs a mark, which comes from fair values; a position without one reports unrealized: null, never a number it made up. marked counts how many positions had one.
Query parameters
| Name | Type | Description |
|---|---|---|
level | stringdefault book | market, book or account. |
Response
Rows per key at that level, and the total.
import os
import httpx
TOKEN = os.environ["SYNPATH_ACCESS_TOKEN"]
r = httpx.get("http://127.0.0.1:8000/trading/pnl", headers={"Authorization": f"Bearer {TOKEN}"})
r.raise_for_status()
print(r.json())200
{
"level": "book",
"rows": [
{
"key": "alpha",
"contracts": "2",
"cost": "0.20",
"realized": "0",
"unrealized": "0.02",
"fees": "0.0014",
"volume": "2",
"positions": 1,
"marked": 1
}
],
"total": {
"key": "*",
"contracts": "2",
"cost": "0.20",
"realized": "0",
"unrealized": "0.02",
"fees": "0.0014",
"volume": "2",
"positions": 1,
"marked": 1
}
}
