Namespace: account
@orderly.network/perp.accountTable of contents
Type Aliases
- AccountMMRInputs
- AvailableBalanceInputs
- FreeCollateralInputs
- IMRInputs
- MaxQtyInputs
- OtherIMsInputs
- PositionNotionalWithOrderInputs
- PositionQtyWithOrderInputs
- ResultOptions
- TotalCollateralValueInputs
- TotalInitialMarginWithOrdersInputs
- TotalMarginRatioInputs
- TotalUnrealizedROIInputs
- TotalValueInputs
Functions
- IMR
- MMR
- availableBalance
- buyOrdersFilter_by_symbol
- currentLeverage
- extractSymbols
- freeCollateral
- getPositonsAndOrdersNotionalBySymbol
- getQtyFromOrdersBySide
- getQtyFromPositions
- groupOrdersBySymbol
- initialMarginWithOrder
- maxQty
- maxQtyByLong
- maxQtyByShort
- otherIMs
- positionNotionalWithOrder_by_symbol
- positionQtyWithOrders_by_symbol
- sellOrdersFilter_by_symbol
- totalCollateral
- totalInitialMarginWithOrders
- totalInitialMarginWithQty
- totalMarginRatio
- totalUnrealizedROI
- totalValue
Type Aliases
AccountMMRInputs
Ƭ AccountMMRInputs:Object
Type declaration
Name | Type | Description |
---|---|---|
positionsMMR | number | - |
positionsNotional | number | Notional sum of all positions, positions.totalNotional() |
Defined in
account.ts:718AvailableBalanceInputs
Ƭ AvailableBalanceInputs:Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
unsettlementPnL | number |
Defined in
account.ts:708FreeCollateralInputs
Ƭ FreeCollateralInputs:Object
Total value of available collateral in the user’s account (denominated in USDC).
Type declaration
Name | Type |
---|---|
totalCollateral | Decimal |
totalInitialMarginWithOrders | number |
Defined in
account.ts:41IMRInputs
Ƭ IMRInputs:Object
Type declaration
Name | Type |
---|---|
IMR_Factor | number |
IMR_factor_power? | number |
baseIMR | number |
maxLeverage | number |
ordersNotional | number |
positionNotional | number |
Defined in
account.ts:123MaxQtyInputs
Ƭ MaxQtyInputs:Object
Type declaration
Name | Type | Description |
---|---|---|
IMR_Factor | number | - |
baseIMR | number | - |
baseMaxQty | number | - |
buyOrdersQty | number | - |
markPrice | number | - |
maxLeverage | number | - |
otherIMs | number | See otherIMs |
positionQty | number | - |
sellOrdersQty | number | - |
symbol | string | - |
takerFeeRate | number | - |
totalCollateral | number | Total collateral of the user (denominated in USDC), can be calculated from totalCollateral. See totalCollateral |
Defined in
account.ts:483OtherIMsInputs
Ƭ OtherIMsInputs:Object
Type declaration
Name | Type |
---|---|
IMR_Factors | { [key: string] : number ; } |
markPrices | { [key: string] : number ; } |
maxLeverage | number |
orders | Order [] |
positions | Position [] |
symbolInfo | any |
Defined in
account.ts:396PositionNotionalWithOrderInputs
Ƭ PositionNotionalWithOrderInputs:Object
Type declaration
Name | Type |
---|---|
markPrice | number |
positionQtyWithOrders | number |
Defined in
account.ts:87PositionQtyWithOrderInputs
Ƭ PositionQtyWithOrderInputs:Object
Type declaration
Name | Type |
---|---|
buyOrdersQty | number |
positionQty | number |
sellOrdersQty | number |
Defined in
account.ts:100ResultOptions
Ƭ ResultOptions:Object
Type declaration
Name | Type |
---|---|
dp | number |
Defined in
account.ts:10TotalCollateralValueInputs
Ƭ TotalCollateralValueInputs:Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
nonUSDCHolding | { discount : number ; holding : number ; markPrice : number }[] |
unsettlementPnL | number |
Defined in
account.ts:56TotalInitialMarginWithOrdersInputs
Ƭ TotalInitialMarginWithOrdersInputs: {IMR_Factors
: { [key: string]
: number
; } ; markPrices
: { [key: string]
: number
; } ; orders
: Order
[] ; positions
: Position
[] ; symbolInfo
: any
} & Pick
<IMRInputs
, "maxLeverage"
>
Defined in
account.ts:228TotalMarginRatioInputs
Ƭ TotalMarginRatioInputs:Object
Type declaration
Name | Type |
---|---|
markPrices | { [key: string] : number ; } |
positions | Position [] |
totalCollateral | number |
Defined in
account.ts:650TotalUnrealizedROIInputs
Ƭ TotalUnrealizedROIInputs:Object
Type declaration
Name | Type |
---|---|
totalUnrealizedPnL | number |
totalValue | number |
Defined in
account.ts:682TotalValueInputs
Ƭ TotalValueInputs:Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
nonUSDCHolding | { discount : number ; holding : number ; markPrice : number }[] |
totalUnsettlementPnL | number |
Defined in
account.ts:14Functions
IMR
▸ IMR(inputs
): number
Initial margin rate for a symbol.
Max(1 / Max Account Leverage, Base IMR i, IMR Factor i * Abs(Position Notional i + Order Notional i)^(4/5))
Parameters
Name | Type |
---|---|
inputs | IMRInputs |
Returns
number
Defined in
account.ts:136MMR
▸ MMR(inputs
): number
| null
total maintenance margin ratio
Parameters
Name | Type | Description |
---|---|---|
inputs | AccountMMRInputs | AccountMMRInputs |
Returns
number
| null
number|null
Defined in
account.ts:733availableBalance
▸ availableBalance(inputs
): number
Parameters
Name | Type |
---|---|
inputs | AvailableBalanceInputs |
Returns
number
Defined in
account.ts:712buyOrdersFilter_by_symbol
▸ buyOrdersFilter_by_symbol(orders
, symbol
): Order
[]
Parameters
Name | Type |
---|---|
orders | Order [] |
symbol | string |
Returns
Order
[]
Defined in
account.ts:159currentLeverage
▸ currentLeverage(totalMarginRatio
): number
current account leverage
Parameters
Name | Type |
---|---|
totalMarginRatio | number |
Returns
number
Defined in
account.ts:701extractSymbols
▸ extractSymbols(positions
, orders
): string
[]
Extracts all unique symbols from positions and orders.
Parameters
Name | Type | Description |
---|---|---|
positions | Pick <Position , "symbol" >[] | An array of position objects. |
orders | Pick <Order , "symbol" >[] | An array of order objects. |
Returns
string
[]
An array of unique symbols.
Defined in
account.ts:375freeCollateral
▸ freeCollateral(inputs
): Decimal
Calculate free collateral.
Parameters
Name | Type |
---|---|
inputs | FreeCollateralInputs |
Returns
Decimal
Defined in
account.ts:50getPositonsAndOrdersNotionalBySymbol
▸ getPositonsAndOrdersNotionalBySymbol(inputs
): number
Parameters
Name | Type |
---|---|
inputs | Object |
inputs.markPrice | number |
inputs.orders | Order [] |
inputs.positions | Position [] |
inputs.symbol | string |
Returns
number
Defined in
account.ts:208getQtyFromOrdersBySide
▸ getQtyFromOrdersBySide(orders
, symbol
, side
): number
Get the quantity of long and short orders for a specified symbol from the list of orders.
Parameters
Name | Type |
---|---|
orders | Order [] |
symbol | string |
side | OrderSide |
Returns
number
Defined in
account.ts:194getQtyFromPositions
▸ getQtyFromPositions(positions
, symbol
): number
Get the quantity of a specified symbol from the list of positions.
Parameters
Name | Type |
---|---|
positions | Position [] |
symbol | string |
Returns
number
Defined in
account.ts:180groupOrdersBySymbol
▸ groupOrdersBySymbol(orders
): Object
Group orders by symbol, as a symbol can have multiple orders.
Parameters
Name | Type |
---|---|
orders | Order [] |
Returns
Object
Defined in
account.ts:355initialMarginWithOrder
▸ initialMarginWithOrder():void
Returns
void
Defined in
account.ts:85maxQty
▸ maxQty(side
, inputs
, options?
): number
Maximum order quantity.
Parameters
Name | Type |
---|---|
side | OrderSide |
inputs | MaxQtyInputs |
options? | ResultOptions |
Returns
number
Defined in
account.ts:515maxQtyByLong
▸ maxQtyByLong(inputs
, options?
): number
Parameters
Name | Type |
---|---|
inputs | Omit <MaxQtyInputs , "side" > |
options? | ResultOptions |
Returns
number
Defined in
account.ts:526maxQtyByShort
▸ maxQtyByShort(inputs
, options?
): number
Parameters
Name | Type |
---|---|
inputs | Omit <MaxQtyInputs , "side" > |
options? | ResultOptions |
Returns
number
Defined in
account.ts:587otherIMs
▸ otherIMs(inputs
): number
Total margin used by other symbols (except the current symbol).
Parameters
Name | Type |
---|---|
inputs | OtherIMsInputs |
Returns
number
Defined in
account.ts:410positionNotionalWithOrder_by_symbol
▸ positionNotionalWithOrder_by_symbol(inputs
): Decimal
Sum of notional value for a symbol’s position and orders.
Parameters
Name | Type |
---|---|
inputs | PositionNotionalWithOrderInputs |
Returns
Decimal
Defined in
account.ts:94positionQtyWithOrders_by_symbol
▸ positionQtyWithOrders_by_symbol(inputs
): number
Sum of position quantity and orders quantity for a symbol.
Parameters
Name | Type |
---|---|
inputs | PositionQtyWithOrderInputs |
Returns
number
Defined in
account.ts:110sellOrdersFilter_by_symbol
▸ sellOrdersFilter_by_symbol(orders
, symbol
): Order
[]
Parameters
Name | Type |
---|---|
orders | Order [] |
symbol | string |
Returns
Order
[]
Defined in
account.ts:168totalCollateral
▸ totalCollateral(inputs
): Decimal
Calculate total collateral.
Parameters
Name | Type |
---|---|
inputs | TotalCollateralValueInputs |
Returns
Decimal
Defined in
account.ts:71totalInitialMarginWithOrders
▸ totalInitialMarginWithOrders(inputs
): number
Calculate the total initial margin used by the user (including positions and orders).
Parameters
Name | Type |
---|---|
inputs | TotalInitialMarginWithOrdersInputs |
Returns
number
Defined in
account.ts:240totalInitialMarginWithQty
▸ totalInitialMarginWithQty(inputs
): number
Parameters
Name | Type |
---|---|
inputs | Object |
inputs.IMR_Factors | Object |
inputs.markPrices | Object |
inputs.maxLeverage | number |
inputs.positions | Position [] |
inputs.symbolInfo | any |
Returns
number
Defined in
account.ts:298totalMarginRatio
▸ totalMarginRatio(inputs
, dp?
): number
total margin ratio
Parameters
Name | Type |
---|---|
inputs | TotalMarginRatioInputs |
dp? | number |
Returns
number
Defined in
account.ts:658totalUnrealizedROI
▸ totalUnrealizedROI(inputs
): number
totalUnrealizedROI
Parameters
Name | Type |
---|---|
inputs | TotalUnrealizedROIInputs |
Returns
number
Defined in
account.ts:690totalValue
▸ totalValue(inputs
): Decimal
User’s total asset value (denominated in USDC), including assets that cannot be used as collateral.
Parameters
Name | Type |
---|---|
inputs | TotalValueInputs |
Returns
Decimal