account in PerpetualState is an object, containing a map of String to Subaccount
data class Account(
var subaccounts: Map<String, Subaccount>?,
var 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>?
)
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.
Same as filledHistory except all empty (0) rewards periods will be removed from the lists.
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?
)
Sequential number for the subaccount
Not used
Total PNL
24-hour PNL
24-hour PNL percentage change
Calculated quote balance
Notional total of the positions
Total value of the positions
Total initial risk
Adjusted margin fraction
Total equity
Free collateral
Leverage of the subaccount
Margin usage of the account
Buying power
All open positions
Outstanding orders
V4 only and should always be true
An array of 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 of the position, it should be the same as marketId
Asset ID, such as "ETH"
Displayable market ID.
LONG, SHORT or NONE
Entry price
Exit price
When the position was created
When the position was closed
Total funding income or expense
Total realized PNL
Total realized PNL as percent
Total unrealized PNL
Total unrealized PNL as percent
Position size
Notional total
Value total for the position
Initial risk total
Adjusted margin fraction
Leverage of the position
Max leverage allowed for the position, calculated from adjustedImf
Buying power for the position
Liquidation price for the position
data class SubaccountPositionResources(
val sideStringKey: TradeStatesWithStringValues,
val indicator: TradeStatesWithStringValues
)
The localization string key to display side
The icon resource
An array of 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
)
The subaccount number that placed the order
Order ID
Client assigned ID. Randomly generated in Abacus
Order type
market
stopMarket
takeProfitMarket
limit
stopLimit
takeProfitLimit
trailingStop
liquidated
liquidation
BUY or SELL
Order status
cancelled
bestEffortCancelled
filled
open
pending
untriggered
Time in force, GTT (Good Til Time) or IOC (Immediate or Cancel)
Market ID
Displayable market ID.
Clob Pair ID used by dYdX chain
Price
Trigger price
Trailing percent for Trailing Stop order
Size of the order
If the order has been partially executed, the remaining size
If the order has been partially executed, total size filled
When the order was created
Order was marked as unfillable
Expiration time
Order is post-only
Order is reduce-only
If order was canceled, the reason for cancellation
data class SubaccountOrderResources(
val sideStringKey: String,
val typeStringKey: String?,
val statusStringKey: String?,
val timeInForceStringKey: String?
)
Localization string key to display the side
Localization string key to display the type
Localization string key to display the status
Localization string key to display the timeInForce