Orderly SDKs / Modules / @orderly.network/perp / account

Namespace: account

@orderly.network/perp.account

Table of contents

Type Aliases

Functions

Type Aliases

AccountMMRInputs

Ƭ AccountMMRInputs: Object

Type declaration

NameTypeDescription
positionsMMRnumber-
positionsNotionalnumberNotional sum of all positions, positions.totalNotional()

Defined in

account.ts:718


AvailableBalanceInputs

Ƭ AvailableBalanceInputs: Object

Type declaration

NameType
USDCHoldingnumber
unsettlementPnLnumber

Defined in

account.ts:708


FreeCollateralInputs

Ƭ FreeCollateralInputs: Object

Total value of available collateral in the user’s account (denominated in USDC).

Type declaration

NameType
totalCollateralDecimal
totalInitialMarginWithOrdersnumber

Defined in

account.ts:41


IMRInputs

Ƭ IMRInputs: Object

Type declaration

NameType
IMR_Factornumber
IMR_factor_power?number
baseIMRnumber
maxLeveragenumber
ordersNotionalnumber
positionNotionalnumber

Defined in

account.ts:123


MaxQtyInputs

Ƭ MaxQtyInputs: Object

Type declaration

NameTypeDescription
IMR_Factornumber-
baseIMRnumber-
baseMaxQtynumber-
buyOrdersQtynumber-
markPricenumber-
maxLeveragenumber-
otherIMsnumberSee otherIMs
positionQtynumber-
sellOrdersQtynumber-
symbolstring-
takerFeeRatenumber-
totalCollateralnumberTotal collateral of the user (denominated in USDC), can be calculated from totalCollateral. See totalCollateral

Defined in

account.ts:483


OtherIMsInputs

Ƭ OtherIMsInputs: Object

Type declaration

NameType
IMR_Factors{ [key: string]: number; }
markPrices{ [key: string]: number; }
maxLeveragenumber
ordersOrder[]
positionsPosition[]
symbolInfoany

Defined in

account.ts:396


PositionNotionalWithOrderInputs

Ƭ PositionNotionalWithOrderInputs: Object

Type declaration

NameType
markPricenumber
positionQtyWithOrdersnumber

Defined in

account.ts:87


PositionQtyWithOrderInputs

Ƭ PositionQtyWithOrderInputs: Object

Type declaration

NameType
buyOrdersQtynumber
positionQtynumber
sellOrdersQtynumber

Defined in

account.ts:100


ResultOptions

Ƭ ResultOptions: Object

Type declaration

NameType
dpnumber

Defined in

account.ts:10


TotalCollateralValueInputs

Ƭ TotalCollateralValueInputs: Object

Type declaration

NameType
USDCHoldingnumber
nonUSDCHolding{ discount: number ; holding: number ; markPrice: number }[]
unsettlementPnLnumber

Defined in

account.ts:56


TotalInitialMarginWithOrdersInputs

Ƭ TotalInitialMarginWithOrdersInputs: { IMR_Factors: { [key: string]: number; } ; markPrices: { [key: string]: number; } ; orders: Order[] ; positions: Position[] ; symbolInfo: any } & Pick<IMRInputs, "maxLeverage">

Defined in

account.ts:228


TotalMarginRatioInputs

Ƭ TotalMarginRatioInputs: Object

Type declaration

NameType
markPrices{ [key: string]: number; }
positionsPosition[]
totalCollateralnumber

Defined in

account.ts:650


TotalUnrealizedROIInputs

Ƭ TotalUnrealizedROIInputs: Object

Type declaration

NameType
totalUnrealizedPnLnumber
totalValuenumber

Defined in

account.ts:682


TotalValueInputs

Ƭ TotalValueInputs: Object

Type declaration

NameType
USDCHoldingnumber
nonUSDCHolding{ discount: number ; holding: number ; markPrice: number }[]
totalUnsettlementPnLnumber

Defined in

account.ts:14

Functions

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

NameType
inputsIMRInputs

Returns

number

Defined in

account.ts:136


MMR

MMR(inputs): number | null

total maintenance margin ratio

Parameters

NameTypeDescription
inputsAccountMMRInputsAccountMMRInputs

Returns

number | null

number|null

Defined in

account.ts:733


availableBalance

availableBalance(inputs): number

Parameters

NameType
inputsAvailableBalanceInputs

Returns

number

Defined in

account.ts:712


buyOrdersFilter_by_symbol

buyOrdersFilter_by_symbol(orders, symbol): Order[]

Parameters

NameType
ordersOrder[]
symbolstring

Returns

Order[]

Defined in

account.ts:159


currentLeverage

currentLeverage(totalMarginRatio): number

current account leverage

Parameters

NameType
totalMarginRationumber

Returns

number

Defined in

account.ts:701


