Orderly network perp.account
Orderly SDKs / Modules / @orderly.network/perp / account
Namespace: account
@orderly.network/perp.account
Table 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
AvailableBalanceInputs
Ƭ AvailableBalanceInputs: Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
unsettlementPnL | number |
Defined in
FreeCollateralInputs
Ƭ 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
IMRInputs
Ƭ IMRInputs: Object
Type declaration
Name | Type |
---|---|
IMR_Factor | number |
IMR_factor_power? | number |
baseIMR | number |
maxLeverage | number |
ordersNotional | number |
positionNotional | number |
Defined in
MaxQtyInputs
Ƭ 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
OtherIMsInputs
Ƭ 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
PositionNotionalWithOrderInputs
Ƭ PositionNotionalWithOrderInputs: Object
Type declaration
Name | Type |
---|---|
markPrice | number |
positionQtyWithOrders | number |
Defined in
PositionQtyWithOrderInputs
Ƭ PositionQtyWithOrderInputs: Object
Type declaration
Name | Type |
---|---|
buyOrdersQty | number |
positionQty | number |
sellOrdersQty | number |
Defined in
ResultOptions
Ƭ ResultOptions: Object
Type declaration
Name | Type |
---|---|
dp | number |
Defined in
TotalCollateralValueInputs
Ƭ TotalCollateralValueInputs: Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
nonUSDCHolding | { discount : number ; holding : number ; markPrice : number }[] |
unsettlementPnL | number |
Defined in
TotalInitialMarginWithOrdersInputs
Ƭ TotalInitialMarginWithOrdersInputs: { IMR_Factors
: { [key: string]
: number
; } ; markPrices
: { [key: string]
: number
; } ; orders
: Order
[] ; positions
: Position
[] ; symbolInfo
: any
} & Pick
<IMRInputs
, "maxLeverage"
>
Defined in
TotalMarginRatioInputs
Ƭ TotalMarginRatioInputs: Object
Type declaration
Name | Type |
---|---|
markPrices | { [key: string] : number ; } |
positions | Position [] |
totalCollateral | number |
Defined in
TotalUnrealizedROIInputs
Ƭ TotalUnrealizedROIInputs: Object
Type declaration
Name | Type |
---|---|
totalUnrealizedPnL | number |
totalValue | number |
Defined in
TotalValueInputs
Ƭ TotalValueInputs: Object
Type declaration
Name | Type |
---|---|
USDCHolding | number |
nonUSDCHolding | { discount : number ; holding : number ; markPrice : number }[] |
totalUnsettlementPnL | number |
Defined in
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
Name | Type |
---|---|
inputs | IMRInputs |
Returns
number
Defined in
MMR
▸ MMR(inputs
): number
| null
total maintenance margin ratio
Parameters
Name | Type | Description |
---|---|---|
inputs | AccountMMRInputs | AccountMMRInputs |
Returns
number
| null
number|null
Defined in
availableBalance
▸ availableBalance(inputs
): number
Parameters
Name | Type |
---|---|
inputs | AvailableBalanceInputs |
Returns
number
Defined in
buyOrdersFilter_by_symbol
▸ buyOrdersFilter_by_symbol(orders
, symbol
): Order
[]
Parameters
Name | Type |
---|---|
orders | Order [] |
symbol | string |
Returns
Order
[]
Defined in
currentLeverage
▸ currentLeverage(totalMarginRatio
): number
current account leverage
Parameters
Name | Type |
---|---|
totalMarginRatio | number |
Returns
number
Defined in
extractSymbols
▸ 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
freeCollateral
▸ freeCollateral(inputs
): Decimal
Calculate free collateral.
Parameters
Name | Type |
---|---|
inputs | FreeCollateralInputs |
Returns
Decimal
Defined in
getPositonsAndOrdersNotionalBySymbol
▸ getPositonsAndOrdersNotionalBySymbol(inputs
): number
Parameters
Name | Type |
---|---|
inputs | Object |
inputs.markPrice | number |
inputs.orders | Order [] |
inputs.positions | Position [] |
inputs.symbol | string |
Returns
number
Defined in
getQtyFromOrdersBySide
▸ 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
getQtyFromPositions
▸ 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
groupOrdersBySymbol
▸ groupOrdersBySymbol(orders
): Object
Group orders by symbol, as a symbol can have multiple orders.
Parameters
Name | Type |
---|---|
orders | Order [] |
Returns
Object
Defined in
initialMarginWithOrder
▸ initialMarginWithOrder(): void
Returns
void
Defined in
maxQty
▸ maxQty(side
, inputs
, options?
): number
Maximum order quantity.
Parameters
Name | Type |
---|---|
side | OrderSide |
inputs | MaxQtyInputs |
options? | ResultOptions |
Returns
number
Defined in
maxQtyByLong
▸ maxQtyByLong(inputs
, options?
): number
Parameters
Name | Type |
---|---|
inputs | Omit <MaxQtyInputs , "side" > |
options? | ResultOptions |
Returns
number
Defined in
maxQtyByShort
▸ maxQtyByShort(inputs
, options?
): number
Parameters
Name | Type |
---|---|
inputs | Omit <MaxQtyInputs , "side" > |
options? | ResultOptions |
Returns
number
Defined in
otherIMs
▸ otherIMs(inputs
): number
Total margin used by other symbols (except the current symbol).
Parameters
Name | Type |
---|---|
inputs | OtherIMsInputs |
Returns
number
Defined in
positionNotionalWithOrder_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
positionQtyWithOrders_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
sellOrdersFilter_by_symbol
▸ sellOrdersFilter_by_symbol(orders
, symbol
): Order
[]
Parameters
Name | Type |
---|---|
orders | Order [] |
symbol | string |
Returns
Order
[]
Defined in
totalCollateral
▸ totalCollateral(inputs
): Decimal
Calculate total collateral.
Parameters
Name | Type |
---|---|
inputs | TotalCollateralValueInputs |
Returns
Decimal
Defined in
totalInitialMarginWithOrders
▸ 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
totalInitialMarginWithQty
▸ 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
totalMarginRatio
▸ totalMarginRatio(inputs
, dp?
): number
total margin ratio
Parameters
Name | Type |
---|---|
inputs | TotalMarginRatioInputs |
dp? | number |
Returns
number
Defined in
totalUnrealizedROI
▸ totalUnrealizedROI(inputs
): number
totalUnrealizedROI
Parameters
Name | Type |
---|---|
inputs | TotalUnrealizedROIInputs |
Returns
number
Defined in
totalValue
▸ 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