Skip to content

Indexer Data

Grouped HTTP indexer data endpoints.

IndexerData dataclass

Bases: GetAssetPositions, GetCandlesPaged, GetComplianceScreen, GetFillsPaged, GetFundingPaymentsPaged, GetFundingPaymentsForParentSubaccount, GetHeight, GetHistoricalFundingPaged, GetHistoricalPnl, GetMarket, GetMegavaultHistoricalPnl, GetOrder, GetOrderBook, GetParentAssetPositions, GetParentFills, GetParentHistoricalPnl, GetParentSubaccount, GetParentTransfers, GetRewards, GetRewardsAggregated, GetScreen, GetSparklines, GetSubaccount, GetSubaccounts, GetTime, GetTrades, GetTransfersPaged, GetTransfersBetween, GetVaultsHistoricalPnl, ListOrders, ListParentOrders, ListParentPositions, GetOpenPosition

HTTP indexer data endpoint group.

Source code in pkg/src/dydx/indexer/data/__init__.py
@dataclass
class IndexerData(
  GetAssetPositions,
  GetCandlesPaged,
  GetComplianceScreen,
  GetFillsPaged,
  GetFundingPaymentsPaged,
  GetFundingPaymentsForParentSubaccount,
  GetHeight,
  GetHistoricalFundingPaged,
  GetHistoricalPnl,
  GetMarket,
  GetMegavaultHistoricalPnl,
  GetOrder,
  GetOrderBook,
  GetParentAssetPositions,
  GetParentFills,
  GetParentHistoricalPnl,
  GetParentSubaccount,
  GetParentTransfers,
  GetRewards,
  GetRewardsAggregated,
  GetScreen,
  GetSparklines,
  GetSubaccount,
  GetSubaccounts,
  GetTime,
  GetTrades,
  GetTransfersPaged,
  GetTransfersBetween,
  GetVaultsHistoricalPnl,
  ListOrders,
  ListParentOrders,
  ListParentPositions,
  GetOpenPosition,
):
  """HTTP indexer data endpoint group."""

dYdX indexer get asset positions types and endpoint.

AssetPosition

Bases: TypedDict

AssetPosition payload.

Source code in pkg/src/dydx/indexer/data/get_asset_positions.py
class AssetPosition(TypedDict):
  """AssetPosition payload."""
  size: Decimal
  symbol: str
  side: Literal['LONG', 'SHORT']
  assetId: str
  subaccountNumber: int

GetAssetPositions dataclass

Bases: IndexerMixin

Endpoint mixin for asset_positions.

Source code in pkg/src/dydx/indexer/data/get_asset_positions.py
@dataclass
class GetAssetPositions(IndexerMixin):
  """Endpoint mixin for asset_positions."""
  async def get_asset_positions(
    self,
    address: str,
    *,
    subaccount: int,
    status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    validate: bool | None = None
  ) -> list[AssetPosition]:
    """Get asset positions.

    Args:
      address: Wallet address that owns the account.
      subaccount: Subaccount number.
      status: Position status filter.
      limit: Maximum number of results to return.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Restrict results to entries created at or before a specific timestamp.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-asset-positions)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if status is not None:
      params['status'] = status
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    r = await self.request('GET', '/v4/assetPositions', params=params)
    return parse_response(r, validate=self.validate(validate))

get_asset_positions(address, *, subaccount, status=None, limit=None, created_before_or_at_height=None, created_before_or_at=None, validate=None) async

Get asset positions.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
subaccount int

Subaccount number.

required
status Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None

Position status filter.

None
limit int | None

Maximum number of results to return.

None
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Restrict results to entries created at or before a specific timestamp.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[AssetPosition]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_asset_positions.py
async def get_asset_positions(
  self,
  address: str,
  *,
  subaccount: int,
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> list[AssetPosition]:
  """Get asset positions.

  Args:
    address: Wallet address that owns the account.
    subaccount: Subaccount number.
    status: Position status filter.
    limit: Maximum number of results to return.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Restrict results to entries created at or before a specific timestamp.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-asset-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if status is not None:
    params['status'] = status
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/assetPositions', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get candles types and endpoint.

Candle

Bases: TypedDict

Candle payload.

Source code in pkg/src/dydx/indexer/data/get_candles.py
class Candle(TypedDict):
  """Candle payload."""
  startedAt: datetime
  ticker: str
  resolution: Literal['1MIN', '5MINS', '15MINS', '30MINS', '1HOUR', '4HOURS', '1DAY']
  low: Decimal
  high: Decimal
  open: Decimal
  close: Decimal
  baseTokenVolume: Decimal
  usdVolume: Decimal
  trades: int
  startingOpenInterest: Decimal
  orderbookMidPriceOpen: NotRequired[Decimal | None]
  orderbookMidPriceClose: NotRequired[Decimal | None]

CandlesResponse

Bases: TypedDict

Candles response payload.

Source code in pkg/src/dydx/indexer/data/get_candles.py
class CandlesResponse(TypedDict):
  """Candles response payload."""
  candles: list[Candle]

GetCandles dataclass

Bases: IndexerMixin

Endpoint mixin for candles.

Source code in pkg/src/dydx/indexer/data/get_candles.py
@dataclass
class GetCandles(IndexerMixin):
  """Endpoint mixin for candles."""
  async def get_candles(
    self,
    market: str,
    *,
    resolution: Literal[
      '1MIN', '5MINS', '15MINS', '30MINS', '1HOUR', '4HOURS', '1DAY'
    ],
    from_iso: datetime | None = None,
    to_iso: datetime | None = None,
    limit: int | None = None,
    validate: bool | None = None
  ) -> CandlesResponse:
    """Fetch candles for a perpetual market.

    Args:
      market: Perpetual market ticker.
      resolution: Candle resolution.
      from_iso: Start timestamp in ISO 8601 format.
      to_iso: End timestamp in ISO 8601 format.
      limit: Maximum number of candles to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-candles)
    """
    params: dict[str, object] = {
      'resolution': resolution,
    }
    if from_iso is not None:
      params['fromISO'] = ts.dump(from_iso)
    if to_iso is not None:
      params['toISO'] = ts.dump(to_iso)
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', f'/v4/candles/perpetualMarkets/{market}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_candles(market, *, resolution, from_iso=None, to_iso=None, limit=None, validate=None) async

Fetch candles for a perpetual market.

Parameters:

Name Type Description Default
market str

Perpetual market ticker.

required
resolution Literal['1MIN', '5MINS', '15MINS', '30MINS', '1HOUR', '4HOURS', '1DAY']

Candle resolution.

required
from_iso datetime | None

Start timestamp in ISO 8601 format.

None
to_iso datetime | None

End timestamp in ISO 8601 format.

None
limit int | None

Maximum number of candles to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
CandlesResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_candles.py
async def get_candles(
  self,
  market: str,
  *,
  resolution: Literal[
    '1MIN', '5MINS', '15MINS', '30MINS', '1HOUR', '4HOURS', '1DAY'
  ],
  from_iso: datetime | None = None,
  to_iso: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> CandlesResponse:
  """Fetch candles for a perpetual market.

  Args:
    market: Perpetual market ticker.
    resolution: Candle resolution.
    from_iso: Start timestamp in ISO 8601 format.
    to_iso: End timestamp in ISO 8601 format.
    limit: Maximum number of candles to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-candles)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  if from_iso is not None:
    params['fromISO'] = ts.dump(from_iso)
  if to_iso is not None:
    params['toISO'] = ts.dump(to_iso)
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/candles/perpetualMarkets/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

GetCandlesPaged dataclass

Bases: GetCandles

Endpoint mixin for candles_paged.

Source code in pkg/src/dydx/indexer/data/get_candles.py
@dataclass
class GetCandlesPaged(GetCandles):
  """Endpoint mixin for candles_paged."""
  async def get_candles_paged(
    self,
    market: str,
    resolution: Resolution,
    *,
    start: datetime | None = None,
    end: datetime | None = None,
    limit: int | None = None,
  ) -> AsyncIterable[Sequence[Candle]]:
    """Page through candles for a perpetual market.

    Args:
      market: The market ticker (e.g. `'BTC-USD'`).
      resolution: The resolution of the candles.
      start: If given, fetches candles starting from the given timestamp.
      end: If given, fetches candles up to and including the given timestamp.
      limit: The max. number of candles to retrieve per request (default: 1000, max: 1000).

    Returns:
      An async iterable of candle pages. Each request advances by the last candle timestamp until an empty page is returned.
    """
    last_time = end
    while True:
      response = await self.get_candles(
        market,
        resolution=resolution,
        from_iso=start,
        to_iso=last_time,
        limit=limit,
      )
      candles = response['candles']
      if not candles:
        break
      yield candles
      last_time = candles[-1]['startedAt']

get_candles_paged(market, resolution, *, start=None, end=None, limit=None) async

Page through candles for a perpetual market.

Parameters:

Name Type Description Default
market str

The market ticker (e.g. 'BTC-USD').

required
resolution Resolution

The resolution of the candles.

required
start datetime | None

If given, fetches candles starting from the given timestamp.

None
end datetime | None

If given, fetches candles up to and including the given timestamp.

None
limit int | None

The max. number of candles to retrieve per request (default: 1000, max: 1000).

None

Returns:

Type Description
AsyncIterable[Sequence[Candle]]

An async iterable of candle pages. Each request advances by the last candle timestamp until an empty page is returned.

Source code in pkg/src/dydx/indexer/data/get_candles.py
async def get_candles_paged(
  self,
  market: str,
  resolution: Resolution,
  *,
  start: datetime | None = None,
  end: datetime | None = None,
  limit: int | None = None,
) -> AsyncIterable[Sequence[Candle]]:
  """Page through candles for a perpetual market.

  Args:
    market: The market ticker (e.g. `'BTC-USD'`).
    resolution: The resolution of the candles.
    start: If given, fetches candles starting from the given timestamp.
    end: If given, fetches candles up to and including the given timestamp.
    limit: The max. number of candles to retrieve per request (default: 1000, max: 1000).

  Returns:
    An async iterable of candle pages. Each request advances by the last candle timestamp until an empty page is returned.
  """
  last_time = end
  while True:
    response = await self.get_candles(
      market,
      resolution=resolution,
      from_iso=start,
      to_iso=last_time,
      limit=limit,
    )
    candles = response['candles']
    if not candles:
      break
    yield candles
    last_time = candles[-1]['startedAt']

dYdX indexer get compliance screen types and endpoint.

ComplianceV2Response

Bases: TypedDict

Compliance v2 response payload.

Source code in pkg/src/dydx/indexer/data/get_compliance_screen.py
class ComplianceV2Response(TypedDict):
  """Compliance v2 response payload."""
  status: Literal['COMPLIANT', 'FIRST_STRIKE_CLOSE_ONLY', 'FIRST_STRIKE', 'CLOSE_ONLY', 'BLOCKED']
  reason: NotRequired[Literal['MANUAL', 'US_GEO', 'CA_GEO', 'GB_GEO', 'SANCTIONED_GEO', 'COMPLIANCE_PROVIDER'] | None]
  updatedAt: NotRequired[datetime | None]

GetComplianceScreen dataclass

Bases: IndexerMixin

Endpoint mixin for compliance_screen.

Source code in pkg/src/dydx/indexer/data/get_compliance_screen.py
@dataclass
class GetComplianceScreen(IndexerMixin):
  """Endpoint mixin for compliance_screen."""
  async def get_compliance_screen(
    self,
    address: str,
    validate: bool | None = None
  ) -> ComplianceV2Response:
    """Get compliance screen.

    Args:
      address: EVM or dYdX address.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-compliance-screen)
    """
    r = await self.request('GET', f'/v4/compliance/screen/{address}')
    return parse_response(r, validate=self.validate(validate))

get_compliance_screen(address, validate=None) async

Get compliance screen.

Parameters:

Name Type Description Default
address str

EVM or dYdX address.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
ComplianceV2Response

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_compliance_screen.py
async def get_compliance_screen(
  self,
  address: str,
  validate: bool | None = None
) -> ComplianceV2Response:
  """Get compliance screen.

  Args:
    address: EVM or dYdX address.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-compliance-screen)
  """
  r = await self.request('GET', f'/v4/compliance/screen/{address}')
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get markets types and endpoint.

GetMarkets dataclass

Bases: IndexerMixin

Endpoint mixin for markets.

Source code in pkg/src/dydx/indexer/data/get_markets.py
@dataclass
class GetMarkets(IndexerMixin):
  """Endpoint mixin for markets."""
  async def get_markets(
    self,
    *,
    market: str | None = None,
    limit: int | None = None,
    validate: bool | None = None
  ) -> GetMarketsResponse:
    """Fetch perpetual market metadata.

    Args:
      market: Specific market ticker to retrieve, for example `BTC-USD`.
      limit: Maximum number of market entries to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-markets)
    """
    params: dict[str, object] = {}
    if market is not None:
      params['market'] = market
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', '/v4/perpetualMarkets', params=params)
    return parse_response(r, validate=self.validate(validate))

get_markets(*, market=None, limit=None, validate=None) async

Fetch perpetual market metadata.

Parameters:

Name Type Description Default
market str | None

Specific market ticker to retrieve, for example BTC-USD.

None
limit int | None

Maximum number of market entries to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
GetMarketsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_markets.py
async def get_markets(
  self,
  *,
  market: str | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> GetMarketsResponse:
  """Fetch perpetual market metadata.

  Args:
    market: Specific market ticker to retrieve, for example `BTC-USD`.
    limit: Maximum number of market entries to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-markets)
  """
  params: dict[str, object] = {}
  if market is not None:
    params['market'] = market
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', '/v4/perpetualMarkets', params=params)
  return parse_response(r, validate=self.validate(validate))

GetMarketsResponse

Bases: TypedDict

Endpoint mixin for markets_response.

Source code in pkg/src/dydx/indexer/data/get_markets.py
class GetMarketsResponse(TypedDict):
  """Endpoint mixin for markets_response."""
  markets: dict[str, PerpetualMarket]

dYdX indexer get market types and endpoint.

GetMarket dataclass

Bases: GetMarkets

Endpoint mixin for market.

Source code in pkg/src/dydx/indexer/data/get_market.py
@dataclass
class GetMarket(GetMarkets):
  """Endpoint mixin for market."""
  async def get_market(
    self,
    market: str,
    *,
    validate: bool | None = None,
  ) -> PerpetualMarket:
    """Fetch one perpetual market by ticker.

    Args:
      market: Market ticker.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.
    """
    response = await self.get_markets(market=market, limit=1, validate=validate)
    return response['markets'][market] if 'markets' in response else response[market]

get_market(market, *, validate=None) async

Fetch one perpetual market by ticker.

Parameters:

Name Type Description Default
market str

Market ticker.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PerpetualMarket

The validated indexer response payload.

Source code in pkg/src/dydx/indexer/data/get_market.py
async def get_market(
  self,
  market: str,
  *,
  validate: bool | None = None,
) -> PerpetualMarket:
  """Fetch one perpetual market by ticker.

  Args:
    market: Market ticker.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.
  """
  response = await self.get_markets(market=market, limit=1, validate=validate)
  return response['markets'][market] if 'markets' in response else response[market]

dYdX indexer get fills types and endpoint.

Fill

Bases: TypedDict

Fill payload.

Source code in pkg/src/dydx/indexer/data/get_fills.py
class Fill(TypedDict):
  """Fill payload."""
  id: str
  side: Literal['BUY', 'SELL']
  liquidity: Literal['MAKER', 'TAKER']
  type: Literal['LIMIT', 'LIQUIDATED', 'LIQUIDATION', 'DELEVERAGED', 'OFFSETTING']
  market: str
  marketType: Literal['PERPETUAL', 'SPOT']
  price: Decimal
  size: Decimal
  fee: Decimal
  affiliateRevShare: Decimal
  createdAt: datetime
  createdAtHeight: str
  orderId: NotRequired[str | None]
  clientMetadata: NotRequired[str | None]
  subaccountNumber: int
  builderFee: NotRequired[Decimal | None]
  builderAddress: NotRequired[str | None]
  positionSizeBefore: NotRequired[Decimal | None]
  entryPriceBefore: NotRequired[Decimal | None]
  positionSideBefore: NotRequired[Literal['LONG', 'SHORT'] | None]

FillsResponse

Bases: TypedDict

Fills response payload.

Source code in pkg/src/dydx/indexer/data/get_fills.py
class FillsResponse(TypedDict):
  """Fills response payload."""
  fills: list[Fill]

GetFills dataclass

Bases: IndexerMixin

Endpoint mixin for fills.

Source code in pkg/src/dydx/indexer/data/get_fills.py
@dataclass
class GetFills(IndexerMixin):
  """Endpoint mixin for fills."""
  async def get_fills(
    self,
    address: str,
    *,
    subaccount: int,
    market: str | None = None,
    market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    limit: int | None = None,
    page: int | None = None,
    validate: bool | None = None
  ) -> FillsResponse:
    """Fetch fills for a subaccount.

    Args:
      address: Wallet address that owns the subaccount.
      subaccount: Subaccount number.
      market: Market ticker filter.
      market_type: Market type filter.
      created_before_or_at_height: Latest block height to include.
      created_before_or_at: Latest timestamp to include.
      limit: Maximum number of fills to return.
      page: Page number for paginated results.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if market is not None:
      params['market'] = market
    if market_type is not None:
      params['marketType'] = market_type
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    if limit is not None:
      params['limit'] = limit
    if page is not None:
      params['page'] = page
    r = await self.request('GET', '/v4/fills', params=params)
    return parse_response(r, validate=self.validate(validate))

