# Subgraph

## Overview

Trading and other data is stored via The Graph. Query the subgraph using [GraphQL](https://thegraph.com/docs/en/querying/graphql-api/).

{% embed url="<https://subgraph.satsuma-prod.com/perp/lugia-optimism/playground>" %}

{% @github-files/github-code-block url="<https://github.com/perpetual-protocol/lugia-subgraph>" %}

## Examples

### `owedRealizedPnl`

Retrieve a trader's unrealized P\&L

```graphql
{
  traderProfiles(
    where: {
      trader:"0x6cf8aba4b2bc2cd9be2e78cf61ef617b02893502" // Lowercase only
      }
    )
  {
    owedRealizedPnl
    market {
      id
    }
  }
}
```
