UpshiftDocs
REST APIInstitutional API

Unrealized PnL

Mark-to-market profit and loss, latest and historical.

Get Unrealized Pnl

Returns unrealized PnL records for a given vault from MongoDB.

Args: vault_address: Vault contract address to query. db: MongoDB session dependency. limit: Optional max number of records to return (newest first). start_date: Optional inclusive lower bound on timestamp. end_date: Optional inclusive upper bound on timestamp. fields: "ratio" returns the slim CollateralRatioPoint shape via a Mongo projection (for the collateral-ratio chart); omitted returns the full UnrealizedPnLResponse. All new params are optional and backward-compatible with the existing full-record behaviour.

GET
/upshift/unrealized_pnl

Query Parameters

vault_addressVault Address
limit?Limit
start_date?Start Date
end_date?End Date
fields?Fields

Response Body

curl -X GET "https://api.upshift.finance/api/v1/upshift/unrealized_pnl?vault_address=string&limit=1&start_date=2019-08-24T14%3A15%3A22Z&end_date=2019-08-24T14%3A15%3A22Z&fields=ratio"
null
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}

Get All Latest Unrealized Pnl

Returns the latest unrealized PnL record per vault in a single query.

Sorts on {vault_address, timestamp desc} to align with the compound index, then groups by vault_address taking the first (newest) record. The index hint forces Mongo to use the compound index, turning this into an index scan (~0.7s) instead of a full collection scan + in-memory sort (>60s).

GET
/upshift/unrealized_pnl/latest

Response Body

curl -X GET "https://api.upshift.finance/api/v1/upshift/unrealized_pnl/latest"
[
  {
    "timestamp": "2019-08-24T14:15:22Z",
    "vault_name": "string",
    "vault_address": "string",
    "strategist_name": "string",
    "reference_asset": "string",
    "asset_price": 0,
    "tvl_on_vault": 0,
    "current_redeem_ratio": 0,
    "actual_tvl": 0,
    "adjusted_redeem_ratio": 0,
    "unrealized_pnl": 0,
    "unrealized_pnl_in_asset": 0
  }
]