get_fills(address, *, subaccount, market=None, market_type=None, created_before_or_at_height=None, created_before_or_at=None, limit=None, page=None, validate=None) async

Fetch fills for a subaccount.

Parameters:

Name Type Description Default
address str

Wallet address that owns the subaccount.

required
subaccount int

Subaccount number.

required
market str | None

Market ticker filter.

None
market_type Literal['PERPETUAL', 'SPOT'] | None

Market type filter.

None
created_before_or_at_height int | None

Latest block height to include.

None
created_before_or_at datetime | None

Latest timestamp to include.

None
limit int | None

Maximum number of fills to return.

None
page int | None

Page number for paginated results.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
FillsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_fills.py
async def get_fills(
  self,
  address: str,
  *,
  subaccount: int,
  market: str | None = None,
  market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FillsResponse:
  """Fetch fills for a subaccount.

  Args:
    address: Wallet address that owns the subaccount.
    subaccount: Subaccount number.
    market: Market ticker filter.
    market_type: Market type filter.
    created_before_or_at_height: Latest block height to include.
    created_before_or_at: Latest timestamp to include.
    limit: Maximum number of fills to return.
    page: Page number for paginated results.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if market is not None:
    params['market'] = market
  if market_type is not None:
    params['marketType'] = market_type
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fills', params=params)
  return parse_response(r, validate=self.validate(validate))

GetFillsPaged dataclass

Bases: GetFills

Endpoint mixin for fills_paged.

Source code in pkg/src/dydx/indexer/data/get_fills.py
@dataclass
class GetFillsPaged(GetFills):
  """Endpoint mixin for fills_paged."""
  def get_fills_paged(
    self, address: str, *,
    subaccount: int,
    market: str | None = None,
    market_type: MarketType | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    limit: int | None = None,
    validate: bool | None = None,
  ) -> PaginatedResponse[Fill, int]:
    """Page through fills for a subaccount.

    Args:
      address: The wallet address that owns the account.
      subaccount: The identifier for the specific subaccount within the wallet address.
      market: The market name (e.g. `'BTC-USD'`).
      market_type: The market type (`'PERPETUAL'` or `'SPOT'`). Must be provided if `market` is provided.
      created_before_or_at_height: If given, fetches fills up to and including the given block height.
      created_before_or_at: If given, fetches fills up to and including the given timestamp.
      limit: The max. number of fills to retrieve (default: 1000, max: 1000).
      validate: Override the client response validation default for this call.

    Returns:
      A paginated response. Each request advances by page number until the endpoint returns no items.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
    """
    async def next(page: int) -> tuple[list[Fill], int | None]:
      """Next.

      Args:
        page: Page number to request.
      """
      response = await self.get_fills(
        address,
        subaccount=subaccount,
        market=market,
        market_type=market_type,
        created_before_or_at_height=created_before_or_at_height,
        created_before_or_at=created_before_or_at,
        limit=limit,
        page=page,
        validate=validate,
      )
      fills = response['fills']
      next_page = page + 1 if fills else None
      return fills, next_page

    return PaginatedResponse(1, next)

get_fills_paged(address, *, subaccount, market=None, market_type=None, created_before_or_at_height=None, created_before_or_at=None, limit=None, validate=None)

Page through fills for a subaccount.

Parameters:

Name Type Description Default
address str

The wallet address that owns the account.

required
subaccount int

The identifier for the specific subaccount within the wallet address.

required
market str | None

The market name (e.g. 'BTC-USD').

None
market_type MarketType | None

The market type ('PERPETUAL' or 'SPOT'). Must be provided if market is provided.

None
created_before_or_at_height int | None

If given, fetches fills up to and including the given block height.

None
created_before_or_at datetime | None

If given, fetches fills up to and including the given timestamp.

None
limit int | None

The max. number of fills to retrieve (default: 1000, max: 1000).

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PaginatedResponse[Fill, int]

A paginated response. Each request advances by page number until the endpoint returns no items.

References
Source code in pkg/src/dydx/indexer/data/get_fills.py
def get_fills_paged(
  self, address: str, *,
  subaccount: int,
  market: str | None = None,
  market_type: MarketType | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> PaginatedResponse[Fill, int]:
  """Page through fills for a subaccount.

  Args:
    address: The wallet address that owns the account.
    subaccount: The identifier for the specific subaccount within the wallet address.
    market: The market name (e.g. `'BTC-USD'`).
    market_type: The market type (`'PERPETUAL'` or `'SPOT'`). Must be provided if `market` is provided.
    created_before_or_at_height: If given, fetches fills up to and including the given block height.
    created_before_or_at: If given, fetches fills up to and including the given timestamp.
    limit: The max. number of fills to retrieve (default: 1000, max: 1000).
    validate: Override the client response validation default for this call.

  Returns:
    A paginated response. Each request advances by page number until the endpoint returns no items.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
  """
  async def next(page: int) -> tuple[list[Fill], int | None]:
    """Next.

    Args:
      page: Page number to request.
    """
    response = await self.get_fills(
      address,
      subaccount=subaccount,
      market=market,
      market_type=market_type,
      created_before_or_at_height=created_before_or_at_height,
      created_before_or_at=created_before_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    fills = response['fills']
    next_page = page + 1 if fills else None
    return fills, next_page

  return PaginatedResponse(1, next)

dYdX indexer get funding payments types and endpoint.

FundingPayment

Bases: TypedDict

FundingPayment payload.

Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
class FundingPayment(TypedDict):
  """FundingPayment payload."""
  createdAt: datetime
  createdAtHeight: str
  perpetualId: str
  ticker: str
  oraclePrice: Decimal
  size: Decimal
  side: Literal['LONG', 'SHORT']
  rate: Decimal
  payment: Decimal
  subaccountNumber: str
  fundingIndex: Decimal

FundingPaymentsResponse

Bases: TypedDict

Funding payments response payload.

Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
class FundingPaymentsResponse(TypedDict):
  """Funding payments response payload."""
  fundingPayments: list[FundingPayment]

GetFundingPayments dataclass

Bases: IndexerMixin

Endpoint mixin for funding_payments.

Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
@dataclass
class GetFundingPayments(IndexerMixin):
  """Endpoint mixin for funding_payments."""
  async def get_funding_payments(
    self,
    address: str,
    *,
    subaccount: int,
    ticker: str | None = None,
    after_or_at: datetime | None = None,
    limit: int | None = None,
    page: int | None = None,
    validate: bool | None = None
  ) -> FundingPaymentsResponse:
    """Fetch funding payments for a subaccount.

    Args:
      address: Wallet address that owns the subaccount.
      subaccount: Subaccount number.
      ticker: Market ticker filter.
      after_or_at: Earliest timestamp to include.
      limit: Maximum number of funding payments to return.
      page: Page number for paginated results.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if ticker is not None:
      params['ticker'] = ticker
    if after_or_at is not None:
      params['afterOrAt'] = ts.dump(after_or_at)
    if limit is not None:
      params['limit'] = limit
    if page is not None:
      params['page'] = page
    r = await self.request('GET', '/v4/fundingPayments', params=params)
    return parse_response(r, validate=self.validate(validate))

get_funding_payments(address, *, subaccount, ticker=None, after_or_at=None, limit=None, page=None, validate=None) async

Fetch funding payments for a subaccount.

Parameters:

Name Type Description Default
address str

Wallet address that owns the subaccount.

required
subaccount int

Subaccount number.

required
ticker str | None

Market ticker filter.

None
after_or_at datetime | None

Earliest timestamp to include.

None
limit int | None

Maximum number of funding payments to return.

None
page int | None

Page number for paginated results.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
FundingPaymentsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
async def get_funding_payments(
  self,
  address: str,
  *,
  subaccount: int,
  ticker: str | None = None,
  after_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FundingPaymentsResponse:
  """Fetch funding payments for a subaccount.

  Args:
    address: Wallet address that owns the subaccount.
    subaccount: Subaccount number.
    ticker: Market ticker filter.
    after_or_at: Earliest timestamp to include.
    limit: Maximum number of funding payments to return.
    page: Page number for paginated results.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if ticker is not None:
    params['ticker'] = ticker
  if after_or_at is not None:
    params['afterOrAt'] = ts.dump(after_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fundingPayments', params=params)
  return parse_response(r, validate=self.validate(validate))

GetFundingPaymentsPaged dataclass

Bases: GetFundingPayments

Endpoint mixin for funding_payments_paged.

Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
@dataclass
class GetFundingPaymentsPaged(GetFundingPayments):
  """Endpoint mixin for funding_payments_paged."""
  def get_funding_payments_paged(
    self,
    address: str,
    *,
    subaccount: int,
    ticker: str | None = None,
    after_or_at: datetime | None = None,
    limit: int | None = None,
    validate: bool | None = None,
  ) -> PaginatedResponse[FundingPayment, int]:
    """Page through funding payments for a subaccount.

    Args:
      address: The wallet address that owns the account.
      subaccount: The identifier for the specific subaccount within the wallet address.
      ticker: The market ticker (e.g. `'BTC-USD'`).
      after_or_at: If given, fetches funding payments starting from the given timestamp.
      limit: The max. number of funding payments to retrieve.
      validate: Override the client response validation default for this call.

    Returns:
      A paginated response. Each request advances by page number until the endpoint returns no items.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
    """
    async def next(page: int) -> tuple[list[FundingPayment], int | None]:
      """Next.

      Args:
        page: Page number to request.
      """
      response = await self.get_funding_payments(
        address,
        subaccount=subaccount,
        ticker=ticker,
        after_or_at=after_or_at,
        limit=limit,
        page=page,
        validate=validate,
      )
      funding_payments = response['fundingPayments']
      next_page = page + 1 if funding_payments else None
      return funding_payments, next_page

    return PaginatedResponse(1, next)

get_funding_payments_paged(address, *, subaccount, ticker=None, after_or_at=None, limit=None, validate=None)

Page through funding payments for a subaccount.

Parameters:

Name Type Description Default
address str

The wallet address that owns the account.

required
subaccount int

The identifier for the specific subaccount within the wallet address.

required
ticker str | None

The market ticker (e.g. 'BTC-USD').

None
after_or_at datetime | None

If given, fetches funding payments starting from the given timestamp.

None
limit int | None

The max. number of funding payments to retrieve.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PaginatedResponse[FundingPayment, int]

A paginated response. Each request advances by page number until the endpoint returns no items.

References
Source code in pkg/src/dydx/indexer/data/get_funding_payments.py
def get_funding_payments_paged(
  self,
  address: str,
  *,
  subaccount: int,
  ticker: str | None = None,
  after_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> PaginatedResponse[FundingPayment, int]:
  """Page through funding payments for a subaccount.

  Args:
    address: The wallet address that owns the account.
    subaccount: The identifier for the specific subaccount within the wallet address.
    ticker: The market ticker (e.g. `'BTC-USD'`).
    after_or_at: If given, fetches funding payments starting from the given timestamp.
    limit: The max. number of funding payments to retrieve.
    validate: Override the client response validation default for this call.

  Returns:
    A paginated response. Each request advances by page number until the endpoint returns no items.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
  """
  async def next(page: int) -> tuple[list[FundingPayment], int | None]:
    """Next.

    Args:
      page: Page number to request.
    """
    response = await self.get_funding_payments(
      address,
      subaccount=subaccount,
      ticker=ticker,
      after_or_at=after_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    funding_payments = response['fundingPayments']
    next_page = page + 1 if funding_payments else None
    return funding_payments, next_page

  return PaginatedResponse(1, next)

dYdX indexer get funding payments for parent subaccount types and endpoint.

FundingPayment

Bases: TypedDict

FundingPayment payload.

Source code in pkg/src/dydx/indexer/data/get_funding_payments_for_parent_subaccount.py
class FundingPayment(TypedDict):
  """FundingPayment payload."""
  createdAt: datetime
  createdAtHeight: str
  perpetualId: str
  ticker: str
  oraclePrice: Decimal
  size: Decimal
  side: Literal['LONG', 'SHORT']
  rate: Decimal
  payment: Decimal
  subaccountNumber: str
  fundingIndex: Decimal

FundingPaymentsResponse

Bases: TypedDict

Funding payments response payload.

Source code in pkg/src/dydx/indexer/data/get_funding_payments_for_parent_subaccount.py
class FundingPaymentsResponse(TypedDict):
  """Funding payments response payload."""
  fundingPayments: list[FundingPayment]

GetFundingPaymentsForParentSubaccount dataclass

Bases: IndexerMixin

Endpoint mixin for funding_payments_for_parent_subaccount.

Source code in pkg/src/dydx/indexer/data/get_funding_payments_for_parent_subaccount.py
@dataclass
class GetFundingPaymentsForParentSubaccount(IndexerMixin):
  """Endpoint mixin for funding_payments_for_parent_subaccount."""
  async def get_funding_payments_for_parent_subaccount(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    after_or_at: datetime | None = None,
    page: int | None = None,
    validate: bool | None = None
  ) -> FundingPaymentsResponse:
    """Get funding payments for parent subaccount.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      after_or_at: Only include payments created at or after this timestamp.
      page: Page number for paginated results.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-funding-payments-for-parent-subaccount)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if after_or_at is not None:
      params['afterOrAt'] = ts.dump(after_or_at)
    if page is not None:
      params['page'] = page
    r = await self.request('GET', '/v4/fundingPayments/parentSubaccount', params=params)
    return parse_response(r, validate=self.validate(validate))

get_funding_payments_for_parent_subaccount(address, *, parent_subaccount, limit=None, after_or_at=None, page=None, validate=None) async

Get funding payments for parent subaccount.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
after_or_at datetime | None

Only include payments created at or after this timestamp.

None
page int | None

Page number for paginated results.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
FundingPaymentsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_funding_payments_for_parent_subaccount.py
async def get_funding_payments_for_parent_subaccount(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  after_or_at: datetime | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FundingPaymentsResponse:
  """Get funding payments for parent subaccount.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    after_or_at: Only include payments created at or after this timestamp.
    page: Page number for paginated results.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-funding-payments-for-parent-subaccount)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if after_or_at is not None:
    params['afterOrAt'] = ts.dump(after_or_at)
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fundingPayments/parentSubaccount', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get height types and endpoint.

GetHeight dataclass

Bases: IndexerMixin

Endpoint mixin for height.

Source code in pkg/src/dydx/indexer/data/get_height.py
@dataclass
class GetHeight(IndexerMixin):
  """Endpoint mixin for height."""
  async def get_height(
    self,
    validate: bool | None = None
  ) -> HeightResponse:
    """Fetch the latest indexer block height.

    Args:
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-height)
    """
    r = await self.request('GET', '/v4/height')
    return parse_response(r, validate=self.validate(validate))

get_height(validate=None) async

Fetch the latest indexer block height.

Parameters:

Name Type Description Default
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
HeightResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_height.py
async def get_height(
  self,
  validate: bool | None = None
) -> HeightResponse:
  """Fetch the latest indexer block height.

  Args:
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-height)
  """
  r = await self.request('GET', '/v4/height')
  return parse_response(r, validate=self.validate(validate))

HeightResponse

Bases: TypedDict

Height response payload.

Source code in pkg/src/dydx/indexer/data/get_height.py
class HeightResponse(TypedDict):
  """Height response payload."""
  height: str
  time: datetime

dYdX indexer get historical funding types and endpoint.

Funding

Bases: TypedDict

Funding payload.

Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
class Funding(TypedDict):
  """Funding payload."""
  ticker: str
  rate: Decimal
  price: Decimal
  effectiveAt: datetime
  effectiveAtHeight: str

GetHistoricalFunding dataclass

Bases: IndexerMixin

Endpoint mixin for historical_funding.

Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
@dataclass
class GetHistoricalFunding(IndexerMixin):
  """Endpoint mixin for historical_funding."""
  async def get_historical_funding(
    self,
    market: str,
    *,
    effective_before_or_at: datetime | None = None,
    effective_before_or_at_height: int | None = None,
    limit: int | None = None,
    validate: bool | None = None
  ) -> HistoricalFundingResponse:
    """Fetch historical funding rates for a market.

    Args:
      market: Perpetual market ticker.
      effective_before_or_at: Latest effective timestamp to include.
      effective_before_or_at_height: Latest effective block height to include.
      limit: Maximum number of funding entries to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-historical-funding)
    """
    params: dict[str, object] = {}
    if effective_before_or_at is not None:
      params['effectiveBeforeOrAt'] = ts.dump(effective_before_or_at)
    if effective_before_or_at_height is not None:
      params['effectiveBeforeOrAtHeight'] = effective_before_or_at_height
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', f'/v4/historicalFunding/{market}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_historical_funding(market, *, effective_before_or_at=None, effective_before_or_at_height=None, limit=None, validate=None) async

Fetch historical funding rates for a market.

Parameters:

Name Type Description Default
market str

Perpetual market ticker.

required
effective_before_or_at datetime | None

Latest effective timestamp to include.

None
effective_before_or_at_height int | None

Latest effective block height to include.

None
limit int | None

Maximum number of funding entries to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
HistoricalFundingResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
async def get_historical_funding(
  self,
  market: str,
  *,
  effective_before_or_at: datetime | None = None,
  effective_before_or_at_height: int | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> HistoricalFundingResponse:
  """Fetch historical funding rates for a market.

  Args:
    market: Perpetual market ticker.
    effective_before_or_at: Latest effective timestamp to include.
    effective_before_or_at_height: Latest effective block height to include.
    limit: Maximum number of funding entries to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-historical-funding)
  """
  params: dict[str, object] = {}
  if effective_before_or_at is not None:
    params['effectiveBeforeOrAt'] = ts.dump(effective_before_or_at)
  if effective_before_or_at_height is not None:
    params['effectiveBeforeOrAtHeight'] = effective_before_or_at_height
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/historicalFunding/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

GetHistoricalFundingPaged dataclass

Bases: GetHistoricalFunding

Endpoint mixin for historical_funding_paged.

Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
@dataclass
class GetHistoricalFundingPaged(GetHistoricalFunding):
  """Endpoint mixin for historical_funding_paged."""
  def get_historical_funding_paged(
    self,
    market: str,
    *,
    effective_before_or_at: datetime | None = None,
    effective_before_or_at_height: int | None = None,
    limit: int | None = None,
  ) -> PaginatedResponse[Funding, int]:
    """Page through historical funding rates for a market.

    Args:
      market: The market ticker (e.g. `'BTC-USD'`).
      effective_before_or_at: If given, fetches funding rates up to and including the given timestamp.
      effective_before_or_at_height: If given, fetches funding rates up to and including the given block height.
      limit: The max. number of candles to retrieve (default: 1000, max: 1000).

    Returns:
      A paginated response. Each request advances by the last returned funding block height until no newer page is available.
    """
    last_block = effective_before_or_at_height or -1
    async def next(last_block: int | None) -> tuple[list[Funding], int | None]:
      """Next.

      Args:
        last_block: Last block.
      """
      if last_block == -1:
        last_block = None
      response = await self.get_historical_funding(
        market,
        effective_before_or_at=effective_before_or_at,
        effective_before_or_at_height=last_block,
        limit=limit,
      )
      historical_funding = response['historicalFunding']
      if not historical_funding:
        return [], None
      else:
        new_last_block = int(historical_funding[-1]['effectiveAtHeight'])
        if new_last_block == last_block:
          return [], None

      return historical_funding, new_last_block

    return PaginatedResponse(last_block, next)

get_historical_funding_paged(market, *, effective_before_or_at=None, effective_before_or_at_height=None, limit=None)

Page through historical funding rates for a market.

Parameters:

Name Type Description Default
market str

The market ticker (e.g. 'BTC-USD').

required
effective_before_or_at datetime | None

If given, fetches funding rates up to and including the given timestamp.

None
effective_before_or_at_height int | None

If given, fetches funding rates up to and including the given block height.

None
limit int | None

The max. number of candles to retrieve (default: 1000, max: 1000).

None

Returns:

Type Description
PaginatedResponse[Funding, int]

A paginated response. Each request advances by the last returned funding block height until no newer page is available.

Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
def get_historical_funding_paged(
  self,
  market: str,
  *,
  effective_before_or_at: datetime | None = None,
  effective_before_or_at_height: int | None = None,
  limit: int | None = None,
) -> PaginatedResponse[Funding, int]:
  """Page through historical funding rates for a market.

  Args:
    market: The market ticker (e.g. `'BTC-USD'`).
    effective_before_or_at: If given, fetches funding rates up to and including the given timestamp.
    effective_before_or_at_height: If given, fetches funding rates up to and including the given block height.
    limit: The max. number of candles to retrieve (default: 1000, max: 1000).

  Returns:
    A paginated response. Each request advances by the last returned funding block height until no newer page is available.
  """
  last_block = effective_before_or_at_height or -1
  async def next(last_block: int | None) -> tuple[list[Funding], int | None]:
    """Next.

    Args:
      last_block: Last block.
    """
    if last_block == -1:
      last_block = None
    response = await self.get_historical_funding(
      market,
      effective_before_or_at=effective_before_or_at,
      effective_before_or_at_height=last_block,
      limit=limit,
    )
    historical_funding = response['historicalFunding']
    if not historical_funding:
      return [], None
    else:
      new_last_block = int(historical_funding[-1]['effectiveAtHeight'])
      if new_last_block == last_block:
        return [], None

    return historical_funding, new_last_block

  return PaginatedResponse(last_block, next)

HistoricalFundingResponse

Bases: TypedDict

Historical funding response payload.

Source code in pkg/src/dydx/indexer/data/get_historical_funding.py
class HistoricalFundingResponse(TypedDict):
  """Historical funding response payload."""
  historicalFunding: list[Funding]

dYdX indexer get historical pnl types and endpoint.

GetHistoricalPnl dataclass

Bases: IndexerMixin

Endpoint mixin for historical_pnl.

Source code in pkg/src/dydx/indexer/data/get_historical_pnl.py
@dataclass
class GetHistoricalPnl(IndexerMixin):
  """Endpoint mixin for historical_pnl."""
  async def get_historical_pnl(
    self,
    address: str,
    *,
    subaccount: int,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    created_on_or_after_height: int | None = None,
    created_on_or_after: datetime | None = None,
    page: int | None = None,
    validate: bool | None = None
  ) -> list[PnlTick]:
    """Get historical pnl.

    Args:
      address: Wallet address that owns the account.
      subaccount: Subaccount number.
      limit: Maximum number of results to return.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Restrict results to entries created at or before a specific timestamp.
      created_on_or_after_height: Restrict results to entries created on or after a specific block height.
      created_on_or_after: Restrict results to entries created on or after a specific timestamp.
      page: Page number for paginated results.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-historical-pnl)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    if created_on_or_after_height is not None:
      params['createdOnOrAfterHeight'] = created_on_or_after_height
    if created_on_or_after is not None:
      params['createdOnOrAfter'] = ts.dump(created_on_or_after)
    if page is not None:
      params['page'] = page
    r = await self.request('GET', '/v4/historical-pnl', params=params)
    return parse_response(r, validate=self.validate(validate))

