forked from singlesly/bingx-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount-websocket-events.ts
More file actions
142 lines (125 loc) · 3.51 KB
/
Copy pathaccount-websocket-events.ts
File metadata and controls
142 lines (125 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { OrderPositionSideEnum, OrderSideEnum } from 'bingx-api/bingx';
export enum AccountWebsocketEventType {
LISTEN_KEY_EXPIRED = 'listenKeyExpired',
ACCOUNT_UPDATE = 'ACCOUNT_UPDATE',
ORDER_TRADE_UPDATE = 'ORDER_TRADE_UPDATE',
ACCOUNT_CONFIG_UPDATE = 'ACCOUNT_CONFIG_UPDATE',
}
export enum AccountUpdateEventLaunchReason {
DEPOSIT = 'DEPOSIT',
WITHDRAW = 'WITHDRAW',
ORDER = 'ORDER',
FUNDING_FEE = 'FUNDING_FEE',
}
export enum WebSocketOrderType {
MARKET = 'MARKET',
LIMIT = 'LIMIT',
STOP = 'STOP',
TAKE_PROFIT = 'TAKE_PROFIT',
LIQUIDATION = 'LIQUIDATION',
TRIGGER_MARKET = 'TRIGGER_MARKET',
}
export enum WebSocketOrderExecutionType {
NEW = 'NEW',
CANCELED = 'CANCELED',
CALCULATED = 'CALCULATED',
EXPIRED = 'EXPIRED',
TRADE = 'TRADE',
}
export enum WebSocketOrderStatus {
NEW = 'NEW',
PARTIALLY_FILLED = 'PARTIALLY_FILLED',
FILLED = 'FILLED',
CANCELED = 'CANCELED',
EXPIRED = 'EXPIRED',
}
export enum WebSocketTriggerPriceType {
MARK_PRICE = 'MARK_PRICE',
CONTRACT_PRICE = 'CONTRACT_PRICE',
INDEX_PRICE = 'INDEX_PRICE',
}
export type EventTimeInMilliseconds = string;
/**
* Relates account events
*/
export type AssetName = string;
export type WalletBalance = number;
export type WalletBalanceExcludingIsolatedMargin = number;
export type WalletBalanceChangeAmount = number;
export type TradingPair = `${string}-${string}`;
export type Position = number;
export type EntryPrice = number;
export type UnrealizedProfitAndLossPosition = number;
export type MarginMode = string;
export type IsolatedPositionMargin = number;
/**
* Relates to order update events
*/
export type ClientCustomOrderId = string;
export type OrderId = string;
export type Quantity = string;
export type Price = string;
export type AveragePrice = string;
export type HandlingFee = string;
export type TransactionTime = string;
export type TransactionAchievedProfitAndLoss = string;
export type OrderFilledAccumulatedQuantity = string;
export type FeeAssetType = string;
export interface AccountBalanceInformation {
a: AssetName;
wb: WalletBalance;
cw: WalletBalanceExcludingIsolatedMargin;
bc: WalletBalanceChangeAmount;
}
export interface TradeInfo {
s: TradingPair;
pa: Position;
ep: EntryPrice;
up: UnrealizedProfitAndLossPosition;
mt: MarginMode;
iw: IsolatedPositionMargin;
ps: OrderPositionSideEnum;
}
export interface AccountWebSocketOrder {
s: TradingPair;
c: ClientCustomOrderId;
i: OrderId;
S: OrderSideEnum;
o: WebSocketOrderType;
q: Quantity;
p: Price;
ap: AveragePrice;
x: WebSocketOrderExecutionType;
X: WebSocketOrderStatus;
N: FeeAssetType;
n: HandlingFee;
T: TransactionTime;
wt: WebSocketTriggerPriceType;
ps: OrderPositionSideEnum;
rp: TransactionAchievedProfitAndLoss;
z: OrderFilledAccumulatedQuantity;
}
export interface AccountUpdateEvent {
m: AccountUpdateEventLaunchReason;
B: AccountBalanceInformation[];
P: TradeInfo[];
}
export interface AccountWebSocketEvent {
e: AccountWebsocketEventType;
E: EventTimeInMilliseconds;
}
export interface ListenKeyExpiredEvent extends AccountWebSocketEvent {
e: AccountWebsocketEventType.LISTEN_KEY_EXPIRED;
listenKey: string;
}
export interface AccountBalanceAndPositionPushEvent
extends AccountWebSocketEvent {
e: AccountWebsocketEventType.ACCOUNT_UPDATE;
T: EventTimeInMilliseconds;
a: AccountUpdateEvent;
}
export interface AccountOrderUpdatePushEvent extends AccountWebSocketEvent {
e: AccountWebsocketEventType.ORDER_TRADE_UPDATE;
E: EventTimeInMilliseconds;
o: AccountWebSocketOrder;
}