extractSymbols

extractSymbols(positions, orders): string[]

Extracts all unique symbols from positions and orders.

Parameters

NameTypeDescription
positionsPick<Position, "symbol">[]An array of position objects.
ordersPick<Order, "symbol">[]An array of order objects.

Returns

string[]

An array of unique symbols.

Defined in

account.ts:375


freeCollateral

freeCollateral(inputs): Decimal

Calculate free collateral.

Parameters

NameType
inputsFreeCollateralInputs

Returns

Decimal

Defined in

account.ts:50


getPositonsAndOrdersNotionalBySymbol

getPositonsAndOrdersNotionalBySymbol(inputs): number

Parameters

NameType
inputsObject
inputs.markPricenumber
inputs.ordersOrder[]
inputs.positionsPosition[]
inputs.symbolstring

Returns

number

Defined in

account.ts:208


getQtyFromOrdersBySide

getQtyFromOrdersBySide(orders, symbol, side): number

Get the quantity of long and short orders for a specified symbol from the list of orders.

Parameters

NameType
ordersOrder[]
symbolstring
sideOrderSide

Returns

number

Defined in

account.ts:194


getQtyFromPositions

getQtyFromPositions(positions, symbol): number

Get the quantity of a specified symbol from the list of positions.

Parameters

NameType
positionsPosition[]
symbolstring

Returns

number

Defined in

account.ts:180


groupOrdersBySymbol

groupOrdersBySymbol(orders): Object

Group orders by symbol, as a symbol can have multiple orders.

Parameters

NameType
ordersOrder[]

Returns

Object

Defined in

account.ts:355


initialMarginWithOrder

initialMarginWithOrder(): void

Returns

void

Defined in

account.ts:85


maxQty

maxQty(side, inputs, options?): number

Maximum order quantity.

Parameters

NameType
sideOrderSide
inputsMaxQtyInputs
options?ResultOptions

Returns

number

Defined in

account.ts:515


maxQtyByLong

maxQtyByLong(inputs, options?): number

Parameters

NameType
inputsOmit<MaxQtyInputs, "side">
options?ResultOptions

Returns

number

Defined in

account.ts:526


maxQtyByShort

maxQtyByShort(inputs, options?): number

Parameters

NameType
inputsOmit<MaxQtyInputs, "side">
options?ResultOptions

Returns

number

Defined in

account.ts:587


otherIMs

otherIMs(inputs): number

Total margin used by other symbols (except the current symbol).

Parameters

NameType
inputsOtherIMsInputs

Returns

number

Defined in

account.ts:410


positionNotionalWithOrder_by_symbol

positionNotionalWithOrder_by_symbol(inputs): Decimal

Sum of notional value for a symbol’s position and orders.

Parameters

NameType
inputsPositionNotionalWithOrderInputs

Returns

Decimal

Defined in

account.ts:94


positionQtyWithOrders_by_symbol

positionQtyWithOrders_by_symbol(inputs): number

Sum of position quantity and orders quantity for a symbol.

Parameters

NameType
inputsPositionQtyWithOrderInputs

Returns

number

Defined in

account.ts:110


sellOrdersFilter_by_symbol

sellOrdersFilter_by_symbol(orders, symbol): Order[]

Parameters

NameType
ordersOrder[]
symbolstring

Returns

Order[]

Defined in

account.ts:168


totalCollateral

totalCollateral(inputs): Decimal

Calculate total collateral.

Parameters

NameType
inputsTotalCollateralValueInputs

Returns

Decimal

Defined in

account.ts:71


totalInitialMarginWithOrders

totalInitialMarginWithOrders(inputs): number

Calculate the total initial margin used by the user (including positions and orders).

Parameters

NameType
inputsTotalInitialMarginWithOrdersInputs

Returns

number

Defined in

account.ts:240


totalInitialMarginWithQty

totalInitialMarginWithQty(inputs): number

Parameters

NameType
inputsObject
inputs.IMR_FactorsObject
inputs.markPricesObject
inputs.maxLeveragenumber
inputs.positionsPosition[]
inputs.symbolInfoany

Returns

number

Defined in

account.ts:298


totalMarginRatio

totalMarginRatio(inputs, dp?): number

total margin ratio

Parameters

NameType
inputsTotalMarginRatioInputs
dp?number

Returns

number

Defined in

account.ts:658


totalUnrealizedROI

totalUnrealizedROI(inputs): number

totalUnrealizedROI

Parameters

NameType
inputsTotalUnrealizedROIInputs

Returns

number

Defined in

account.ts:690


totalValue

totalValue(inputs): Decimal

User’s total asset value (denominated in USDC), including assets that cannot be used as collateral.

Parameters

NameType
inputsTotalValueInputs

Returns

Decimal

Defined in

account.ts:28