get_historical_pnl(address, *, subaccount, limit=None, created_before_or_at_height=None, created_before_or_at=None, created_on_or_after_height=None, created_on_or_after=None, page=None, validate=None) async

Get historical pnl.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
subaccount int

Subaccount number.

required
limit int | None

Maximum number of results to return.

None
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Restrict results to entries created at or before a specific timestamp.

None
created_on_or_after_height int | None

Restrict results to entries created on or after a specific block height.

None
created_on_or_after datetime | None

Restrict results to entries created on or after a specific timestamp.

None
page int | None

Page number for paginated results.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[PnlTick]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_historical_pnl.py
async def get_historical_pnl(
  self,
  address: str,
  *,
  subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  created_on_or_after_height: int | None = None,
  created_on_or_after: datetime | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> list[PnlTick]:
  """Get historical pnl.

  Args:
    address: Wallet address that owns the account.
    subaccount: Subaccount number.
    limit: Maximum number of results to return.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Restrict results to entries created at or before a specific timestamp.
    created_on_or_after_height: Restrict results to entries created on or after a specific block height.
    created_on_or_after: Restrict results to entries created on or after a specific timestamp.
    page: Page number for paginated results.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-historical-pnl)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if created_on_or_after_height is not None:
    params['createdOnOrAfterHeight'] = created_on_or_after_height
  if created_on_or_after is not None:
    params['createdOnOrAfter'] = ts.dump(created_on_or_after)
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/historical-pnl', params=params)
  return parse_response(r, validate=self.validate(validate))

PnlTick

Bases: TypedDict

PnL tick payload.

Source code in pkg/src/dydx/indexer/data/get_historical_pnl.py
class PnlTick(TypedDict):
  """PnL tick payload."""
  blockHeight: str
  blockTime: datetime
  createdAt: datetime
  equity: Decimal
  totalPnl: Decimal
  netTransfer: Decimal

dYdX indexer get megavault historical pnl types and endpoint.

GetMegavaultHistoricalPnl dataclass

Bases: IndexerMixin

Endpoint mixin for megavault_historical_pnl.

Source code in pkg/src/dydx/indexer/data/get_megavault_historical_pnl.py
@dataclass
class GetMegavaultHistoricalPnl(IndexerMixin):
  """Endpoint mixin for megavault_historical_pnl."""
  async def get_megavault_historical_pnl(
    self,
    *,
    resolution: Literal['hour', 'day'],
    validate: bool | None = None
  ) -> list[PnlTick]:
    """Get megavault historical pnl.

    Args:
      resolution: PnL tick resolution.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-megavault-historical-pnl)
    """
    params: dict[str, object] = {
      'resolution': resolution,
    }
    r = await self.request('GET', '/v4/vault/v1/megavault/historicalPnl', params=params)
    return parse_response(r, validate=self.validate(validate))

get_megavault_historical_pnl(*, resolution, validate=None) async

Get megavault historical pnl.

Parameters:

Name Type Description Default
resolution Literal['hour', 'day']

PnL tick resolution.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[PnlTick]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_megavault_historical_pnl.py
async def get_megavault_historical_pnl(
  self,
  *,
  resolution: Literal['hour', 'day'],
  validate: bool | None = None
) -> list[PnlTick]:
  """Get megavault historical pnl.

  Args:
    resolution: PnL tick resolution.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-megavault-historical-pnl)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  r = await self.request('GET', '/v4/vault/v1/megavault/historicalPnl', params=params)
  return parse_response(r, validate=self.validate(validate))

