/// import EventEmitter from 'events'; import { WsBalanceData, WsPosition, WsPositionData, WsPush, WsPushArg } from './type'; import { OkxWebSocketClient } from './ws-client'; export interface WsAssetInfo { availBal: string; availEq: string; ccy: string; cashBal: string; uTime: string; disEq: string; eq: string; eqUsd: string; frozenBal: string; interest: string; isoEq: string; liab: string; maxLoan: string; mgnRatio: string; notionalLever: string; ordFrozen: string; upl: string; uplLiab: string; crossLiab: string; isoLiab: string; coinUsdPrice: string; stgyEq: string; spotInUseAmt: string; isoUpl: string; borrowFroz: string; } export interface WsAccoutInfo { /** * The latest time to get account information, millisecond format of Unix timestamp, e.g. 1597026383085 */ uTime: string; /** * The total amount of equity in USD */ totalEq: string; /** * Isolated margin equity in USD * Applicable to Single-currency margin and Multi-currency margin and Portfolio margin */ isoEq: string; /** * Adjusted / Effective equity in USD * The net fiat value of the assets in the account that can provide margins for spot, futures, perpetual swap and options under the cross margin mode. * Cause in multi-ccy or PM mode, the asset and margin requirement will all be converted to USD value to process the order check or liquidation. * Due to the volatility of each currency market, our platform calculates the actual USD value of each currency based on discount rates to balance market risks. * Applicable to Multi-currency margin and Portfolio margin */ adjEq: string; /** * Margin frozen for pending cross orders in USD * Only applicable to Multi-currency margin */ ordFroz: string; /** * Initial margin requirement in USD * The sum of initial margins of all open positions and pending orders under cross margin mode in USD. * Applicable to Multi-currency margin and Portfolio margin */ imr: string; /** * Maintenance margin requirement in USD * The sum of maintenance margins of all open positions under cross margin mode in USD. * Applicable to Multi-currency margin and Portfolio margin */ mmr: string; /** * Potential borrowing IMR of the account in USD * Only applicable to Multi-currency margin and Portfolio margin. It is "" for other margin modes. */ borrowFroz: string; /** * Notional value of positions in USD * Applicable to Multi-currency margin and Portfolio margin */ notionalUsd: string; /** * Margin ratio in USD * The index for measuring the risk of a certain asset in the account. * Applicable to Multi-currency margin and Portfolio margin */ mgnRatio: string; details: WsAssetInfo[]; } export interface WsPushAccountArg extends WsPushArg { channel: 'account'; uid: string; ccy?: string; } export interface WsPushBalAndPosArg extends WsPushArg { channel: 'balance_and_position'; uid: string; } export interface WsPushPositionsArg extends WsPushArg { channel: 'positions'; } export interface WsBalAndPosData { pTime: string; eventType: string; balData: WsBalanceData[]; posData: WsPositionData[]; } export type WsPushAccount = WsPush; export type WsPushBalAndPos = WsPush; export type WsPushPositions = WsPush; export interface Account { emit(event: 'push-account', data: WsAccoutInfo[]): boolean; emit(event: 'push-balance_and_position', data: WsBalAndPosData[]): boolean; emit(event: 'push-positions', data: WsPosition[]): boolean; on(event: 'push-account', listerner: (data: WsAccoutInfo[]) => void): this; on(event: 'push-balance_and_position', listerner: (data: WsBalAndPosData[]) => void): this; on(event: 'push-positions', listener: (data: WsPosition[]) => void): this; } export declare class Account extends EventEmitter { private _okxWsClient; private _accountInfo; private _position; constructor(okxWsClient: OkxWebSocketClient); private _subscribe; private _subscribeAccount; private _handlePushAccount; private _handlePushBalAdnPos; private _handlePushPositions; get accountInfo(): WsAccoutInfo[] | undefined; get position(): WsPosition[] | undefined; }