Skip to content

Latest commit

 

History

History
420 lines (258 loc) · 7.59 KB

Account.md

File metadata and controls

420 lines (258 loc) · 7.59 KB

Account

account in PerpetualState is an object, containing a map of String to Subaccount

data class Account(
 var subaccounts: Map<String, Subaccount>?,
 var tradingRewards: TradingRewards?
)

TradingRewards

Metadata about trading rewards this account has earned.

data class TradingRewards(
 val total: Double?,
 val filledHistory: Map<String, IList>?,
 val rawHistory: Map<String, IList>?
)

filledHistory

Map with keys "WEEKLY", "DAILY", and "MONTHLY" where each value is a list of objects representing the rewards received in every period starting in the current period and going backward.

Periods with no rewards will be present in the list with a value of 0.

rawHistory

Same as filledHistory except all empty (0) rewards periods will be removed from the lists.

Subaccount

data class Subaccount(
 val subaccountNumber: Int,
 val positionId: String?,
 val pnlTotal: Double?,
 val pnl24h: Double?,
 val pnl24hPercent: Double?,
 val quoteBalance: TradeStatesWithDoubleValues?,
 val notionalTotal: TradeStatesWithDoubleValues?,
 val valueTotal: TradeStatesWithDoubleValues?,
 val initialRiskTotal: TradeStatesWithDoubleValues?,
 val adjustedImf: TradeStatesWithDoubleValues?,
 val equity: TradeStatesWithDoubleValues?,
 val freeCollateral: TradeStatesWithDoubleValues?,
 val leverage: TradeStatesWithDoubleValues?,
 val marginUsage: TradeStatesWithDoubleValues?,
 val buyingPower: TradeStatesWithDoubleValues?,
 val openPositions: SubaccountPositions?,
 val orders: SubaccountOrders?,
 val marginEnabled: Boolean?
)

subaccountNumber

Sequential number for the subaccount

positionId

Not used

pnlTotal

Total PNL

pnl24h

24-hour PNL

pnl24hPercent

24-hour PNL percentage change

quoteBalance

Calculated quote balance

notionalTotal

Notional total of the positions

valueTotal

Total value of the positions

initialRiskTotal

Total initial risk

adjustedImf

Adjusted margin fraction

equity

Total equity

freeCollateral

Free collateral

leverage

Leverage of the subaccount

marginUsage

Margin usage of the account

buyingPower

Buying power

openPositions

All open positions

orders

Outstanding orders

marginEnabled

V4 only and should always be true

SubaccountPositions

An array of SubaccountPosition

SubaccountPosition

data class SubaccountPosition(
 val id: String,
 val assetId: String,
 val displayId: String,  val side: TradeStatesWithPositionSides,
 val entryPrice: TradeStatesWithDoubleValues?,
 val exitPrice: Double?,
 val createdAtMilliseconds: Double?,
 val closedAtMilliseconds: Double?,
 val netFunding: Double?,
 val realizedPnl: TradeStatesWithDoubleValues?,
 val realizedPnlPercent: TradeStatesWithDoubleValues?,
 val unrealizedPnl: TradeStatesWithDoubleValues?,
 val unrealizedPnlPercent: TradeStatesWithDoubleValues?,
 val size: TradeStatesWithDoubleValues?,
 val notionalTotal: TradeStatesWithDoubleValues?,
 val valueTotal: TradeStatesWithDoubleValues?,
 val initialRiskTotal: TradeStatesWithDoubleValues?,
 val adjustedImf: TradeStatesWithDoubleValues?,
 val leverage: TradeStatesWithDoubleValues?,
 val maxLeverage: TradeStatesWithDoubleValues?,
 val buyingPower: TradeStatesWithDoubleValues?,
 val liquidationPrice: TradeStatesWithDoubleValues?,
 val resources: SubaccountPositionResources
)

id

ID of the position, it should be the same as marketId

assetId

Asset ID, such as "ETH"

displayId

Displayable market ID.

side

LONG, SHORT or NONE

entryPrice

Entry price

exitPrice

Exit price

createdAtMilliseconds

When the position was created

closedAtMilliseconds

When the position was closed

netFunding

Total funding income or expense

realizedPnl

Total realized PNL

realizedPnlPercent

Total realized PNL as percent

unrealizedPnl

Total unrealized PNL

unrealizedPnlPercent

Total unrealized PNL as percent

size

Position size

notionalTotal

Notional total

valueTotal

Value total for the position

initialRiskTotal

Initial risk total

adjustedImf

Adjusted margin fraction

leverage

Leverage of the position

maxLeverage

Max leverage allowed for the position, calculated from adjustedImf

buyingPower

Buying power for the position

liquidationPrice

Liquidation price for the position

SubaccountPositionResources

data class SubaccountPositionResources(
 val sideStringKey: TradeStatesWithStringValues,
 val indicator: TradeStatesWithStringValues
)

sideStringKey

The localization string key to display side

indicator

The icon resource

SubaccountOrders

An array of SubaccountOrder

SubaccountOrder

data class SubaccountOrder(  val subaccountNumber: Int,  val id: String,
 val clientId: String?,
 val type: OrderType,
 val side: OrderSide,
 val status: OrderStatus,
 val timeInForce: OrderTimeInForce?,
 val marketId: String,  val displayId: String,  val clobPairId: Int?,
 val price: Double,
 val triggerPrice: Double?,
 val trailingPercent: Double?,
 val size: Double,
 val remainingSize: Double?,
 val totalFilled: Double?,
 val createdAtMilliseconds: Double?,
 val unfillableAtMilliseconds: Double?,
 val expiresAtMilliseconds: Double?,
 val postOnly: Boolean,
 val reduceOnly: Boolean,
 val cancelReason: String?,
 val resources: SubaccountOrderResources
)

subaccountNumber

The subaccount number that placed the order

id

Order ID

clientId

Client assigned ID. Randomly generated in Abacus

type

Order type

 market
 stopMarket
 takeProfitMarket
 limit
 stopLimit
 takeProfitLimit
 trailingStop
 liquidated
 liquidation

side

BUY or SELL

status

Order status

 cancelled
 bestEffortCancelled
 filled
 open
 pending
 untriggered

timeInForce

Time in force, GTT (Good Til Time) or IOC (Immediate or Cancel)

marketId

Market ID

displayId

Displayable market ID.

clobPairId

Clob Pair ID used by dYdX chain

price

Price

triggerPrice

Trigger price

trailingPercent

Trailing percent for Trailing Stop order

size

Size of the order

remainingSize

If the order has been partially executed, the remaining size

totalFilled

If the order has been partially executed, total size filled

createdAtMilliseconds

When the order was created

unfillableAtMilliseconds

Order was marked as unfillable

expiresAtMilliseconds

Expiration time

postOnly

Order is post-only

reduceOnly

Order is reduce-only

cancelReason

If order was canceled, the reason for cancellation

SubaccountOrderResources

data class SubaccountOrderResources(
 val sideStringKey: String,
 val typeStringKey: String?,
 val statusStringKey: String?,
 val timeInForceStringKey: String?
)

sideStringKey

Localization string key to display the side

typeStringKey

Localization string key to display the type

statusStringKey

Localization string key to display the status

timeInForceStringKey

Localization string key to display the timeInForce