PnlTick

Bases: TypedDict

PnL tick payload.

Source code in pkg/src/dydx/indexer/data/get_megavault_historical_pnl.py
class PnlTick(TypedDict):
  """PnL tick payload."""
  blockHeight: str
  blockTime: datetime
  createdAt: datetime
  equity: Decimal
  totalPnl: Decimal
  netTransfer: Decimal

dYdX indexer get open position types and endpoint.

GetOpenPosition dataclass

Bases: ListPositions

Endpoint mixin for open_position.

Source code in pkg/src/dydx/indexer/data/get_open_position.py
@dataclass
class GetOpenPosition(ListPositions):
  """Endpoint mixin for open_position."""
  async def get_open_position(
    self,
    address: str,
    market: str,
    *,
    subaccount: int,
    validate: bool | None = None,
  ) -> PerpetualPosition | None:
    """Fetch one open perpetual position for a subaccount.

    Args:
      address: Wallet address.
      market: Market ticker.
      subaccount: Subaccount number.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.
    """
    response = await self.list_positions(
      address,
      subaccount=subaccount,
      status='OPEN',
      validate=validate,
    )
    positions = response['positions']
    for position in positions:
      if position['market'] == market:
        return position
    return None

get_open_position(address, market, *, subaccount, validate=None) async

Fetch one open perpetual position for a subaccount.

Parameters:

Name Type Description Default
address str

Wallet address.

required
market str

Market ticker.

required
subaccount int

Subaccount number.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PerpetualPosition | None

The validated indexer response payload.

Source code in pkg/src/dydx/indexer/data/get_open_position.py
async def get_open_position(
  self,
  address: str,
  market: str,
  *,
  subaccount: int,
  validate: bool | None = None,
) -> PerpetualPosition | None:
  """Fetch one open perpetual position for a subaccount.

  Args:
    address: Wallet address.
    market: Market ticker.
    subaccount: Subaccount number.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.
  """
  response = await self.list_positions(
    address,
    subaccount=subaccount,
    status='OPEN',
    validate=validate,
  )
  positions = response['positions']
  for position in positions:
    if position['market'] == market:
      return position
  return None

dYdX indexer get order types and endpoint.

GetOrder dataclass

Bases: IndexerMixin

Endpoint mixin for order.

Source code in pkg/src/dydx/indexer/data/get_order.py
@dataclass
class GetOrder(IndexerMixin):
  """Endpoint mixin for order."""
  async def get_order(
    self,
    order_id: str,
    validate: bool | None = None
  ) -> Order:
    """Get order.

    Args:
      order_id: Order id.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-order)
    """
    r = await self.request('GET', f'/v4/orders/{order_id}')
    return parse_response(r, validate=self.validate(validate))

get_order(order_id, validate=None) async

Get order.

Parameters:

Name Type Description Default
order_id str

Order id.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
Order

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_order.py
async def get_order(
  self,
  order_id: str,
  validate: bool | None = None
) -> Order:
  """Get order.

  Args:
    order_id: Order id.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-order)
  """
  r = await self.request('GET', f'/v4/orders/{order_id}')
  return parse_response(r, validate=self.validate(validate))

Order

Bases: TypedDict

Order payload.

Source code in pkg/src/dydx/indexer/data/get_order.py
class Order(TypedDict):
  """Order payload."""
  id: str
  subaccountId: str
  clientId: str
  clobPairId: str
  side: Literal['BUY', 'SELL']
  size: Decimal
  totalFilled: Decimal
  price: Decimal
  type: Literal['LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER']
  status: Literal['OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING']
  timeInForce: Literal['GTT', 'IOC', 'FOK']
  reduceOnly: NotRequired[bool | None]
  orderFlags: str
  goodTilBlock: NotRequired[str | None]
  goodTilBlockTime: NotRequired[datetime | None]
  createdAtHeight: NotRequired[str | None]
  clientMetadata: NotRequired[str | None]
  triggerPrice: NotRequired[Decimal | None]
  postOnly: NotRequired[bool | None]
  ticker: str
  updatedAt: NotRequired[datetime | None]
  updatedAtHeight: NotRequired[str | None]
  subaccountNumber: int
  orderRouterAddress: NotRequired[str|None]
  builderFee: NotRequired[Decimal | None]
  feePpm: NotRequired[Decimal | None]

dYdX indexer get order book types and endpoint.

BookEntry

Bases: TypedDict

BookEntry payload.

Source code in pkg/src/dydx/indexer/data/get_order_book.py
class BookEntry(TypedDict):
  """BookEntry payload."""
  price: Decimal
  size: Decimal

GetOrderBook dataclass

Bases: IndexerMixin

Endpoint mixin for order_book.

Source code in pkg/src/dydx/indexer/data/get_order_book.py
@dataclass
class GetOrderBook(IndexerMixin):
  """Endpoint mixin for order_book."""
  async def get_order_book(
    self,
    market: str,
    validate: bool | None = None
  ) -> OrderBook:
    """Get order book.

    Args:
      market: Perpetual market ticker.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-market-orderbook)
    """
    r = await self.request('GET', f'/v4/orderbooks/perpetualMarket/{market}')
    return parse_response(r, validate=self.validate(validate))

get_order_book(market, validate=None) async

Get order book.

Parameters:

Name Type Description Default
market str

Perpetual market ticker.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
OrderBook

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_order_book.py
async def get_order_book(
  self,
  market: str,
  validate: bool | None = None
) -> OrderBook:
  """Get order book.

  Args:
    market: Perpetual market ticker.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-market-orderbook)
  """
  r = await self.request('GET', f'/v4/orderbooks/perpetualMarket/{market}')
  return parse_response(r, validate=self.validate(validate))

OrderBook

Bases: TypedDict

OrderBook payload.

Source code in pkg/src/dydx/indexer/data/get_order_book.py
class OrderBook(TypedDict):
  """OrderBook payload."""
  bids: list[BookEntry]
  asks: list[BookEntry]

dYdX indexer get parent asset positions types and endpoint.

AssetPosition

Bases: TypedDict

AssetPosition payload.

Source code in pkg/src/dydx/indexer/data/get_parent_asset_positions.py
class AssetPosition(TypedDict):
  """AssetPosition payload."""
  size: Decimal
  symbol: str
  side: Literal['LONG', 'SHORT']
  assetId: str
  subaccountNumber: int

GetParentAssetPositions dataclass

Bases: IndexerMixin

Endpoint mixin for parent_asset_positions.

Source code in pkg/src/dydx/indexer/data/get_parent_asset_positions.py
@dataclass
class GetParentAssetPositions(IndexerMixin):
  """Endpoint mixin for parent_asset_positions."""
  async def get_parent_asset_positions(
    self,
    address: str,
    *,
    parent_subaccount: int,
    validate: bool | None = None
  ) -> list[AssetPosition]:
    """Get parent asset positions.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-asset-positions)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    r = await self.request('GET', '/v4/assetPositions/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))

get_parent_asset_positions(address, *, parent_subaccount, validate=None) async

Get parent asset positions.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[AssetPosition]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_parent_asset_positions.py
async def get_parent_asset_positions(
  self,
  address: str,
  *,
  parent_subaccount: int,
  validate: bool | None = None
) -> list[AssetPosition]:
  """Get parent asset positions.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-asset-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  r = await self.request('GET', '/v4/assetPositions/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get parent fills types and endpoint.

Fill

Bases: TypedDict

Fill payload.

Source code in pkg/src/dydx/indexer/data/get_parent_fills.py
class Fill(TypedDict):
  """Fill payload."""
  id: str
  side: Literal['BUY', 'SELL']
  liquidity: Literal['MAKER', 'TAKER']
  type: Literal['LIMIT', 'LIQUIDATED', 'LIQUIDATION', 'DELEVERAGED', 'OFFSETTING']
  market: str
  marketType: Literal['PERPETUAL', 'SPOT']
  price: Decimal
  size: Decimal
  fee: Decimal
  affiliateRevShare: Decimal
  createdAt: datetime
  createdAtHeight: str
  orderId: NotRequired[str | None]
  clientMetadata: NotRequired[str | None]
  subaccountNumber: int
  builderFee: NotRequired[Decimal | None]
  builderAddress: NotRequired[str | None]
  positionSizeBefore: NotRequired[Decimal | None]
  entryPriceBefore: NotRequired[Decimal | None]
  positionSideBefore: NotRequired[Literal['LONG', 'SHORT'] | None]

FillsResponse

Bases: TypedDict

Fills response payload.

Source code in pkg/src/dydx/indexer/data/get_parent_fills.py
class FillsResponse(TypedDict):
  """Fills response payload."""
  fills: list[Fill]

GetParentFills dataclass

Bases: IndexerMixin

Endpoint mixin for parent_fills.

Source code in pkg/src/dydx/indexer/data/get_parent_fills.py
@dataclass
class GetParentFills(IndexerMixin):
  """Endpoint mixin for parent_fills."""
  async def get_parent_fills(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    market: str | None = None,
    market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
    validate: bool | None = None
  ) -> FillsResponse:
    """Get parent fills.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Latest timestamp to include.
      market: Ticker filter.
      market_type: Market type filter.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-fills)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    if market is not None:
      params['market'] = market
    if market_type is not None:
      params['marketType'] = market_type
    r = await self.request('GET', '/v4/fills/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))

get_parent_fills(address, *, parent_subaccount, limit=None, created_before_or_at_height=None, created_before_or_at=None, market=None, market_type=None, validate=None) async

Get parent fills.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Latest timestamp to include.

None
market str | None

Ticker filter.

None
market_type Literal['PERPETUAL', 'SPOT'] | None

Market type filter.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
FillsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_parent_fills.py
async def get_parent_fills(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  market: str | None = None,
  market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
  validate: bool | None = None
) -> FillsResponse:
  """Get parent fills.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Latest timestamp to include.
    market: Ticker filter.
    market_type: Market type filter.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-fills)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if market is not None:
    params['market'] = market
  if market_type is not None:
    params['marketType'] = market_type
  r = await self.request('GET', '/v4/fills/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get parent historical pnl types and endpoint.

GetParentHistoricalPnl dataclass

Bases: IndexerMixin

Endpoint mixin for parent_historical_pnl.

Source code in pkg/src/dydx/indexer/data/get_parent_historical_pnl.py
@dataclass
class GetParentHistoricalPnl(IndexerMixin):
  """Endpoint mixin for parent_historical_pnl."""
  async def get_parent_historical_pnl(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    created_on_or_after_height: int | None = None,
    created_on_or_after: datetime | None = None,
    validate: bool | None = None
  ) -> list[PnlTick]:
    """Get parent historical pnl.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Restrict results to entries created at or before a specific timestamp.
      created_on_or_after_height: Restrict results to entries created on or after a specific block height.
      created_on_or_after: Restrict results to entries created on or after a specific timestamp.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-historical-pnl)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    if created_on_or_after_height is not None:
      params['createdOnOrAfterHeight'] = created_on_or_after_height
    if created_on_or_after is not None:
      params['createdOnOrAfter'] = ts.dump(created_on_or_after)
    r = await self.request('GET', '/v4/historical-pnl/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))

get_parent_historical_pnl(address, *, parent_subaccount, limit=None, created_before_or_at_height=None, created_before_or_at=None, created_on_or_after_height=None, created_on_or_after=None, validate=None) async

Get parent historical pnl.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Restrict results to entries created at or before a specific timestamp.

None
created_on_or_after_height int | None

Restrict results to entries created on or after a specific block height.

None
created_on_or_after datetime | None

Restrict results to entries created on or after a specific timestamp.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[PnlTick]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_parent_historical_pnl.py
async def get_parent_historical_pnl(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  created_on_or_after_height: int | None = None,
  created_on_or_after: datetime | None = None,
  validate: bool | None = None
) -> list[PnlTick]:
  """Get parent historical pnl.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Restrict results to entries created at or before a specific timestamp.
    created_on_or_after_height: Restrict results to entries created on or after a specific block height.
    created_on_or_after: Restrict results to entries created on or after a specific timestamp.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-historical-pnl)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if created_on_or_after_height is not None:
    params['createdOnOrAfterHeight'] = created_on_or_after_height
  if created_on_or_after is not None:
    params['createdOnOrAfter'] = ts.dump(created_on_or_after)
  r = await self.request('GET', '/v4/historical-pnl/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

PnlTick

Bases: TypedDict

PnL tick payload.

Source code in pkg/src/dydx/indexer/data/get_parent_historical_pnl.py
class PnlTick(TypedDict):
  """PnL tick payload."""
  blockHeight: str
  blockTime: datetime
  createdAt: datetime
  equity: Decimal
  totalPnl: Decimal
  netTransfer: Decimal

dYdX indexer get parent subaccount types and endpoint.

AssetPosition

Bases: TypedDict

AssetPosition payload.

Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
class AssetPosition(TypedDict):
  """AssetPosition payload."""
  size: Decimal
  symbol: str
  side: Literal['LONG', 'SHORT']
  assetId: str
  subaccountNumber: int

GetParentSubaccount dataclass

Bases: IndexerMixin

Endpoint mixin for parent_subaccount.

Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
@dataclass
class GetParentSubaccount(IndexerMixin):
  """Endpoint mixin for parent_subaccount."""
  async def get_parent_subaccount(
    self,
    address: str,
    parent_subaccount: int,
    validate: bool | None = None
  ) -> ParentSubaccount:
    """Get parent subaccount.

    Args:
      address: Wallet address that owns the parent subaccount.
      parent_subaccount: Parent subaccount number.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-subaccount)
    """
    r = await self.request('GET', f'/v4/addresses/{address}/parentSubaccountNumber/{parent_subaccount}')
    return parse_response(r, validate=self.validate(validate))

get_parent_subaccount(address, parent_subaccount, validate=None) async

Get parent subaccount.

Parameters:

Name Type Description Default
address str

Wallet address that owns the parent subaccount.

required
parent_subaccount int

Parent subaccount number.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
ParentSubaccount

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
async def get_parent_subaccount(
  self,
  address: str,
  parent_subaccount: int,
  validate: bool | None = None
) -> ParentSubaccount:
  """Get parent subaccount.

  Args:
    address: Wallet address that owns the parent subaccount.
    parent_subaccount: Parent subaccount number.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-subaccount)
  """
  r = await self.request('GET', f'/v4/addresses/{address}/parentSubaccountNumber/{parent_subaccount}')
  return parse_response(r, validate=self.validate(validate))

ParentSubaccount

Bases: TypedDict

ParentSubaccount payload.

Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
class ParentSubaccount(TypedDict):
  """ParentSubaccount payload."""
  address: str
  parentSubaccountNumber: int
  equity: Decimal
  freeCollateral: Decimal
  childSubaccounts: list[Subaccount]

PerpetualPosition

Bases: TypedDict

PerpetualPosition payload.

Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
class PerpetualPosition(TypedDict):
  """PerpetualPosition payload."""
  market: str
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED']
  side: Literal['LONG', 'SHORT']
  size: Decimal
  maxSize: Decimal
  entryPrice: Decimal
  exitPrice: NotRequired[Decimal | None]
  realizedPnl: NotRequired[Decimal | None]
  unrealizedPnl: NotRequired[Decimal | None]
  createdAt: datetime
  createdAtHeight: str
  closedAt: NotRequired[datetime | None]
  sumOpen: Decimal
  sumClose: Decimal
  netFunding: Decimal
  subaccountNumber: int

Subaccount

Bases: TypedDict

Subaccount payload.

Source code in pkg/src/dydx/indexer/data/get_parent_subaccount.py
class Subaccount(TypedDict):
  """Subaccount payload."""
  address: str
  subaccountNumber: int
  equity: Decimal
  freeCollateral: Decimal
  openPerpetualPositions: PerpetualPositionsMap
  assetPositions: AssetPositionsMap
  marginEnabled: bool
  updatedAtHeight: str
  latestProcessedBlockHeight: str

dYdX indexer get parent transfers types and endpoint.

Account

Bases: TypedDict

Account payload.

Source code in pkg/src/dydx/indexer/data/get_parent_transfers.py
class Account(TypedDict):
  """Account payload."""
  address: str
  subaccountNumber: NotRequired[int|None]

GetParentTransfers dataclass

Bases: IndexerMixin

Endpoint mixin for parent_transfers.

Source code in pkg/src/dydx/indexer/data/get_parent_transfers.py
@dataclass
class GetParentTransfers(IndexerMixin):
  """Endpoint mixin for parent_transfers."""
  async def get_parent_transfers(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    validate: bool | None = None
  ) -> TransfersResponse:
    """Get parent transfers.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Restrict results to entries created at or before a specific timestamp.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-transfers)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    r = await self.request('GET', '/v4/transfers/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))

get_parent_transfers(address, *, parent_subaccount, limit=None, created_before_or_at_height=None, created_before_or_at=None, validate=None) async

Get parent transfers.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Restrict results to entries created at or before a specific timestamp.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
TransfersResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_parent_transfers.py
async def get_parent_transfers(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """Get parent transfers.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Restrict results to entries created at or before a specific timestamp.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-transfers)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/transfers/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

Transfer

Bases: TypedDict

Transfer payload.

Source code in pkg/src/dydx/indexer/data/get_parent_transfers.py
class Transfer(TypedDict):
  """Transfer payload."""
  id: str
  sender: Account
  recipient: Account
  size: Decimal
  createdAt: datetime
  createdAtHeight: str
  symbol: str
  type: Literal['TRANSFER_IN', 'TRANSFER_OUT', 'DEPOSIT', 'WITHDRAWAL']
  transactionHash: str

TransfersResponse

Bases: TypedDict

Transfers response payload.

Source code in pkg/src/dydx/indexer/data/get_parent_transfers.py
class TransfersResponse(TypedDict):
  """Transfers response payload."""
  transfers: list[Transfer]

dYdX indexer get rewards types and endpoint.

GetRewards dataclass

Bases: IndexerMixin

Endpoint mixin for rewards.

Source code in pkg/src/dydx/indexer/data/get_rewards.py
@dataclass
class GetRewards(IndexerMixin):
  """Endpoint mixin for rewards."""
  async def get_rewards(
    self,
    address: str,
    *,
    limit: int | None = None,
    starting_before_or_at_height: int | None = None,
    starting_before_or_at: datetime | None = None,
    validate: bool | None = None
  ) -> list[HistoricalBlockTradingReward]:
    """Get rewards.

    Args:
      address: Wallet address that owns the account.
      limit: Maximum number of results to return.
      starting_before_or_at_height: Only include rewards starting at or before this block height.
      starting_before_or_at: Only include rewards starting at or before this timestamp.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards)
    """
    params: dict[str, object] = {}
    if limit is not None:
      params['limit'] = limit
    if starting_before_or_at_height is not None:
      params['startingBeforeOrAtHeight'] = starting_before_or_at_height
    if starting_before_or_at is not None:
      params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
    r = await self.request('GET', f'/v4/historicalBlockTradingRewards/{address}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_rewards(address, *, limit=None, starting_before_or_at_height=None, starting_before_or_at=None, validate=None) async

Get rewards.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
limit int | None

Maximum number of results to return.

None
starting_before_or_at_height int | None

Only include rewards starting at or before this block height.

None
starting_before_or_at datetime | None

Only include rewards starting at or before this timestamp.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[HistoricalBlockTradingReward]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_rewards.py
async def get_rewards(
  self,
  address: str,
  *,
  limit: int | None = None,
  starting_before_or_at_height: int | None = None,
  starting_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> list[HistoricalBlockTradingReward]:
  """Get rewards.

  Args:
    address: Wallet address that owns the account.
    limit: Maximum number of results to return.
    starting_before_or_at_height: Only include rewards starting at or before this block height.
    starting_before_or_at: Only include rewards starting at or before this timestamp.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards)
  """
  params: dict[str, object] = {}
  if limit is not None:
    params['limit'] = limit
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  if starting_before_or_at is not None:
    params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
  r = await self.request('GET', f'/v4/historicalBlockTradingRewards/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

HistoricalBlockTradingReward

Bases: TypedDict

HistoricalBlockTradingReward payload.

Source code in pkg/src/dydx/indexer/data/get_rewards.py
class HistoricalBlockTradingReward(TypedDict):
  """HistoricalBlockTradingReward payload."""
  tradingReward: Decimal
  createdAtHeight: str
  createdAt: datetime

dYdX indexer get rewards aggregated types and endpoint.

GetRewardsAggregated dataclass

Bases: IndexerMixin

Endpoint mixin for rewards_aggregated.

Source code in pkg/src/dydx/indexer/data/get_rewards_aggregated.py
@dataclass
class GetRewardsAggregated(IndexerMixin):
  """Endpoint mixin for rewards_aggregated."""
  async def get_rewards_aggregated(
    self,
    address: str,
    *,
    period: Literal['DAILY', 'WEEKLY', 'MONTHLY'],
    limit: int | None = None,
    starting_before_or_at: datetime | None = None,
    starting_before_or_at_height: int | None = None,
    validate: bool | None = None
  ) -> list[HistoricalTradingRewardAggregation]:
    """Get rewards aggregated.

    Args:
      address: Wallet address that owns the account.
      period: Aggregation period.
      limit: Maximum number of results to return.
      starting_before_or_at: Only include aggregations starting at or before this timestamp.
      starting_before_or_at_height: Only include aggregations starting at or before this block height.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards-aggregated)
    """
    params: dict[str, object] = {
      'period': period,
    }
    if limit is not None:
      params['limit'] = limit
    if starting_before_or_at is not None:
      params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
    if starting_before_or_at_height is not None:
      params['startingBeforeOrAtHeight'] = starting_before_or_at_height
    r = await self.request('GET', f'/v4/historicalTradingRewardAggregations/{address}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_rewards_aggregated(address, *, period, limit=None, starting_before_or_at=None, starting_before_or_at_height=None, validate=None) async

Get rewards aggregated.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
period Literal['DAILY', 'WEEKLY', 'MONTHLY']

Aggregation period.

required
limit int | None

Maximum number of results to return.

None
starting_before_or_at datetime | None

Only include aggregations starting at or before this timestamp.

None
starting_before_or_at_height int | None

Only include aggregations starting at or before this block height.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[HistoricalTradingRewardAggregation]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_rewards_aggregated.py
async def get_rewards_aggregated(
  self,
  address: str,
  *,
  period: Literal['DAILY', 'WEEKLY', 'MONTHLY'],
  limit: int | None = None,
  starting_before_or_at: datetime | None = None,
  starting_before_or_at_height: int | None = None,
  validate: bool | None = None
) -> list[HistoricalTradingRewardAggregation]:
  """Get rewards aggregated.

  Args:
    address: Wallet address that owns the account.
    period: Aggregation period.
    limit: Maximum number of results to return.
    starting_before_or_at: Only include aggregations starting at or before this timestamp.
    starting_before_or_at_height: Only include aggregations starting at or before this block height.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards-aggregated)
  """
  params: dict[str, object] = {
    'period': period,
  }
  if limit is not None:
    params['limit'] = limit
  if starting_before_or_at is not None:
    params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  r = await self.request('GET', f'/v4/historicalTradingRewardAggregations/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

HistoricalTradingRewardAggregation

Bases: TypedDict

HistoricalTradingRewardAggregation payload.

Source code in pkg/src/dydx/indexer/data/get_rewards_aggregated.py
class HistoricalTradingRewardAggregation(TypedDict):
  """HistoricalTradingRewardAggregation payload."""
  tradingReward: Decimal
  startedAtHeight: str
  startedAt: datetime
  endedAtHeight: str
  endedAt: datetime

dYdX indexer get screen types and endpoint.

ComplianceResponse

Bases: TypedDict

Compliance response payload.

Source code in pkg/src/dydx/indexer/data/get_screen.py
class ComplianceResponse(TypedDict):
  """Compliance response payload."""
  restricted: bool
  reason: str

GetScreen dataclass

Bases: IndexerMixin

Endpoint mixin for screen.

Source code in pkg/src/dydx/indexer/data/get_screen.py
@dataclass
class GetScreen(IndexerMixin):
  """Endpoint mixin for screen."""
  async def get_screen(
    self,
    address: str,
    *,
    validate: bool | None = None
  ) -> ComplianceResponse:
    """Get screen.

    Args:
      address: Wallet address to screen.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-screen)
    """
    params: dict[str, object] = {
      'address': address,
    }
    r = await self.request('GET', '/v4/screen', params=params)
    return parse_response(r, validate=self.validate(validate))

get_screen(address, *, validate=None) async

Get screen.

Parameters:

Name Type Description Default
address str

Wallet address to screen.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
ComplianceResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_screen.py
async def get_screen(
  self,
  address: str,
  *,
  validate: bool | None = None
) -> ComplianceResponse:
  """Get screen.

  Args:
    address: Wallet address to screen.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-screen)
  """
  params: dict[str, object] = {
    'address': address,
  }
  r = await self.request('GET', '/v4/screen', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get sparklines types and endpoint.

GetSparklines dataclass

Bases: IndexerMixin

Endpoint mixin for sparklines.

Source code in pkg/src/dydx/indexer/data/get_sparklines.py
@dataclass
class GetSparklines(IndexerMixin):
  """Endpoint mixin for sparklines."""
  async def get_sparklines(
    self,
    *,
    time_period: Literal['OneDay', 'SevenDays'],
    validate: bool | None = None
  ) -> Sparkline:
    """Get sparklines.

    Args:
      time_period: Sparkline time period.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/markets#get-sparklines)
    """
    params: dict[str, object] = {
      'timePeriod': time_period,
    }
    r = await self.request('GET', '/v4/sparklines', params=params)
    return parse_response(r, validate=self.validate(validate))

get_sparklines(*, time_period, validate=None) async

Get sparklines.

Parameters:

Name Type Description Default
time_period Literal['OneDay', 'SevenDays']

Sparkline time period.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
Sparkline

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_sparklines.py
async def get_sparklines(
  self,
  *,
  time_period: Literal['OneDay', 'SevenDays'],
  validate: bool | None = None
) -> Sparkline:
  """Get sparklines.

  Args:
    time_period: Sparkline time period.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/markets#get-sparklines)
  """
  params: dict[str, object] = {
    'timePeriod': time_period,
  }
  r = await self.request('GET', '/v4/sparklines', params=params)
  return parse_response(r, validate=self.validate(validate))

dYdX indexer get subaccount types and endpoint.

AssetPosition

Bases: TypedDict

AssetPosition payload.

Source code in pkg/src/dydx/indexer/data/get_subaccount.py
class AssetPosition(TypedDict):
  """AssetPosition payload."""
  size: Decimal
  symbol: str
  side: Literal['LONG', 'SHORT']
  assetId: str
  subaccountNumber: int

GetSubaccount dataclass

Bases: IndexerMixin

Endpoint mixin for subaccount.

Source code in pkg/src/dydx/indexer/data/get_subaccount.py
@dataclass
class GetSubaccount(IndexerMixin):
  """Endpoint mixin for subaccount."""
  async def get_subaccount(
    self,
    address: str,
    subaccount: int,
    validate: bool | None = None
  ) -> GetSubaccountResponse:
    """Get subaccount.

    Args:
      address: Account address.
      subaccount: Subaccount number.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccount)
    """
    r = await self.request('GET', f'/v4/addresses/{address}/subaccountNumber/{subaccount}')
    return parse_response(r, validate=self.validate(validate))

get_subaccount(address, subaccount, validate=None) async

Get subaccount.

Parameters:

Name Type Description Default
address str

Account address.

required
subaccount int

Subaccount number.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
GetSubaccountResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_subaccount.py
async def get_subaccount(
  self,
  address: str,
  subaccount: int,
  validate: bool | None = None
) -> GetSubaccountResponse:
  """Get subaccount.

  Args:
    address: Account address.
    subaccount: Subaccount number.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccount)
  """
  r = await self.request('GET', f'/v4/addresses/{address}/subaccountNumber/{subaccount}')
  return parse_response(r, validate=self.validate(validate))

GetSubaccountResponse

Bases: TypedDict

Endpoint mixin for subaccount_response.

Source code in pkg/src/dydx/indexer/data/get_subaccount.py
class GetSubaccountResponse(TypedDict):
  """Endpoint mixin for subaccount_response."""
  subaccount: Subaccount

PerpetualPosition

Bases: TypedDict

PerpetualPosition payload.

Source code in pkg/src/dydx/indexer/data/get_subaccount.py
class PerpetualPosition(TypedDict):
  """PerpetualPosition payload."""
  market: str
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED']
  side: Literal['LONG', 'SHORT']
  size: Decimal
  maxSize: Decimal
  entryPrice: Decimal
  exitPrice: NotRequired[Decimal | None]
  realizedPnl: NotRequired[Decimal | None]
  unrealizedPnl: NotRequired[Decimal | None]
  createdAt: datetime
  createdAtHeight: str
  closedAt: NotRequired[datetime | None]
  sumOpen: Decimal
  sumClose: Decimal
  netFunding: Decimal
  subaccountNumber: int

Subaccount

Bases: TypedDict

Subaccount payload.

Source code in pkg/src/dydx/indexer/data/get_subaccount.py
class Subaccount(TypedDict):
  """Subaccount payload."""
  address: str
  subaccountNumber: int
  equity: Decimal
  freeCollateral: Decimal
  openPerpetualPositions: PerpetualPositionsMap
  assetPositions: AssetPositionsMap
  marginEnabled: bool
  updatedAtHeight: str
  latestProcessedBlockHeight: str

dYdX indexer get subaccounts types and endpoint.

AddressResponse

Bases: TypedDict

Address response payload.

Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
class AddressResponse(TypedDict):
  """Address response payload."""
  subaccounts: list[Subaccount]
  totalTradingRewards: Decimal

AssetPosition

Bases: TypedDict

AssetPosition payload.

Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
class AssetPosition(TypedDict):
  """AssetPosition payload."""
  size: Decimal
  symbol: str
  side: Literal['LONG', 'SHORT']
  assetId: str
  subaccountNumber: int

GetSubaccounts dataclass

Bases: IndexerMixin

Endpoint mixin for subaccounts.

Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
@dataclass
class GetSubaccounts(IndexerMixin):
  """Endpoint mixin for subaccounts."""
  async def get_subaccounts(
    self,
    address: str,
    *,
    limit: int | None = None,
    validate: bool | None = None
  ) -> AddressResponse:
    """Get subaccounts.

    Args:
      address: Account address.
      limit: Maximum number of subaccounts to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccounts)
    """
    params: dict[str, object] = {}
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', f'/v4/addresses/{address}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_subaccounts(address, *, limit=None, validate=None) async

Get subaccounts.

Parameters:

Name Type Description Default
address str

Account address.

required
limit int | None

Maximum number of subaccounts to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
AddressResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
async def get_subaccounts(
  self,
  address: str,
  *,
  limit: int | None = None,
  validate: bool | None = None
) -> AddressResponse:
  """Get subaccounts.

  Args:
    address: Account address.
    limit: Maximum number of subaccounts to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccounts)
  """
  params: dict[str, object] = {}
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/addresses/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

PerpetualPosition

Bases: TypedDict

PerpetualPosition payload.

Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
class PerpetualPosition(TypedDict):
  """PerpetualPosition payload."""
  market: str
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED']
  side: Literal['LONG', 'SHORT']
  size: Decimal
  maxSize: Decimal
  entryPrice: Decimal
  exitPrice: NotRequired[Decimal | None]
  realizedPnl: NotRequired[Decimal | None]
  unrealizedPnl: NotRequired[Decimal | None]
  createdAt: datetime
  createdAtHeight: str
  closedAt: NotRequired[datetime | None]
  sumOpen: Decimal
  sumClose: Decimal
  netFunding: Decimal
  subaccountNumber: int

Subaccount

Bases: TypedDict

Subaccount payload.

Source code in pkg/src/dydx/indexer/data/get_subaccounts.py
class Subaccount(TypedDict):
  """Subaccount payload."""
  address: str
  subaccountNumber: int
  equity: Decimal
  freeCollateral: Decimal
  openPerpetualPositions: PerpetualPositionsMap
  assetPositions: AssetPositionsMap
  marginEnabled: bool
  updatedAtHeight: str
  latestProcessedBlockHeight: str

dYdX indexer get time types and endpoint.

GetTime dataclass

Bases: IndexerMixin

Endpoint mixin for time.

Source code in pkg/src/dydx/indexer/data/get_time.py
@dataclass
class GetTime(IndexerMixin):
  """Endpoint mixin for time."""
  async def get_time(
    self,
    validate: bool | None = None
  ) -> TimeResponse:
    """Fetch the indexer server time.

    Args:
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-time)
    """
    r = await self.request('GET', '/v4/time')
    return parse_response(r, validate=self.validate(validate))

get_time(validate=None) async

Fetch the indexer server time.

Parameters:

Name Type Description Default
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
TimeResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_time.py
async def get_time(
  self,
  validate: bool | None = None
) -> TimeResponse:
  """Fetch the indexer server time.

  Args:
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-time)
  """
  r = await self.request('GET', '/v4/time')
  return parse_response(r, validate=self.validate(validate))

TimeResponse

Bases: TypedDict

Time response payload.

Source code in pkg/src/dydx/indexer/data/get_time.py
class TimeResponse(TypedDict):
  """Time response payload."""
  iso: datetime
  epoc: float

dYdX indexer get trades types and endpoint.

GetTrades dataclass

Bases: IndexerMixin

Endpoint mixin for trades.

Source code in pkg/src/dydx/indexer/data/get_trades.py
@dataclass
class GetTrades(IndexerMixin):
  """Endpoint mixin for trades."""
  async def get_trades(
    self,
    market: str,
    *,
    starting_before_or_at_height: int | None = None,
    limit: int | None = None,
    validate: bool | None = None
  ) -> TradesResponse:
    """Get trades.

    Args:
      market: Perpetual market ticker.
      starting_before_or_at_height: Latest block height to include.
      limit: Maximum number of trades to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-trades)
    """
    params: dict[str, object] = {}
    if starting_before_or_at_height is not None:
      params['startingBeforeOrAtHeight'] = starting_before_or_at_height
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', f'/v4/trades/perpetualMarket/{market}', params=params)
    return parse_response(r, validate=self.validate(validate))

get_trades(market, *, starting_before_or_at_height=None, limit=None, validate=None) async

Get trades.

Parameters:

Name Type Description Default
market str

Perpetual market ticker.

required
starting_before_or_at_height int | None

Latest block height to include.

None
limit int | None

Maximum number of trades to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
TradesResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_trades.py
async def get_trades(
  self,
  market: str,
  *,
  starting_before_or_at_height: int | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> TradesResponse:
  """Get trades.

  Args:
    market: Perpetual market ticker.
    starting_before_or_at_height: Latest block height to include.
    limit: Maximum number of trades to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-trades)
  """
  params: dict[str, object] = {}
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/trades/perpetualMarket/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

Trade

Bases: TypedDict

Trade payload.

Source code in pkg/src/dydx/indexer/data/get_trades.py
class Trade(TypedDict):
  """Trade payload."""
  id: str
  side: Literal['BUY', 'SELL']
  size: Decimal
  price: Decimal
  type: Literal['LIMIT', 'LIQUIDATED', 'DELEVERAGED']
  createdAt: datetime
  createdAtHeight: str

TradesResponse

Bases: TypedDict

TradesResponse payload.

Source code in pkg/src/dydx/indexer/data/get_trades.py
class TradesResponse(TypedDict):
  """TradesResponse payload."""
  trades: list[Trade]

dYdX indexer get transfers types and endpoint.

Account

Bases: TypedDict

Account payload.

Source code in pkg/src/dydx/indexer/data/get_transfers.py
class Account(TypedDict):
  """Account payload."""
  address: str
  subaccountNumber: NotRequired[int|None]

GetTransfers dataclass

Bases: IndexerMixin

Endpoint mixin for transfers.

Source code in pkg/src/dydx/indexer/data/get_transfers.py
@dataclass
class GetTransfers(IndexerMixin):
  """Endpoint mixin for transfers."""
  async def get_transfers(
    self,
    address: str,
    *,
    subaccount: int,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    limit: int | None = None,
    page: int | None = None,
    validate: bool | None = None
  ) -> TransfersResponse:
    """Fetch transfers for a subaccount.

    Args:
      address: Wallet address that owns the subaccount.
      subaccount: Subaccount number.
      created_before_or_at_height: Latest block height to include.
      created_before_or_at: Latest timestamp to include.
      limit: Maximum number of transfers to return.
      page: Page number for paginated results.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    if limit is not None:
      params['limit'] = limit
    if page is not None:
      params['page'] = page
    r = await self.request('GET', '/v4/transfers', params=params)
    return parse_response(r, validate=self.validate(validate))

get_transfers(address, *, subaccount, created_before_or_at_height=None, created_before_or_at=None, limit=None, page=None, validate=None) async

Fetch transfers for a subaccount.

Parameters:

Name Type Description Default
address str

Wallet address that owns the subaccount.

required
subaccount int

Subaccount number.

required
created_before_or_at_height int | None

Latest block height to include.

None
created_before_or_at datetime | None

Latest timestamp to include.

None
limit int | None

Maximum number of transfers to return.

None
page int | None

Page number for paginated results.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
TransfersResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_transfers.py
async def get_transfers(
  self,
  address: str,
  *,
  subaccount: int,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """Fetch transfers for a subaccount.

  Args:
    address: Wallet address that owns the subaccount.
    subaccount: Subaccount number.
    created_before_or_at_height: Latest block height to include.
    created_before_or_at: Latest timestamp to include.
    limit: Maximum number of transfers to return.
    page: Page number for paginated results.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/transfers', params=params)
  return parse_response(r, validate=self.validate(validate))

GetTransfersPaged dataclass

Bases: GetTransfers

Endpoint mixin for transfers_paged.

Source code in pkg/src/dydx/indexer/data/get_transfers.py
@dataclass
class GetTransfersPaged(GetTransfers):
  """Endpoint mixin for transfers_paged."""
  def get_transfers_paged(
    self,
    address: str,
    *,
    subaccount: int,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    limit: int | None = None,
    validate: bool | None = None,
  ) -> PaginatedResponse[Transfer, int]:
    """Page through transfers for a subaccount.

    Args:
      address: The wallet address that owns the account.
      subaccount: The identifier for the specific subaccount within the wallet address.
      created_before_or_at_height: If given, fetches transfers up to and including the given block height.
      created_before_or_at: If given, fetches transfers up to and including the given timestamp.
      limit: The max. number of transfers to retrieve (default: 1000, max: 1000).
      validate: Override the client response validation default for this call.

    Returns:
      A paginated response. Each request advances by page number until the endpoint returns no items.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
    """
    async def next(page: int) -> tuple[list[Transfer], int | None]:
      """Next.

      Args:
        page: Page number to request.
      """
      response = await self.get_transfers(
        address,
        subaccount=subaccount,
        created_before_or_at_height=created_before_or_at_height,
        created_before_or_at=created_before_or_at,
        limit=limit,
        page=page,
        validate=validate,
      )
      transfers = response['transfers']
      next_page = page + 1 if transfers else None
      return transfers, next_page

    return PaginatedResponse(1, next)

get_transfers_paged(address, *, subaccount, created_before_or_at_height=None, created_before_or_at=None, limit=None, validate=None)

Page through transfers for a subaccount.

Parameters:

Name Type Description Default
address str

The wallet address that owns the account.

required
subaccount int

The identifier for the specific subaccount within the wallet address.

required
created_before_or_at_height int | None

If given, fetches transfers up to and including the given block height.

None
created_before_or_at datetime | None

If given, fetches transfers up to and including the given timestamp.

None
limit int | None

The max. number of transfers to retrieve (default: 1000, max: 1000).

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PaginatedResponse[Transfer, int]

A paginated response. Each request advances by page number until the endpoint returns no items.

References
Source code in pkg/src/dydx/indexer/data/get_transfers.py
def get_transfers_paged(
  self,
  address: str,
  *,
  subaccount: int,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> PaginatedResponse[Transfer, int]:
  """Page through transfers for a subaccount.

  Args:
    address: The wallet address that owns the account.
    subaccount: The identifier for the specific subaccount within the wallet address.
    created_before_or_at_height: If given, fetches transfers up to and including the given block height.
    created_before_or_at: If given, fetches transfers up to and including the given timestamp.
    limit: The max. number of transfers to retrieve (default: 1000, max: 1000).
    validate: Override the client response validation default for this call.

  Returns:
    A paginated response. Each request advances by page number until the endpoint returns no items.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
  """
  async def next(page: int) -> tuple[list[Transfer], int | None]:
    """Next.

    Args:
      page: Page number to request.
    """
    response = await self.get_transfers(
      address,
      subaccount=subaccount,
      created_before_or_at_height=created_before_or_at_height,
      created_before_or_at=created_before_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    transfers = response['transfers']
    next_page = page + 1 if transfers else None
    return transfers, next_page

  return PaginatedResponse(1, next)

Transfer

Bases: TypedDict

Transfer payload.

Source code in pkg/src/dydx/indexer/data/get_transfers.py
class Transfer(TypedDict):
  """Transfer payload."""
  id: str
  sender: Account
  recipient: Account
  size: Decimal
  createdAt: datetime
  createdAtHeight: str
  symbol: str
  type: Literal['TRANSFER_IN', 'TRANSFER_OUT', 'DEPOSIT', 'WITHDRAWAL']
  transactionHash: str

TransfersResponse

Bases: TypedDict

Transfers response payload.

Source code in pkg/src/dydx/indexer/data/get_transfers.py
class TransfersResponse(TypedDict):
  """Transfers response payload."""
  transfers: list[Transfer]

dYdX indexer get transfers between types and endpoint.

Account

Bases: TypedDict

Account payload.

Source code in pkg/src/dydx/indexer/data/get_transfers_between.py
class Account(TypedDict):
  """Account payload."""
  address: str
  subaccountNumber: NotRequired[int|None]

GetTransfersBetween dataclass

Bases: IndexerMixin

Endpoint mixin for transfers_between.

Source code in pkg/src/dydx/indexer/data/get_transfers_between.py
@dataclass
class GetTransfersBetween(IndexerMixin):
  """Endpoint mixin for transfers_between."""
  async def get_transfers_between(
    self,
    source_address: str,
    *,
    source_subaccount: str,
    recipient_address: str,
    recipient_subaccount: str,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    validate: bool | None = None
  ) -> TransfersResponse:
    """Get transfers between.

    Args:
      source_address: Sender wallet address.
      source_subaccount: Sender subaccount number.
      recipient_address: Recipient wallet address.
      recipient_subaccount: Recipient subaccount number.
      created_before_or_at_height: Restrict results to entries created at or before a specific block height.
      created_before_or_at: Restrict results to entries created at or before a specific timestamp.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-transfers-between)
    """
    params: dict[str, object] = {
      'sourceAddress': source_address,
      'sourceSubaccountNumber': source_subaccount,
      'recipientAddress': recipient_address,
      'recipientSubaccountNumber': recipient_subaccount,
    }
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    r = await self.request('GET', '/v4/transfers/between', params=params)
    return parse_response(r, validate=self.validate(validate))

get_transfers_between(source_address, *, source_subaccount, recipient_address, recipient_subaccount, created_before_or_at_height=None, created_before_or_at=None, validate=None) async

Get transfers between.

Parameters:

Name Type Description Default
source_address str

Sender wallet address.

required
source_subaccount str

Sender subaccount number.

required
recipient_address str

Recipient wallet address.

required
recipient_subaccount str

Recipient subaccount number.

required
created_before_or_at_height int | None

Restrict results to entries created at or before a specific block height.

None
created_before_or_at datetime | None

Restrict results to entries created at or before a specific timestamp.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
TransfersResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_transfers_between.py
async def get_transfers_between(
  self,
  source_address: str,
  *,
  source_subaccount: str,
  recipient_address: str,
  recipient_subaccount: str,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """Get transfers between.

  Args:
    source_address: Sender wallet address.
    source_subaccount: Sender subaccount number.
    recipient_address: Recipient wallet address.
    recipient_subaccount: Recipient subaccount number.
    created_before_or_at_height: Restrict results to entries created at or before a specific block height.
    created_before_or_at: Restrict results to entries created at or before a specific timestamp.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-transfers-between)
  """
  params: dict[str, object] = {
    'sourceAddress': source_address,
    'sourceSubaccountNumber': source_subaccount,
    'recipientAddress': recipient_address,
    'recipientSubaccountNumber': recipient_subaccount,
  }
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/transfers/between', params=params)
  return parse_response(r, validate=self.validate(validate))

Transfer

Bases: TypedDict

Transfer payload.

Source code in pkg/src/dydx/indexer/data/get_transfers_between.py
class Transfer(TypedDict):
  """Transfer payload."""
  id: str
  sender: Account
  recipient: Account
  size: Decimal
  createdAt: datetime
  createdAtHeight: str
  symbol: str
  type: Literal['TRANSFER_IN', 'TRANSFER_OUT', 'DEPOSIT', 'WITHDRAWAL']
  transactionHash: str

TransfersResponse

Bases: TypedDict

Transfers response payload.

Source code in pkg/src/dydx/indexer/data/get_transfers_between.py
class TransfersResponse(TypedDict):
  """Transfers response payload."""
  transfers: list[Transfer]

dYdX indexer get vaults historical pnl types and endpoint.

GetVaultsHistoricalPnl dataclass

Bases: IndexerMixin

Endpoint mixin for vaults_historical_pnl.

Source code in pkg/src/dydx/indexer/data/get_vaults_historical_pnl.py
@dataclass
class GetVaultsHistoricalPnl(IndexerMixin):
  """Endpoint mixin for vaults_historical_pnl."""
  async def get_vaults_historical_pnl(
    self,
    *,
    resolution: Literal['hour', 'day'],
    validate: bool | None = None
  ) -> list[VaultHistoricalPnl]:
    """Get vaults historical pnl.

    Args:
      resolution: PnL tick resolution.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-vaults-historical-pnl)
    """
    params: dict[str, object] = {
      'resolution': resolution,
    }
    r = await self.request('GET', '/v4/vault/v1/vaults/historicalPnl', params=params)
    return parse_response(r, validate=self.validate(validate))

get_vaults_historical_pnl(*, resolution, validate=None) async

Get vaults historical pnl.

Parameters:

Name Type Description Default
resolution Literal['hour', 'day']

PnL tick resolution.

required
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[VaultHistoricalPnl]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/get_vaults_historical_pnl.py
async def get_vaults_historical_pnl(
  self,
  *,
  resolution: Literal['hour', 'day'],
  validate: bool | None = None
) -> list[VaultHistoricalPnl]:
  """Get vaults historical pnl.

  Args:
    resolution: PnL tick resolution.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-vaults-historical-pnl)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  r = await self.request('GET', '/v4/vault/v1/vaults/historicalPnl', params=params)
  return parse_response(r, validate=self.validate(validate))

PnlTick

Bases: TypedDict

PnL tick payload.

Source code in pkg/src/dydx/indexer/data/get_vaults_historical_pnl.py
class PnlTick(TypedDict):
  """PnL tick payload."""
  blockHeight: str
  blockTime: datetime
  createdAt: datetime
  equity: Decimal
  totalPnl: Decimal
  netTransfer: Decimal

VaultHistoricalPnl

Bases: TypedDict

Vault historical PnL payload.

Source code in pkg/src/dydx/indexer/data/get_vaults_historical_pnl.py
class VaultHistoricalPnl(TypedDict):
  """Vault historical PnL payload."""
  ticker: str
  historicalPnl: PnlTick

dYdX indexer list orders types and endpoint.

ListOrders dataclass

Bases: IndexerMixin

Endpoint mixin for ListOrders.

Source code in pkg/src/dydx/indexer/data/list_orders.py
@dataclass
class ListOrders(IndexerMixin):
  """Endpoint mixin for ListOrders."""
  async def list_orders(
    self,
    address: str,
    *,
    subaccount: int,
    limit: int | None = None,
    ticker: str | None = None,
    side: Literal['BUY', 'SELL'] | None = None,
    status: Literal[
      'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
    ] | None = None,
    type: Literal[
      'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
    ] | None = None,
    good_til_block_before_or_at: int | None = None,
    good_til_block_time_before_or_at: datetime | None = None,
    return_latest_orders: bool | None = None,
    validate: bool | None = None
  ) -> list[Order]:
    """List orders.

    Args:
      address: Wallet address that owns the subaccount.
      subaccount: Subaccount number.
      limit: Maximum number of orders to return.
      ticker: Ticker filter.
      side: Order side filter.
      status: Order status filter.
      type: Order type filter.
      good_til_block_before_or_at: Latest good-til-block to include.
      good_til_block_time_before_or_at: Latest good-til-block time to include.
      return_latest_orders: Whether to return only the latest orders.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#list-orders)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if ticker is not None:
      params['ticker'] = ticker
    if side is not None:
      params['side'] = side
    if status is not None:
      params['status'] = status
    if type is not None:
      params['type'] = type
    if good_til_block_before_or_at is not None:
      params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
    if good_til_block_time_before_or_at is not None:
      params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
    if return_latest_orders is not None:
      params['returnLatestOrders'] = return_latest_orders
    r = await self.request('GET', '/v4/orders', params=params)
    return parse_response(r, validate=self.validate(validate))

list_orders(address, *, subaccount, limit=None, ticker=None, side=None, status=None, type=None, good_til_block_before_or_at=None, good_til_block_time_before_or_at=None, return_latest_orders=None, validate=None) async

List orders.

Parameters:

Name Type Description Default
address str

Wallet address that owns the subaccount.

required
subaccount int

Subaccount number.

required
limit int | None

Maximum number of orders to return.

None
ticker str | None

Ticker filter.

None
side Literal['BUY', 'SELL'] | None

Order side filter.

None
status Literal['OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'] | None

Order status filter.

None
type Literal['LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'] | None

Order type filter.

None
good_til_block_before_or_at int | None

Latest good-til-block to include.

None
good_til_block_time_before_or_at datetime | None

Latest good-til-block time to include.

None
return_latest_orders bool | None

Whether to return only the latest orders.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[Order]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/list_orders.py
async def list_orders(
  self,
  address: str,
  *,
  subaccount: int,
  limit: int | None = None,
  ticker: str | None = None,
  side: Literal['BUY', 'SELL'] | None = None,
  status: Literal[
    'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
  ] | None = None,
  type: Literal[
    'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
  ] | None = None,
  good_til_block_before_or_at: int | None = None,
  good_til_block_time_before_or_at: datetime | None = None,
  return_latest_orders: bool | None = None,
  validate: bool | None = None
) -> list[Order]:
  """List orders.

  Args:
    address: Wallet address that owns the subaccount.
    subaccount: Subaccount number.
    limit: Maximum number of orders to return.
    ticker: Ticker filter.
    side: Order side filter.
    status: Order status filter.
    type: Order type filter.
    good_til_block_before_or_at: Latest good-til-block to include.
    good_til_block_time_before_or_at: Latest good-til-block time to include.
    return_latest_orders: Whether to return only the latest orders.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#list-orders)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if ticker is not None:
    params['ticker'] = ticker
  if side is not None:
    params['side'] = side
  if status is not None:
    params['status'] = status
  if type is not None:
    params['type'] = type
  if good_til_block_before_or_at is not None:
    params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
  if good_til_block_time_before_or_at is not None:
    params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
  if return_latest_orders is not None:
    params['returnLatestOrders'] = return_latest_orders
  r = await self.request('GET', '/v4/orders', params=params)
  return parse_response(r, validate=self.validate(validate))

Order

Bases: TypedDict

Order payload.

Source code in pkg/src/dydx/indexer/data/list_orders.py
class Order(TypedDict):
  """Order payload."""
  id: str
  subaccountId: str
  clientId: str
  clobPairId: str
  side: Literal['BUY', 'SELL']
  size: Decimal
  totalFilled: Decimal
  price: Decimal
  type: Literal['LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER']
  status: Literal['OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING']
  timeInForce: Literal['GTT', 'IOC', 'FOK']
  reduceOnly: NotRequired[bool | None]
  orderFlags: str
  goodTilBlock: NotRequired[str | None]
  goodTilBlockTime: NotRequired[datetime | None]
  createdAtHeight: NotRequired[str | None]
  clientMetadata: NotRequired[str | None]
  triggerPrice: NotRequired[Decimal | None]
  postOnly: NotRequired[bool | None]
  ticker: str
  updatedAt: NotRequired[datetime | None]
  updatedAtHeight: NotRequired[str | None]
  subaccountNumber: int
  orderRouterAddress: NotRequired[str|None]
  builderFee: NotRequired[Decimal | None]
  feePpm: NotRequired[Decimal | None]

dYdX indexer list parent orders types and endpoint.

ListParentOrders dataclass

Bases: IndexerMixin

Endpoint mixin for ListParentOrders.

Source code in pkg/src/dydx/indexer/data/list_parent_orders.py
@dataclass
class ListParentOrders(IndexerMixin):
  """Endpoint mixin for ListParentOrders."""
  async def list_parent_orders(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    ticker: str | None = None,
    side: Literal['BUY', 'SELL'] | None = None,
    status: Literal[
      'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
    ] | None = None,
    type: Literal[
      'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
    ] | None = None,
    good_til_block_before_or_at: int | None = None,
    good_til_block_time_before_or_at: datetime | None = None,
    return_latest_orders: bool | None = None,
    validate: bool | None = None
  ) -> list[Order]:
    """List parent orders.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      ticker: Ticker filter.
      side: Order side filter.
      status: Order status filter.
      type: Order type filter.
      good_til_block_before_or_at: Latest good-til-block to include.
      good_til_block_time_before_or_at: Latest good-til-block time to include.
      return_latest_orders: Whether to return only the latest orders.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-orders)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    if ticker is not None:
      params['ticker'] = ticker
    if side is not None:
      params['side'] = side
    if status is not None:
      params['status'] = status
    if type is not None:
      params['type'] = type
    if good_til_block_before_or_at is not None:
      params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
    if good_til_block_time_before_or_at is not None:
      params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
    if return_latest_orders is not None:
      params['returnLatestOrders'] = return_latest_orders
    r = await self.request('GET', '/v4/orders/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))

list_parent_orders(address, *, parent_subaccount, limit=None, ticker=None, side=None, status=None, type=None, good_til_block_before_or_at=None, good_til_block_time_before_or_at=None, return_latest_orders=None, validate=None) async

List parent orders.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
ticker str | None

Ticker filter.

None
side Literal['BUY', 'SELL'] | None

Order side filter.

None
status Literal['OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'] | None

Order status filter.

None
type Literal['LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'] | None

Order type filter.

None
good_til_block_before_or_at int | None

Latest good-til-block to include.

None
good_til_block_time_before_or_at datetime | None

Latest good-til-block time to include.

None
return_latest_orders bool | None

Whether to return only the latest orders.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[Order]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/list_parent_orders.py
async def list_parent_orders(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  ticker: str | None = None,
  side: Literal['BUY', 'SELL'] | None = None,
  status: Literal[
    'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
  ] | None = None,
  type: Literal[
    'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
  ] | None = None,
  good_til_block_before_or_at: int | None = None,
  good_til_block_time_before_or_at: datetime | None = None,
  return_latest_orders: bool | None = None,
  validate: bool | None = None
) -> list[Order]:
  """List parent orders.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    ticker: Ticker filter.
    side: Order side filter.
    status: Order status filter.
    type: Order type filter.
    good_til_block_before_or_at: Latest good-til-block to include.
    good_til_block_time_before_or_at: Latest good-til-block time to include.
    return_latest_orders: Whether to return only the latest orders.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-orders)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if ticker is not None:
    params['ticker'] = ticker
  if side is not None:
    params['side'] = side
  if status is not None:
    params['status'] = status
  if type is not None:
    params['type'] = type
  if good_til_block_before_or_at is not None:
    params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
  if good_til_block_time_before_or_at is not None:
    params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
  if return_latest_orders is not None:
    params['returnLatestOrders'] = return_latest_orders
  r = await self.request('GET', '/v4/orders/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

Order

Bases: TypedDict

Order payload.

Source code in pkg/src/dydx/indexer/data/list_parent_orders.py
class Order(TypedDict):
  """Order payload."""
  id: str
  subaccountId: str
  clientId: str
  clobPairId: str
  side: Literal['BUY', 'SELL']
  size: Decimal
  totalFilled: Decimal
  price: Decimal
  type: Literal['LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER']
  status: Literal['OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING']
  timeInForce: Literal['GTT', 'IOC', 'FOK']
  reduceOnly: NotRequired[bool | None]
  orderFlags: str
  goodTilBlock: NotRequired[str | None]
  goodTilBlockTime: NotRequired[datetime | None]
  createdAtHeight: NotRequired[str | None]
  clientMetadata: NotRequired[str | None]
  triggerPrice: NotRequired[Decimal | None]
  postOnly: NotRequired[bool | None]
  ticker: str
  updatedAt: NotRequired[datetime | None]
  updatedAtHeight: NotRequired[str | None]
  subaccountNumber: int
  orderRouterAddress: NotRequired[str|None]
  builderFee: NotRequired[Decimal | None]
  feePpm: NotRequired[Decimal | None]

dYdX indexer list parent positions types and endpoint.

ListParentPositions dataclass

Bases: IndexerMixin

Endpoint mixin for ListParentPositions.

Source code in pkg/src/dydx/indexer/data/list_parent_positions.py
@dataclass
class ListParentPositions(IndexerMixin):
  """Endpoint mixin for ListParentPositions."""
  async def list_parent_positions(
    self,
    address: str,
    *,
    parent_subaccount: int,
    limit: int | None = None,
    validate: bool | None = None
  ) -> list[PerpetualPosition]:
    """List parent positions.

    Args:
      address: Wallet address that owns the account.
      parent_subaccount: Parent subaccount number.
      limit: Maximum number of results to return.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-positions)
    """
    params: dict[str, object] = {
      'address': address,
      'parentSubaccountNumber': parent_subaccount,
    }
    if limit is not None:
      params['limit'] = limit
    r = await self.request('GET', '/v4/perpetualPositions/parentSubaccountNumber', params=params)
    return parse_response(r, validate=self.validate(validate))['positions']

list_parent_positions(address, *, parent_subaccount, limit=None, validate=None) async

List parent positions.

Parameters:

Name Type Description Default
address str

Wallet address that owns the account.

required
parent_subaccount int

Parent subaccount number.

required
limit int | None

Maximum number of results to return.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
list[PerpetualPosition]

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/list_parent_positions.py
async def list_parent_positions(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  validate: bool | None = None
) -> list[PerpetualPosition]:
  """List parent positions.

  Args:
    address: Wallet address that owns the account.
    parent_subaccount: Parent subaccount number.
    limit: Maximum number of results to return.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', '/v4/perpetualPositions/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))['positions']

PerpetualPosition

Bases: TypedDict

PerpetualPosition payload.

Source code in pkg/src/dydx/indexer/data/list_parent_positions.py
class PerpetualPosition(TypedDict):
  """PerpetualPosition payload."""
  market: str
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED']
  side: Literal['LONG', 'SHORT']
  size: Decimal
  maxSize: Decimal
  entryPrice: Decimal
  exitPrice: NotRequired[Decimal | None]
  realizedPnl: NotRequired[Decimal | None]
  unrealizedPnl: NotRequired[Decimal | None]
  createdAt: datetime
  createdAtHeight: str
  closedAt: NotRequired[datetime | None]
  sumOpen: Decimal
  sumClose: Decimal
  netFunding: Decimal
  subaccountNumber: int

Response

Bases: TypedDict

Response payload.

Source code in pkg/src/dydx/indexer/data/list_parent_positions.py
class Response(TypedDict):
  """Response payload."""
  positions: list[PerpetualPosition]

dYdX indexer list positions types and endpoint.

ListPositions dataclass

Bases: IndexerMixin

Endpoint mixin for ListPositions.

Source code in pkg/src/dydx/indexer/data/list_positions.py
@dataclass
class ListPositions(IndexerMixin):
  """Endpoint mixin for ListPositions."""
  async def list_positions(
    self, address: str, *,
    subaccount: int,
    status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
    limit: int | None = None,
    created_before_or_at_height: int | None = None,
    created_before_or_at: datetime | None = None,
    validate: bool | None = None
  ) -> PositionsResponse:
    """List positions.

    Args:
      address: Wallet address that owns the subaccount.
      subaccount: Subaccount number.
      status: Position status filter.
      limit: Maximum number of positions to return.
      created_before_or_at_height: Latest block height to include.
      created_before_or_at: Latest timestamp to include.
      validate: Override the client response validation default for this call.

    Returns:
      The validated indexer response payload.

    References:
      - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#list-positions)
    """
    params: dict[str, object] = {
      'address': address,
      'subaccountNumber': subaccount,
    }
    if status is not None:
      params['status'] = status
    if limit is not None:
      params['limit'] = limit
    if created_before_or_at_height is not None:
      params['createdBeforeOrAtHeight'] = created_before_or_at_height
    if created_before_or_at is not None:
      params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
    r = await self.request('GET', '/v4/perpetualPositions', params=params)
    return parse_response(r, validate=self.validate(validate))

list_positions(address, *, subaccount, status=None, limit=None, created_before_or_at_height=None, created_before_or_at=None, validate=None) async

List positions.

Parameters:

Name Type Description Default
address str

Wallet address that owns the subaccount.

required
subaccount int

Subaccount number.

required
status Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None

Position status filter.

None
limit int | None

Maximum number of positions to return.

None
created_before_or_at_height int | None

Latest block height to include.

None
created_before_or_at datetime | None

Latest timestamp to include.

None
validate bool | None

Override the client response validation default for this call.

None

Returns:

Type Description
PositionsResponse

The validated indexer response payload.

References
Source code in pkg/src/dydx/indexer/data/list_positions.py
async def list_positions(
  self, address: str, *,
  subaccount: int,
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> PositionsResponse:
  """List positions.

  Args:
    address: Wallet address that owns the subaccount.
    subaccount: Subaccount number.
    status: Position status filter.
    limit: Maximum number of positions to return.
    created_before_or_at_height: Latest block height to include.
    created_before_or_at: Latest timestamp to include.
    validate: Override the client response validation default for this call.

  Returns:
    The validated indexer response payload.

  References:
    - [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#list-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if status is not None:
    params['status'] = status
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/perpetualPositions', params=params)
  return parse_response(r, validate=self.validate(validate))

PerpetualPosition

Bases: TypedDict

PerpetualPosition payload.

Source code in pkg/src/dydx/indexer/data/list_positions.py
class PerpetualPosition(TypedDict):
  """PerpetualPosition payload."""
  market: str
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED']
  side: Literal['LONG', 'SHORT']
  size: Decimal
  maxSize: Decimal
  entryPrice: Decimal
  exitPrice: NotRequired[Decimal | None]
  realizedPnl: NotRequired[Decimal | None]
  unrealizedPnl: NotRequired[Decimal | None]
  createdAt: datetime
  createdAtHeight: str
  closedAt: NotRequired[datetime | None]
  sumOpen: Decimal
  sumClose: Decimal
  netFunding: Decimal
  subaccountNumber: int

PositionsResponse

Bases: TypedDict

PositionsResponse payload.

Source code in pkg/src/dydx/indexer/data/list_positions.py
class PositionsResponse(TypedDict):
  """PositionsResponse payload."""
  positions: list[PerpetualPosition]