ccxt 4.5.26 → 4.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/zebpay.js +11 -0
- package/dist/cjs/src/base/Exchange.js +2 -2
- package/dist/cjs/src/binance.js +18 -7
- package/dist/cjs/src/bingx.js +5 -5
- package/dist/cjs/src/bitget.js +18 -17
- package/dist/cjs/src/bitmex.js +5 -1
- package/dist/cjs/src/blofin.js +5 -5
- package/dist/cjs/src/bybit.js +58 -29
- package/dist/cjs/src/coincatch.js +9 -9
- package/dist/cjs/src/coinex.js +93 -0
- package/dist/cjs/src/coinmate.js +20 -0
- package/dist/cjs/src/coinsph.js +23 -0
- package/dist/cjs/src/cryptocom.js +7 -0
- package/dist/cjs/src/gate.js +2 -0
- package/dist/cjs/src/hyperliquid.js +12 -15
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/whitebit.js +4 -2
- package/dist/cjs/src/zebpay.js +1908 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/binance.d.ts +3 -1
- package/js/src/abstract/binancecoinm.d.ts +3 -1
- package/js/src/abstract/binanceus.d.ts +3 -1
- package/js/src/abstract/binanceusdm.d.ts +3 -1
- package/js/src/abstract/coinex.d.ts +16 -0
- package/js/src/abstract/coinmate.d.ts +3 -0
- package/js/src/abstract/coinsph.d.ts +21 -0
- package/js/src/abstract/cryptocom.d.ts +7 -0
- package/js/src/abstract/gate.d.ts +2 -0
- package/js/src/abstract/gateio.d.ts +2 -0
- package/js/src/abstract/zebpay.d.ts +49 -0
- package/js/src/abstract/zebpay.js +11 -0
- package/js/src/base/Exchange.js +2 -2
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +18 -7
- package/js/src/bingx.js +5 -5
- package/js/src/bitget.js +19 -18
- package/js/src/bitmex.js +5 -1
- package/js/src/blofin.js +5 -5
- package/js/src/bybit.d.ts +3 -0
- package/js/src/bybit.js +58 -29
- package/js/src/coincatch.js +9 -9
- package/js/src/coinex.d.ts +11 -0
- package/js/src/coinex.js +93 -0
- package/js/src/coinmate.d.ts +9 -0
- package/js/src/coinmate.js +20 -0
- package/js/src/coinsph.js +23 -0
- package/js/src/cryptocom.js +7 -0
- package/js/src/gate.js +2 -0
- package/js/src/hyperliquid.js +12 -15
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/whitebit.js +4 -2
- package/js/src/zebpay.d.ts +361 -0
- package/js/src/zebpay.js +1907 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1908 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var zebpay$1 = require('./abstract/zebpay.js');
|
|
6
|
+
var number = require('./base/functions/number.js');
|
|
7
|
+
var errors = require('./base/errors.js');
|
|
8
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
9
|
+
var Precise = require('./base/Precise.js');
|
|
10
|
+
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* @class
|
|
15
|
+
* @augments Exchange
|
|
16
|
+
*/
|
|
17
|
+
class zebpay extends zebpay$1["default"] {
|
|
18
|
+
describe() {
|
|
19
|
+
return this.deepExtend(super.describe(), {
|
|
20
|
+
'id': 'zebpay',
|
|
21
|
+
'name': 'Zebpay',
|
|
22
|
+
'countries': ['IN'],
|
|
23
|
+
'rateLimit': 50,
|
|
24
|
+
'version': 'v1',
|
|
25
|
+
'certified': false,
|
|
26
|
+
'pro': false,
|
|
27
|
+
'has': {
|
|
28
|
+
'CORS': undefined,
|
|
29
|
+
'spot': true,
|
|
30
|
+
'margin': false,
|
|
31
|
+
'swap': true,
|
|
32
|
+
'future': false,
|
|
33
|
+
'option': undefined,
|
|
34
|
+
'addMargin': true,
|
|
35
|
+
'cancelAllOrders': true,
|
|
36
|
+
'cancelOrder': true,
|
|
37
|
+
'cancelOrders': false,
|
|
38
|
+
'closePosition': true,
|
|
39
|
+
'createOrder': true,
|
|
40
|
+
'fetchBalance': true,
|
|
41
|
+
'fetchCurrencies': true,
|
|
42
|
+
'fetchLeverage': true,
|
|
43
|
+
'fetchLeverages': true,
|
|
44
|
+
'fetchMarkets': true,
|
|
45
|
+
'fetchMyTrades': true,
|
|
46
|
+
'fetchOHLCV': true,
|
|
47
|
+
'fetchOpenOrders': true,
|
|
48
|
+
'fetchOrder': true,
|
|
49
|
+
'fetchOrderBook': true,
|
|
50
|
+
'fetchOrderTrades': true,
|
|
51
|
+
'fetchPositions': true,
|
|
52
|
+
'fetchTicker': true,
|
|
53
|
+
'fetchTickers': true,
|
|
54
|
+
'fetchTrades': true,
|
|
55
|
+
'fetchTradingFee': true,
|
|
56
|
+
'reduceMargin': true,
|
|
57
|
+
'setLeverage': true,
|
|
58
|
+
},
|
|
59
|
+
'timeframes': {
|
|
60
|
+
'1m': 1,
|
|
61
|
+
'5m': 5,
|
|
62
|
+
'15m': 15,
|
|
63
|
+
'30m': 30,
|
|
64
|
+
'1h': 60,
|
|
65
|
+
'2h': 120,
|
|
66
|
+
'4h': 480,
|
|
67
|
+
'12h': 720,
|
|
68
|
+
'1d': 1440,
|
|
69
|
+
'1w': 10080,
|
|
70
|
+
},
|
|
71
|
+
'urls': {
|
|
72
|
+
'logo': 'https://github.com/user-attachments/assets/8094e7be-55a7-46f4-a087-0ca31b48ecad',
|
|
73
|
+
'api': {
|
|
74
|
+
'spot': 'https://sapi.zebpay.com',
|
|
75
|
+
'swap': 'https://futuresbe.zebpay.com',
|
|
76
|
+
},
|
|
77
|
+
'test': {
|
|
78
|
+
'spot': 'https://www.zebstage.com',
|
|
79
|
+
'swap': 'https://dev-futuresbe.zebstage.com',
|
|
80
|
+
},
|
|
81
|
+
'www': 'https://www.zebpay.com',
|
|
82
|
+
'doc': 'https://github.com/zebpay/zebpay-api-references',
|
|
83
|
+
'fees': 'https://zebpay.com/in/features/pricing',
|
|
84
|
+
},
|
|
85
|
+
'api': {
|
|
86
|
+
'public': {
|
|
87
|
+
'spot': {
|
|
88
|
+
'get': {
|
|
89
|
+
'v2/system/time': 10,
|
|
90
|
+
'v2/system/status': 10,
|
|
91
|
+
'v2/market/orderbook': 10,
|
|
92
|
+
'v2/market/trades': 10,
|
|
93
|
+
'v2/market/ticker': 10,
|
|
94
|
+
'v2/market/allTickers': 10,
|
|
95
|
+
'v2/ex/exchangeInfo': 10,
|
|
96
|
+
'v2/ex/currencies': 10,
|
|
97
|
+
'v2/market/klines': 10,
|
|
98
|
+
'v2/ex/tradefees': 10,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
'swap': {
|
|
102
|
+
'get': {
|
|
103
|
+
'v1/system/time': 10,
|
|
104
|
+
'v1/system/status': 10,
|
|
105
|
+
'v1/exchange/tradefee': 10,
|
|
106
|
+
'v1/exchange/tradefees': 10,
|
|
107
|
+
'v1/market/orderBook': 10,
|
|
108
|
+
'v1/market/ticker24Hr': 10,
|
|
109
|
+
'v1/market/markets': 10,
|
|
110
|
+
'v1/market/aggTrade': 10,
|
|
111
|
+
},
|
|
112
|
+
'post': {
|
|
113
|
+
'v1/market/klines': 10,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
'private': {
|
|
118
|
+
'spot': {
|
|
119
|
+
'post': {
|
|
120
|
+
'v2/ex/orders': 10,
|
|
121
|
+
},
|
|
122
|
+
'get': {
|
|
123
|
+
'v2/ex/orders': 10,
|
|
124
|
+
'v2/account/balance': 10,
|
|
125
|
+
'v2/ex/tradefee': 10,
|
|
126
|
+
'v2/ex/order': 10,
|
|
127
|
+
'v2/ex/order/fills': 10,
|
|
128
|
+
},
|
|
129
|
+
'delete': {
|
|
130
|
+
'v2/ex/order': 10,
|
|
131
|
+
'v2/ex/orders': 10,
|
|
132
|
+
'v2/ex/orders/cancelAll': 10,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
'swap': {
|
|
136
|
+
'get': {
|
|
137
|
+
'v1/wallet/balance': 10,
|
|
138
|
+
'v1/trade/order': 10,
|
|
139
|
+
'v1/trade/order/open-orders': 10,
|
|
140
|
+
'v1/trade/userLeverages': 10,
|
|
141
|
+
'v1/trade/userLeverage': 10,
|
|
142
|
+
'v1/trade/positions': 10,
|
|
143
|
+
'v1/trade/history': 10,
|
|
144
|
+
},
|
|
145
|
+
'post': {
|
|
146
|
+
'v1/trade/order': 10,
|
|
147
|
+
'v1/trade/order/addTPSL': 10,
|
|
148
|
+
'v1/trade/addMargin': 10,
|
|
149
|
+
'v1/trade/reduceMargin': 10,
|
|
150
|
+
'v1/trade/position/close': 10,
|
|
151
|
+
'v1/trade/update/userLeverage': 10,
|
|
152
|
+
},
|
|
153
|
+
'delete': {
|
|
154
|
+
'v1/trade/order': 10,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
'precisionMode': number.TICK_SIZE,
|
|
160
|
+
'fees': {},
|
|
161
|
+
'commonCurrencies': {},
|
|
162
|
+
'requiredCredentials': {
|
|
163
|
+
'apiKey': true,
|
|
164
|
+
'secret': true,
|
|
165
|
+
},
|
|
166
|
+
'options': {
|
|
167
|
+
'fetchMarkets': {
|
|
168
|
+
'types': ['spot', 'swap'],
|
|
169
|
+
},
|
|
170
|
+
'defaultType': 'spot', // 'spot', 'swap'
|
|
171
|
+
},
|
|
172
|
+
'features': {
|
|
173
|
+
'default': {
|
|
174
|
+
'fetchOHLCV': {
|
|
175
|
+
'limit': 100,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
'exceptions': {
|
|
180
|
+
'exact': {
|
|
181
|
+
'77': errors.InvalidOrder,
|
|
182
|
+
'400': errors.BadRequest,
|
|
183
|
+
'401': errors.AuthenticationError,
|
|
184
|
+
'403': errors.NotSupported,
|
|
185
|
+
'404': errors.NotSupported,
|
|
186
|
+
'429': errors.RateLimitExceeded,
|
|
187
|
+
'500': errors.ExchangeNotAvailable,
|
|
188
|
+
'503': errors.ExchangeNotAvailable,
|
|
189
|
+
'3013': errors.OrderNotFound,
|
|
190
|
+
'Order quantity is out of range': errors.InvalidOrder,
|
|
191
|
+
'Invalid trade order type': errors.InvalidOrder,
|
|
192
|
+
'Insufficient margin': errors.InsufficientFunds,
|
|
193
|
+
'insufficient balance': errors.InsufficientFunds,
|
|
194
|
+
'leverage must be in [1,8]': errors.BadRequest,
|
|
195
|
+
'the request you sent is invalid': errors.BadRequest,
|
|
196
|
+
},
|
|
197
|
+
'broad': {
|
|
198
|
+
'InvalidOrder': errors.InvalidOrder, // Rate should be in the range of
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @method
|
|
205
|
+
* @name zebpay#fetchStatus
|
|
206
|
+
* @description the latest known information on the availability of the exchange API
|
|
207
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#system-status
|
|
208
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-status
|
|
209
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
210
|
+
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
211
|
+
*/
|
|
212
|
+
async fetchStatus(params = {}) {
|
|
213
|
+
let type = undefined;
|
|
214
|
+
[type, params] = this.handleMarketTypeAndParams('fetchStatus', undefined, params);
|
|
215
|
+
const isSpot = (type === 'spot');
|
|
216
|
+
let response = undefined;
|
|
217
|
+
let data = {};
|
|
218
|
+
if (isSpot) {
|
|
219
|
+
response = await this.publicSpotGetV2SystemStatus(params);
|
|
220
|
+
data = response;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
response = await this.publicSwapGetV1SystemStatus(params);
|
|
224
|
+
data = this.safeDict(response, 'data', {});
|
|
225
|
+
}
|
|
226
|
+
//
|
|
227
|
+
// {
|
|
228
|
+
// "statusDescription": "OK",
|
|
229
|
+
// "data":
|
|
230
|
+
// {
|
|
231
|
+
// "systemStatus": "ok"
|
|
232
|
+
// }
|
|
233
|
+
// "statusCode": 200,
|
|
234
|
+
// "customMessage": ["OK"]
|
|
235
|
+
// }
|
|
236
|
+
//
|
|
237
|
+
const status = this.safeString2(data, 'systemStatus', 'status');
|
|
238
|
+
return {
|
|
239
|
+
'status': status,
|
|
240
|
+
'updated': undefined,
|
|
241
|
+
'eta': undefined,
|
|
242
|
+
'url': undefined,
|
|
243
|
+
'info': response,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @method
|
|
248
|
+
* @name zebpayfutures#fetchTime
|
|
249
|
+
* @description fetches the current integer timestamp in milliseconds from the poloniexfutures server
|
|
250
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-server-time
|
|
251
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-time
|
|
252
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
253
|
+
* @returns {int} the current integer timestamp in milliseconds from the poloniexfutures server
|
|
254
|
+
*/
|
|
255
|
+
async fetchTime(params = {}) {
|
|
256
|
+
let type = undefined;
|
|
257
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
|
|
258
|
+
const isSpot = (type === 'spot');
|
|
259
|
+
let response = undefined;
|
|
260
|
+
let data = {};
|
|
261
|
+
if (isSpot) {
|
|
262
|
+
response = await this.publicSpotGetV2SystemTime(params);
|
|
263
|
+
data = response;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
response = await this.publicSwapGetV1SystemTime(params);
|
|
267
|
+
data = this.safeDict(response, 'data', {});
|
|
268
|
+
}
|
|
269
|
+
//
|
|
270
|
+
// {
|
|
271
|
+
// "statusDescription": "OK",
|
|
272
|
+
// "data":
|
|
273
|
+
// {
|
|
274
|
+
// "timestamp": 1546837113087
|
|
275
|
+
// }
|
|
276
|
+
// "statusCode": 200,
|
|
277
|
+
// "customMessage": ["OK"]
|
|
278
|
+
// }
|
|
279
|
+
//
|
|
280
|
+
const time = this.safeInteger(data, 'timestamp');
|
|
281
|
+
return time;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* @method
|
|
285
|
+
* @name zebpay#fetchMarkets
|
|
286
|
+
* @description retrieves data on all markets for zebpay
|
|
287
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-trading-pairs
|
|
288
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#fetch-markets
|
|
289
|
+
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
290
|
+
* @returns {object[]} an array of objects representing market data
|
|
291
|
+
*/
|
|
292
|
+
async fetchMarkets(params = {}) {
|
|
293
|
+
const promisesUnresolved = [];
|
|
294
|
+
const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets');
|
|
295
|
+
const defaultMarkets = ['spot', 'swap'];
|
|
296
|
+
const types = this.safeList(fetchMarketsOptions, 'types', defaultMarkets);
|
|
297
|
+
for (let i = 0; i < types.length; i++) {
|
|
298
|
+
const type = types[i];
|
|
299
|
+
if (type === 'spot') {
|
|
300
|
+
promisesUnresolved.push(this.fetchSpotMarkets(params));
|
|
301
|
+
}
|
|
302
|
+
else if (type === 'swap') {
|
|
303
|
+
promisesUnresolved.push(this.fetchSwapMarkets(params));
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
throw new errors.ExchangeError(this.id + ' fetchMarkets() this.options fetchMarkets "' + type + '" is not a supported market type');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const promises = await Promise.all(promisesUnresolved);
|
|
310
|
+
const spotMarkets = this.safeList(promises, 0, []);
|
|
311
|
+
const futureMarkets = this.safeList(promises, 1, []);
|
|
312
|
+
return this.arrayConcat(spotMarkets, futureMarkets);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @method
|
|
316
|
+
* @name zebpay#fetchCurrencies
|
|
317
|
+
* @description fetches all available currencies on an exchange
|
|
318
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-coin-settings
|
|
319
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
320
|
+
* @returns {object} an associative dictionary of currencies
|
|
321
|
+
*/
|
|
322
|
+
async fetchCurrencies(params = {}) {
|
|
323
|
+
const response = await this.publicSpotGetV2ExCurrencies(params);
|
|
324
|
+
//
|
|
325
|
+
// {
|
|
326
|
+
// "data": [
|
|
327
|
+
// {
|
|
328
|
+
// "currency": "BTC",
|
|
329
|
+
// "name": "BTC",
|
|
330
|
+
// "fullName": "150",
|
|
331
|
+
// "precision": "0.2",
|
|
332
|
+
// "type": "fiat",
|
|
333
|
+
// "isDebitEnabled": false,
|
|
334
|
+
// "chains": [
|
|
335
|
+
// {
|
|
336
|
+
// "chainName": "Bitcoin",
|
|
337
|
+
// "withdrawalMinSize": "0.000482",
|
|
338
|
+
// "depositMinSize": "0.00000001",
|
|
339
|
+
// "withdrawalFee": "0.00040000",
|
|
340
|
+
// "isWithdrawEnabled": "true",
|
|
341
|
+
// "isDepositEnabled": "true",
|
|
342
|
+
// "contractAddress": "0x095418A82BC2439703b69fbE1210824F2247D77c",
|
|
343
|
+
// "withdrawPrecision": "8",
|
|
344
|
+
// "maxWithdraw": "2.43090487000000",
|
|
345
|
+
// "maxDeposit": "100.00000000",
|
|
346
|
+
// "needTag": "false",
|
|
347
|
+
// "chainId": "bitcoin",
|
|
348
|
+
// "AddressRegex": "^tb1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39,59}|m[a-zA-Z0-9]{25,34}|n[a-zA-Z0-9]{25,34}|^2[a-zA-Z0-9]{25,34}$"
|
|
349
|
+
// }
|
|
350
|
+
// ]
|
|
351
|
+
// }
|
|
352
|
+
// ]
|
|
353
|
+
// }
|
|
354
|
+
//
|
|
355
|
+
const rows = this.safeList(response, 'data', []);
|
|
356
|
+
const result = {};
|
|
357
|
+
for (let i = 0; i < rows.length; i++) {
|
|
358
|
+
const currency = rows[i];
|
|
359
|
+
const currencyId = this.safeString(currency, 'currency');
|
|
360
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
361
|
+
const name = this.safeString(currency, 'name');
|
|
362
|
+
const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision')));
|
|
363
|
+
const chains = this.safeList(currency, 'chains', []);
|
|
364
|
+
const networks = {};
|
|
365
|
+
let minWithdrawFeeString = undefined;
|
|
366
|
+
let minWithdrawString = undefined;
|
|
367
|
+
let minDepositString = undefined;
|
|
368
|
+
let deposit = false;
|
|
369
|
+
let withdraw = false;
|
|
370
|
+
for (let j = 0; j < chains.length; j++) {
|
|
371
|
+
const chain = chains[j];
|
|
372
|
+
const networkId = this.safeString(chain, 'chainId');
|
|
373
|
+
const networkCode = this.networkIdToCode(networkId);
|
|
374
|
+
const depositAllowed = this.safeBool(chain, 'isDepositEnabled') === true;
|
|
375
|
+
deposit = (depositAllowed) ? depositAllowed : deposit;
|
|
376
|
+
const withdrawAllowed = this.safeBool(chain, 'isWithdrawEnabled') === true;
|
|
377
|
+
withdraw = (withdrawAllowed) ? withdrawAllowed : withdraw;
|
|
378
|
+
const withdrawFeeString = this.safeString(chain, 'withdrawalFee');
|
|
379
|
+
if (withdrawFeeString !== undefined) {
|
|
380
|
+
minWithdrawFeeString = (minWithdrawFeeString === undefined) ? withdrawFeeString : Precise["default"].stringMin(withdrawFeeString, minWithdrawFeeString);
|
|
381
|
+
}
|
|
382
|
+
const minNetworkWithdrawString = this.safeString(chain, 'withdrawalMinSize');
|
|
383
|
+
if (minNetworkWithdrawString !== undefined) {
|
|
384
|
+
minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : Precise["default"].stringMin(minNetworkWithdrawString, minWithdrawString);
|
|
385
|
+
}
|
|
386
|
+
const minNetworkDepositString = this.safeString(chain, 'depositMinSize');
|
|
387
|
+
if (minNetworkDepositString !== undefined) {
|
|
388
|
+
minDepositString = (minDepositString === undefined) ? minNetworkDepositString : Precise["default"].stringMin(minNetworkDepositString, minDepositString);
|
|
389
|
+
}
|
|
390
|
+
networks[networkCode] = {
|
|
391
|
+
'info': chain,
|
|
392
|
+
'id': networkId,
|
|
393
|
+
'network': networkCode,
|
|
394
|
+
'active': depositAllowed && withdrawAllowed,
|
|
395
|
+
'deposit': depositAllowed,
|
|
396
|
+
'withdraw': withdrawAllowed,
|
|
397
|
+
'fee': this.parseNumber(withdrawFeeString),
|
|
398
|
+
'precision': precision,
|
|
399
|
+
'limits': {
|
|
400
|
+
'withdraw': {
|
|
401
|
+
'min': this.parseNumber(minNetworkWithdrawString),
|
|
402
|
+
'max': undefined,
|
|
403
|
+
},
|
|
404
|
+
'deposit': {
|
|
405
|
+
'min': this.parseNumber(minNetworkDepositString),
|
|
406
|
+
'max': undefined,
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
result[code] = this.safeCurrencyStructure({
|
|
412
|
+
'info': currency,
|
|
413
|
+
'code': code,
|
|
414
|
+
'id': currencyId,
|
|
415
|
+
'name': name,
|
|
416
|
+
'active': deposit && withdraw,
|
|
417
|
+
'deposit': deposit,
|
|
418
|
+
'withdraw': withdraw,
|
|
419
|
+
'fee': this.parseNumber(minWithdrawFeeString),
|
|
420
|
+
'precision': precision,
|
|
421
|
+
'limits': {
|
|
422
|
+
'amount': {
|
|
423
|
+
'min': undefined,
|
|
424
|
+
'max': undefined,
|
|
425
|
+
},
|
|
426
|
+
'withdraw': {
|
|
427
|
+
'min': this.parseNumber(minWithdrawString),
|
|
428
|
+
'max': undefined,
|
|
429
|
+
},
|
|
430
|
+
'deposit': {
|
|
431
|
+
'min': this.parseNumber(minDepositString),
|
|
432
|
+
'max': undefined,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
'networks': networks,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @method
|
|
442
|
+
* @name zebpay#fetchTradingFee
|
|
443
|
+
* @description fetch the trading fees for a market
|
|
444
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-exchange-fee
|
|
445
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fee-single-symbol
|
|
446
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
447
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
448
|
+
* @param {object} [params.side] side to fetch trading fee
|
|
449
|
+
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
450
|
+
*/
|
|
451
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
452
|
+
await this.loadMarkets();
|
|
453
|
+
const market = this.market(symbol);
|
|
454
|
+
let response = undefined;
|
|
455
|
+
let data;
|
|
456
|
+
const request = {
|
|
457
|
+
'symbol': market['id'],
|
|
458
|
+
};
|
|
459
|
+
if (market['spot']) {
|
|
460
|
+
response = await this.privateSpotGetV2ExTradefee(this.extend(request, params));
|
|
461
|
+
//
|
|
462
|
+
// {
|
|
463
|
+
// "statusDescription": "Success",
|
|
464
|
+
// "data":
|
|
465
|
+
// {
|
|
466
|
+
// "symbol": "BTCINR",
|
|
467
|
+
// "takerFeeRate": "0.01",
|
|
468
|
+
// "makerFeeRate": "0.05",
|
|
469
|
+
// "percentage": true
|
|
470
|
+
// } ,
|
|
471
|
+
// "statusCode": 200,
|
|
472
|
+
// }
|
|
473
|
+
data = this.safeDict(response, 'data', {});
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
response = await this.publicSwapGetV1ExchangeTradefee(this.extend(request, params));
|
|
477
|
+
//
|
|
478
|
+
// {
|
|
479
|
+
// "statusDescription": "OK",
|
|
480
|
+
// "data":
|
|
481
|
+
// [
|
|
482
|
+
// {
|
|
483
|
+
// "symbol": "BTCINR",
|
|
484
|
+
// "takerFee": "0.01",
|
|
485
|
+
// "makerFee": "0.05"
|
|
486
|
+
// }
|
|
487
|
+
// ] ,
|
|
488
|
+
// "statusCode": 200,
|
|
489
|
+
// "customMessage": ["OK"]
|
|
490
|
+
// }
|
|
491
|
+
//
|
|
492
|
+
const responseData = this.safeList(response, 'data', []);
|
|
493
|
+
data = this.safeDict(responseData, 0);
|
|
494
|
+
}
|
|
495
|
+
return this.parseTradingFee(data, market);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* @method
|
|
499
|
+
* @name zebpay(futures)#fetchTradingFees
|
|
500
|
+
* @description fetch the trading fees for multiple markets
|
|
501
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fees-all-symbols
|
|
502
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
503
|
+
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
504
|
+
*/
|
|
505
|
+
async fetchTradingFees(params = {}) {
|
|
506
|
+
let type = undefined;
|
|
507
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
508
|
+
let response = undefined;
|
|
509
|
+
if (type === 'spot') {
|
|
510
|
+
response = await this.publicSpotGetV2ExTradefees(params);
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
response = await this.publicSwapGetV1ExchangeTradefees(params);
|
|
514
|
+
}
|
|
515
|
+
//
|
|
516
|
+
// {
|
|
517
|
+
// "statusDescription": "OK",
|
|
518
|
+
// "data": [
|
|
519
|
+
// {
|
|
520
|
+
// "symbol": "BTCINR",
|
|
521
|
+
// "takerFee": "0.01",
|
|
522
|
+
// "makerFee": "0.05"
|
|
523
|
+
// }
|
|
524
|
+
// ],
|
|
525
|
+
// "statusCode": 200,
|
|
526
|
+
// "customMessage": ["OK"]
|
|
527
|
+
// }
|
|
528
|
+
//
|
|
529
|
+
const fees = this.safeList(response, 'data', []);
|
|
530
|
+
const result = {};
|
|
531
|
+
for (let i = 0; i < fees.length; i++) {
|
|
532
|
+
const fee = this.parseTradingFee(fees[i]);
|
|
533
|
+
const symbol = fee['symbol'];
|
|
534
|
+
result[symbol] = fee;
|
|
535
|
+
}
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* @method
|
|
540
|
+
* @name zebpay#fetchOrderBook
|
|
541
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
542
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-order-book
|
|
543
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-order-book
|
|
544
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
545
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
546
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
547
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
548
|
+
*/
|
|
549
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
550
|
+
await this.loadMarkets();
|
|
551
|
+
const market = this.market(symbol);
|
|
552
|
+
const request = {
|
|
553
|
+
'symbol': market['id'],
|
|
554
|
+
};
|
|
555
|
+
let response = undefined;
|
|
556
|
+
if (market['spot']) {
|
|
557
|
+
if (limit !== undefined) {
|
|
558
|
+
request['limit'] = limit;
|
|
559
|
+
}
|
|
560
|
+
//
|
|
561
|
+
// {
|
|
562
|
+
// "asks": [
|
|
563
|
+
// [5000, 1000], //Price, quantity
|
|
564
|
+
// [6000, 1983] //Price, quantity
|
|
565
|
+
// ],
|
|
566
|
+
// "bids": [
|
|
567
|
+
// [3200, 800], //Price, quantity
|
|
568
|
+
// [3100, 100] //Price, quantity
|
|
569
|
+
// ],
|
|
570
|
+
// }
|
|
571
|
+
// }
|
|
572
|
+
response = await this.publicSpotGetV2MarketOrderbook(this.extend(request, params));
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
response = await this.publicSwapGetV1MarketOrderBook(this.extend(request, params));
|
|
576
|
+
}
|
|
577
|
+
const bookData = this.safeDict(response, 'data', {});
|
|
578
|
+
const orderbook = this.parseOrderBook(bookData, market['symbol'], undefined, 'bids', 'asks', 0, 1);
|
|
579
|
+
orderbook['nonce'] = this.safeInteger(bookData, 'nonce');
|
|
580
|
+
return orderbook;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* @method
|
|
584
|
+
* @name zebpay#fetchTicker
|
|
585
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
586
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-ticker
|
|
587
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-24hr-ticker
|
|
588
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
589
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
590
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
591
|
+
*/
|
|
592
|
+
async fetchTicker(symbol, params = {}) {
|
|
593
|
+
await this.loadMarkets();
|
|
594
|
+
const market = this.market(symbol);
|
|
595
|
+
const request = {
|
|
596
|
+
'symbol': market['id'],
|
|
597
|
+
};
|
|
598
|
+
let response = undefined;
|
|
599
|
+
if (market['spot']) {
|
|
600
|
+
response = await this.publicSpotGetV2MarketTicker(this.extend(request, params));
|
|
601
|
+
//
|
|
602
|
+
// [
|
|
603
|
+
// {
|
|
604
|
+
// "symbol": "BTC-INR",
|
|
605
|
+
// "bestBid": "4900000",
|
|
606
|
+
// "bestBidQty": "0.00014938",
|
|
607
|
+
// "bestAsk": "",
|
|
608
|
+
// "bestAskQty": "0",
|
|
609
|
+
// "priceChange": "-98134.56",
|
|
610
|
+
// "priceChangePercent": "-1.84",
|
|
611
|
+
// "high": "5433400",
|
|
612
|
+
// "low": "5333400",
|
|
613
|
+
// "vol": "0.0002",
|
|
614
|
+
// "volValue": "1066.68",
|
|
615
|
+
// "last": "5333400"
|
|
616
|
+
// }
|
|
617
|
+
// ]
|
|
618
|
+
//
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
response = await this.publicSwapGetV1MarketTicker24Hr(this.extend(request, params));
|
|
622
|
+
}
|
|
623
|
+
const data = this.safeDict(response, 'data', {});
|
|
624
|
+
return this.parseTicker(data, market);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* @method
|
|
628
|
+
* @name zebpay#fetchTickers
|
|
629
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
630
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-all-tickers
|
|
631
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
632
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
633
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
634
|
+
*/
|
|
635
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
636
|
+
let type = undefined;
|
|
637
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTickers', undefined, params);
|
|
638
|
+
if (type !== 'spot') {
|
|
639
|
+
throw new errors.NotSupported(this.id + ' fetchTickers() does not support ' + type + ' markets');
|
|
640
|
+
}
|
|
641
|
+
await this.loadMarkets();
|
|
642
|
+
symbols = this.marketSymbols(symbols);
|
|
643
|
+
const response = await this.publicSpotGetV2MarketAllTickers(params);
|
|
644
|
+
//
|
|
645
|
+
// [
|
|
646
|
+
// {
|
|
647
|
+
// "symbol": "BTC-INR",
|
|
648
|
+
// "bestBid": "4900000",
|
|
649
|
+
// "bestBidQty": "0.00014938",
|
|
650
|
+
// "bestAsk": "",
|
|
651
|
+
// "bestAskQty": "0",
|
|
652
|
+
// "priceChange": "-98134.56",
|
|
653
|
+
// "priceChangePercent": "-1.84",
|
|
654
|
+
// "high": "5433400",
|
|
655
|
+
// "low": "5333400",
|
|
656
|
+
// "vol": "0.0002",
|
|
657
|
+
// "volValue": "1066.68",
|
|
658
|
+
// "last": "5333400"
|
|
659
|
+
// }
|
|
660
|
+
// ]
|
|
661
|
+
//
|
|
662
|
+
const tickerList = this.safeList(response, 'data', []);
|
|
663
|
+
return this.parseTickers(tickerList, symbols);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* @method
|
|
667
|
+
* @name zebpay#fetchOHLCV
|
|
668
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
669
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-klinescandlesticks
|
|
670
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#-get-k-lines-ohlcv-data
|
|
671
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
672
|
+
* @param {string} timeframe the length of time each candle represents
|
|
673
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
674
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
675
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
676
|
+
* @param {int} [params.endtime] the latest time in ms to fetch orders for
|
|
677
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
678
|
+
*/
|
|
679
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
680
|
+
await this.loadMarkets();
|
|
681
|
+
const market = this.market(symbol);
|
|
682
|
+
if (limit === undefined) {
|
|
683
|
+
limit = 100; // default is 200
|
|
684
|
+
}
|
|
685
|
+
const request = {
|
|
686
|
+
'symbol': market['id'],
|
|
687
|
+
};
|
|
688
|
+
if (market['spot']) {
|
|
689
|
+
request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
request['interval'] = timeframe;
|
|
693
|
+
}
|
|
694
|
+
if (market['contract'] && (limit !== undefined)) {
|
|
695
|
+
request['limit'] = limit;
|
|
696
|
+
}
|
|
697
|
+
if (since !== undefined) {
|
|
698
|
+
if (market['spot']) {
|
|
699
|
+
request['startTime'] = since;
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
request['since'] = since;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const until = this.safeInteger2(params, 'until', 'endtime');
|
|
706
|
+
if (until !== undefined) {
|
|
707
|
+
request['endTime'] = until;
|
|
708
|
+
params = this.omit(params, ['endtime', 'until']);
|
|
709
|
+
}
|
|
710
|
+
let response = undefined;
|
|
711
|
+
if (market['spot']) {
|
|
712
|
+
if (until === undefined || since === undefined) {
|
|
713
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOHLCV() requires a both a since and until/endtime parameter for spot markets');
|
|
714
|
+
}
|
|
715
|
+
response = await this.publicSpotGetV2MarketKlines(this.extend(request, params));
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
response = await this.publicSwapPostV1MarketKlines(this.extend(request, params));
|
|
719
|
+
}
|
|
720
|
+
//
|
|
721
|
+
// [
|
|
722
|
+
// [
|
|
723
|
+
// "1670608800000",
|
|
724
|
+
// "17071",
|
|
725
|
+
// "17073",
|
|
726
|
+
// "17027",
|
|
727
|
+
// "17055.5",
|
|
728
|
+
// "268611",
|
|
729
|
+
// "15.74462667"
|
|
730
|
+
// ],
|
|
731
|
+
// [
|
|
732
|
+
// "1670605200000",
|
|
733
|
+
// "17071.5",
|
|
734
|
+
// "17071.5",
|
|
735
|
+
// "17061",
|
|
736
|
+
// "17071",
|
|
737
|
+
// "4177",
|
|
738
|
+
// "0.24469757"
|
|
739
|
+
// ],
|
|
740
|
+
// [
|
|
741
|
+
// "1670601600000",
|
|
742
|
+
// "17086.5",
|
|
743
|
+
// "17088",
|
|
744
|
+
// "16978",
|
|
745
|
+
// "17071.5",
|
|
746
|
+
// "6356",
|
|
747
|
+
// "0.37288112"
|
|
748
|
+
// ]
|
|
749
|
+
// ]
|
|
750
|
+
//
|
|
751
|
+
const data = this.safeList(response, 'data', []);
|
|
752
|
+
return this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* @method
|
|
756
|
+
* @name zebpay#fetchTrades
|
|
757
|
+
* @description get the list of most recent trades for a particular symbol
|
|
758
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-recent-trades
|
|
759
|
+
* @see https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-aggregate-trades
|
|
760
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
761
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
762
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
763
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
764
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
765
|
+
*/
|
|
766
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
767
|
+
await this.loadMarkets();
|
|
768
|
+
const market = this.market(symbol);
|
|
769
|
+
const request = {
|
|
770
|
+
'symbol': market['id'],
|
|
771
|
+
};
|
|
772
|
+
if (market['spot'] && limit !== undefined) {
|
|
773
|
+
request['limit'] = limit;
|
|
774
|
+
}
|
|
775
|
+
let response = undefined;
|
|
776
|
+
if (market['spot']) {
|
|
777
|
+
response = await this.publicSpotGetV2MarketTrades(this.extend(request, params));
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
response = await this.publicSwapGetV1MarketAggTrade(this.extend(request, params));
|
|
781
|
+
}
|
|
782
|
+
//
|
|
783
|
+
// [
|
|
784
|
+
// {
|
|
785
|
+
// "id" : "60014521",
|
|
786
|
+
// "price" : "23162.94",
|
|
787
|
+
// "qty" : "0.00009",
|
|
788
|
+
// "side" : "SELL",
|
|
789
|
+
// "time" : 1659684602042,
|
|
790
|
+
// "isBuyerMaker" : 1659684602036
|
|
791
|
+
// }
|
|
792
|
+
// ]
|
|
793
|
+
//
|
|
794
|
+
const data = this.safeList(response, 'data', []);
|
|
795
|
+
return this.parseTrades(data, market, since, limit);
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* @method
|
|
799
|
+
* @name zebpay#fetchMyTrades
|
|
800
|
+
* @description get the list of most recent trades for a particular symbol
|
|
801
|
+
* @see https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-trade-history
|
|
802
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
803
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
804
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
805
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
806
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
807
|
+
*/
|
|
808
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
809
|
+
await this.loadMarkets();
|
|
810
|
+
let market = undefined;
|
|
811
|
+
if (symbol !== undefined) {
|
|
812
|
+
market = this.market(symbol);
|
|
813
|
+
}
|
|
814
|
+
let type = undefined;
|
|
815
|
+
[type, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
|
|
816
|
+
let response = undefined;
|
|
817
|
+
if (type === 'spot') {
|
|
818
|
+
throw new errors.NotSupported(this.id + ' fetchMyTrades() does not support spot markets');
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
response = await this.privateSwapGetV1TradeHistory(params);
|
|
822
|
+
}
|
|
823
|
+
const data = this.safeDict(response, 'data', {});
|
|
824
|
+
const items = this.safeList(data, 'items', []);
|
|
825
|
+
return this.parseTrades(items, market, since, limit);
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* @method
|
|
829
|
+
* @name zebpatspot#fetchOrderTrades
|
|
830
|
+
* @description fetch all the trades made from a single order
|
|
831
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-fills
|
|
832
|
+
* @param {string} id order id
|
|
833
|
+
* @param {string} symbol unified market symbol
|
|
834
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
835
|
+
* @param {int} [limit] the maximum number of trades to retrieve
|
|
836
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
837
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
838
|
+
*/
|
|
839
|
+
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
840
|
+
let type = undefined;
|
|
841
|
+
[type, params] = this.handleMarketTypeAndParams('fetchOrderTrades', undefined, params);
|
|
842
|
+
if (type !== 'spot') {
|
|
843
|
+
throw new errors.NotSupported(this.id + ' fetchOrderTrades() does not support ' + type + ' markets');
|
|
844
|
+
}
|
|
845
|
+
await this.loadMarkets();
|
|
846
|
+
const request = {
|
|
847
|
+
'orderId': id,
|
|
848
|
+
};
|
|
849
|
+
const response = await this.privateSpotGetV2ExOrderFills(this.extend(request, params));
|
|
850
|
+
//
|
|
851
|
+
// {
|
|
852
|
+
// "orderId": "456789",
|
|
853
|
+
// "symbol": "LINK_USDT",
|
|
854
|
+
// "origQty": "1.5",
|
|
855
|
+
// "orderId": "30249408733945856",
|
|
856
|
+
// "side": "BUY",
|
|
857
|
+
// "type": "LIMIT",
|
|
858
|
+
// "matchRole": "MAKER",
|
|
859
|
+
// "createTime": 1648200366864,
|
|
860
|
+
// "price": "3.1",
|
|
861
|
+
// "avgExecutedPrice": "2.3456"
|
|
862
|
+
// "openQty": "1",
|
|
863
|
+
// "filledQty": "0",
|
|
864
|
+
// "fees": "0.00145",
|
|
865
|
+
// }
|
|
866
|
+
//
|
|
867
|
+
const data = this.safeDict(response, 'data', {});
|
|
868
|
+
const trades = [data];
|
|
869
|
+
return this.parseTrades(trades);
|
|
870
|
+
}
|
|
871
|
+
parseTrade(trade, market = undefined) {
|
|
872
|
+
//
|
|
873
|
+
// fetchMyTrades
|
|
874
|
+
//
|
|
875
|
+
// {
|
|
876
|
+
// "id": "32164924331503616",
|
|
877
|
+
// "symbol": "LINK_USDT",
|
|
878
|
+
// "accountType": "SPOT",
|
|
879
|
+
// "orderId": "32164923987566592",
|
|
880
|
+
// "side": "SELL",
|
|
881
|
+
// "type": "MARKET",
|
|
882
|
+
// "matchRole": "TAKER",
|
|
883
|
+
// "createTime": 1648635115525,
|
|
884
|
+
// "price": "11",
|
|
885
|
+
// "quantity": "0.5",
|
|
886
|
+
// "amount": "5.5",
|
|
887
|
+
// "feeCurrency": "USDT",
|
|
888
|
+
// "feeAmount": "0.007975",
|
|
889
|
+
// "pageId": "32164924331503616",
|
|
890
|
+
// "clientOrderId": "myOwnId-321"
|
|
891
|
+
// }
|
|
892
|
+
// {
|
|
893
|
+
// aggregateTradeId: '2659115835',
|
|
894
|
+
// symbol: 'ETHINR',
|
|
895
|
+
// price: '292848',
|
|
896
|
+
// quantity: '0.147',
|
|
897
|
+
// firstTradeId: '7018766077',
|
|
898
|
+
// lastTradeId: '7018766081',
|
|
899
|
+
// tradeTime: '1765381971447',
|
|
900
|
+
// isBuyerMarketMaker: true
|
|
901
|
+
// }
|
|
902
|
+
//
|
|
903
|
+
//
|
|
904
|
+
const id = this.safeString2(trade, 'id', 'aggregateTradeId');
|
|
905
|
+
const orderId = this.safeString2(trade, 'id', 'order');
|
|
906
|
+
const timestamp = this.safeInteger2(trade, 'timestamp', 'tradeTime');
|
|
907
|
+
const marketId = this.safeString(trade, 'symbol');
|
|
908
|
+
market = this.safeMarket(marketId, market, '_');
|
|
909
|
+
const symbol = market['symbol'];
|
|
910
|
+
const side = this.safeStringLower(trade, 'side');
|
|
911
|
+
const priceString = this.safeString(trade, 'price');
|
|
912
|
+
const amountString = this.safeString2(trade, 'amount', 'quantity');
|
|
913
|
+
return this.safeTrade({
|
|
914
|
+
'id': id,
|
|
915
|
+
'info': trade,
|
|
916
|
+
'timestamp': timestamp,
|
|
917
|
+
'datetime': this.iso8601(timestamp),
|
|
918
|
+
'symbol': symbol,
|
|
919
|
+
'order': orderId,
|
|
920
|
+
'type': this.safeStringLower(trade, 'type'),
|
|
921
|
+
'side': side,
|
|
922
|
+
'takerOrMaker': undefined,
|
|
923
|
+
'price': priceString,
|
|
924
|
+
'amount': amountString,
|
|
925
|
+
'cost': this.safeString(trade, 'cost'),
|
|
926
|
+
'fee': this.safeDict(trade, 'fee'),
|
|
927
|
+
}, market);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* @method
|
|
931
|
+
* @name zebpay#fetchBalance
|
|
932
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
933
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-account-balance
|
|
934
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/wallet.md#get-wallet-balance
|
|
935
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
936
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
937
|
+
*/
|
|
938
|
+
async fetchBalance(params = {}) {
|
|
939
|
+
await this.loadMarkets();
|
|
940
|
+
let type = undefined;
|
|
941
|
+
[type, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
942
|
+
const isSpot = (type === 'spot');
|
|
943
|
+
let response = undefined;
|
|
944
|
+
if (isSpot) {
|
|
945
|
+
response = await this.privateSpotGetV2AccountBalance(params);
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
response = await this.privateSwapGetV1WalletBalance(params);
|
|
949
|
+
}
|
|
950
|
+
//
|
|
951
|
+
// {
|
|
952
|
+
// "data": [
|
|
953
|
+
// {
|
|
954
|
+
// "free": 200,
|
|
955
|
+
// "used": 100,
|
|
956
|
+
// "total": 300,
|
|
957
|
+
// "currency": "INR"
|
|
958
|
+
// },
|
|
959
|
+
// {
|
|
960
|
+
// "free": 0,
|
|
961
|
+
// "used": 0,
|
|
962
|
+
// "total": 0,
|
|
963
|
+
// "currency": "USDT"
|
|
964
|
+
// }
|
|
965
|
+
// ]
|
|
966
|
+
// }
|
|
967
|
+
//
|
|
968
|
+
return this.parseBalance(response);
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* @method
|
|
972
|
+
* @name zebpay#createOrder
|
|
973
|
+
* @description Create an order on the exchange
|
|
974
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#place-new-order
|
|
975
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--create-order
|
|
976
|
+
* @param {string} symbol Unified CCXT market symbol
|
|
977
|
+
* @param {string} type 'limit' or 'market'
|
|
978
|
+
* @param {string} side 'buy' or 'sell'
|
|
979
|
+
* @param {float} amount the amount of currency to trade
|
|
980
|
+
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
981
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
982
|
+
* @param {string} [params.formType] The price at which a trigger order is triggered at
|
|
983
|
+
* @param {string} [params.marginAsset] The asset the order creates, default is INR.
|
|
984
|
+
* @param {boolean} [params.takeProfit] Takeprofit flag for the order.
|
|
985
|
+
* @param {boolean} [params.stopLoss] Stop loss flag for the order.
|
|
986
|
+
* @param {string} [params.positionId] PositionId of the order.
|
|
987
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
988
|
+
*/
|
|
989
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
990
|
+
await this.loadMarkets();
|
|
991
|
+
const market = this.market(symbol);
|
|
992
|
+
const upperCaseType = type.toUpperCase();
|
|
993
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
994
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
995
|
+
params = this.omit(params, ['marginAsset', 'takeProfitPrice', 'takeProfitPrice']);
|
|
996
|
+
let request = {
|
|
997
|
+
'symbol': market['id'],
|
|
998
|
+
'side': side.toUpperCase(),
|
|
999
|
+
};
|
|
1000
|
+
let response = undefined;
|
|
1001
|
+
if (market['spot']) {
|
|
1002
|
+
[request, params] = this.orderRequest(symbol, type, amount, request, price, params);
|
|
1003
|
+
response = await this.privateSpotPostV2ExOrders(this.extend(request, params));
|
|
1004
|
+
}
|
|
1005
|
+
else {
|
|
1006
|
+
const marginAsset = this.safeString(params, 'marginAsset', 'INR');
|
|
1007
|
+
const formType = this.safeStringUpper(params, 'formType', 'ORDER_FORM');
|
|
1008
|
+
request['formType'] = formType;
|
|
1009
|
+
request['amount'] = this.parseToNumeric(this.amountToPrecision(market['id'], amount));
|
|
1010
|
+
request['marginAsset'] = marginAsset;
|
|
1011
|
+
const hasTP = takeProfitPrice !== undefined;
|
|
1012
|
+
const hasSL = stopLossPrice !== undefined;
|
|
1013
|
+
if (hasTP || hasSL) {
|
|
1014
|
+
if (hasTP) {
|
|
1015
|
+
request['takeProfitPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, takeProfitPrice));
|
|
1016
|
+
}
|
|
1017
|
+
if (hasSL) {
|
|
1018
|
+
request['stopLossPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, stopLossPrice));
|
|
1019
|
+
}
|
|
1020
|
+
response = await this.privateSwapPostV1TradeOrderAddTPSL(this.extend(request, params));
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
request['type'] = upperCaseType;
|
|
1024
|
+
if (type === 'limit') {
|
|
1025
|
+
if (price === undefined) {
|
|
1026
|
+
throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a price argument for limit orders');
|
|
1027
|
+
}
|
|
1028
|
+
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
1029
|
+
}
|
|
1030
|
+
response = await this.privateSwapPostV1TradeOrder(this.extend(request, params));
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
//
|
|
1034
|
+
// {
|
|
1035
|
+
// "data": {
|
|
1036
|
+
// "clientOrderId": "619717484f1d010001510cde",
|
|
1037
|
+
// },
|
|
1038
|
+
// }
|
|
1039
|
+
//
|
|
1040
|
+
const data = this.safeDict(response, 'data', {});
|
|
1041
|
+
return this.parseOrder(data, market);
|
|
1042
|
+
}
|
|
1043
|
+
orderRequest(symbol, type, amount, request, price = undefined, params = {}) {
|
|
1044
|
+
const upperCaseType = type.toUpperCase();
|
|
1045
|
+
const triggerPrice = this.safeString(params, 'stopLossPrice', undefined);
|
|
1046
|
+
const quoteOrderQty = this.safeString2(params, 'quoteOrderQty', 'cost', undefined);
|
|
1047
|
+
const timeInForce = this.safeString(params, 'timeInForce', 'GTC');
|
|
1048
|
+
const clientOrderId = this.safeString(params, 'clientOrderId', this.uuid());
|
|
1049
|
+
params = this.omit(params, ['stopLossPrice', 'cost', 'timeInForce', 'clientOrderId']);
|
|
1050
|
+
request['type'] = upperCaseType;
|
|
1051
|
+
request['clientOrderId'] = clientOrderId;
|
|
1052
|
+
request['timeInForce'] = timeInForce;
|
|
1053
|
+
if (upperCaseType === 'MARKET') {
|
|
1054
|
+
if (quoteOrderQty === undefined) {
|
|
1055
|
+
throw new errors.ExchangeError(this.id + ' spot market orders require cost in params');
|
|
1056
|
+
}
|
|
1057
|
+
request['quoteOrderAmount'] = this.costToPrecision(symbol, quoteOrderQty);
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
if (triggerPrice !== undefined) {
|
|
1061
|
+
request['stopLossPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1062
|
+
}
|
|
1063
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
1064
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1065
|
+
}
|
|
1066
|
+
return [request, params];
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* @method
|
|
1070
|
+
* @name zebpay#cancelOrder
|
|
1071
|
+
* @description cancels an open order
|
|
1072
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-order
|
|
1073
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-cancel-order
|
|
1074
|
+
* @param {string} id order id
|
|
1075
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1076
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1077
|
+
* @param {object} [params.timestamp] extra parameters specific to the exchange API endpoint
|
|
1078
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1079
|
+
*/
|
|
1080
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1081
|
+
await this.loadMarkets();
|
|
1082
|
+
const market = this.market(symbol);
|
|
1083
|
+
let response = undefined;
|
|
1084
|
+
const request = {};
|
|
1085
|
+
if (market['spot']) {
|
|
1086
|
+
request['orderId'] = id;
|
|
1087
|
+
response = await this.privateSpotDeleteV2ExOrder(this.extend(request, params));
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1091
|
+
if (clientOrderId === undefined) {
|
|
1092
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a clientOrderId parameter for swap orders');
|
|
1093
|
+
}
|
|
1094
|
+
request['clientOrderId'] = clientOrderId;
|
|
1095
|
+
request['symbol'] = market['id'];
|
|
1096
|
+
response = await this.privateSwapDeleteV1TradeOrder(this.extend(request, params));
|
|
1097
|
+
}
|
|
1098
|
+
//
|
|
1099
|
+
// {
|
|
1100
|
+
// "data": {
|
|
1101
|
+
// "clientOrderId": "619714b8b6353000014c505a",
|
|
1102
|
+
// "status": "canceled"
|
|
1103
|
+
// },
|
|
1104
|
+
// }
|
|
1105
|
+
//
|
|
1106
|
+
return this.parseOrder(this.safeDict(response, 'data'));
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* @method
|
|
1110
|
+
* @name zebpay#cancelOrders
|
|
1111
|
+
* @description cancels all open orders
|
|
1112
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-all-orders
|
|
1113
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1114
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1115
|
+
* @param {object} [params.timestamp] extra parameters specific to the exchange API endpoint
|
|
1116
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1117
|
+
*/
|
|
1118
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1119
|
+
let type = undefined;
|
|
1120
|
+
[type, params] = this.handleMarketTypeAndParams('cancelAllOrders', undefined, params);
|
|
1121
|
+
if (type !== 'spot') {
|
|
1122
|
+
throw new errors.NotSupported(this.id + ' cancelAllOrders() does not support ' + type + ' markets');
|
|
1123
|
+
}
|
|
1124
|
+
await this.loadMarkets();
|
|
1125
|
+
const response = await this.privateSpotDeleteV2ExOrdersCancelAll(params);
|
|
1126
|
+
//
|
|
1127
|
+
// {
|
|
1128
|
+
// "data": {
|
|
1129
|
+
// "orderId": "12345",
|
|
1130
|
+
// "symbol": 'BTC-INR
|
|
1131
|
+
// },
|
|
1132
|
+
// }
|
|
1133
|
+
//
|
|
1134
|
+
const data = this.safeDict(response, 'data', {});
|
|
1135
|
+
const parsedOrder = this.parseOrder(data);
|
|
1136
|
+
return [parsedOrder];
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* @method
|
|
1140
|
+
* @name zebpay#fetchOpenOrders
|
|
1141
|
+
* @description fetches information on multiple open orders made by the user
|
|
1142
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-orders
|
|
1143
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-open-orders
|
|
1144
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1145
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1146
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1147
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1148
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1149
|
+
*/
|
|
1150
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1151
|
+
await this.loadMarkets();
|
|
1152
|
+
const market = this.market(symbol);
|
|
1153
|
+
const request = {
|
|
1154
|
+
'symbol': market['id'],
|
|
1155
|
+
};
|
|
1156
|
+
let response = undefined;
|
|
1157
|
+
let orders = [];
|
|
1158
|
+
if (market['spot']) {
|
|
1159
|
+
request['currentPage'] = 1;
|
|
1160
|
+
if (limit !== undefined) {
|
|
1161
|
+
request['pageSize'] = limit;
|
|
1162
|
+
}
|
|
1163
|
+
response = await this.privateSpotGetV2ExOrders(this.extend(request, params));
|
|
1164
|
+
const responseData = this.safeDict(response, 'data', {});
|
|
1165
|
+
orders = this.safeList(responseData, 'items', []);
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
if (since !== undefined) {
|
|
1169
|
+
request['since'] = since;
|
|
1170
|
+
}
|
|
1171
|
+
if (limit !== undefined) {
|
|
1172
|
+
request['limit'] = limit;
|
|
1173
|
+
}
|
|
1174
|
+
response = await this.privateSwapGetV1TradeOrderOpenOrders(this.extend(request, params));
|
|
1175
|
+
const responseData = this.safeDict(response, 'data', {});
|
|
1176
|
+
orders = this.safeList(responseData, 'data', []);
|
|
1177
|
+
}
|
|
1178
|
+
//
|
|
1179
|
+
// {
|
|
1180
|
+
// "data": {
|
|
1181
|
+
// "nextTimeStamp": null,
|
|
1182
|
+
// "totalCount": 100,
|
|
1183
|
+
// "data": [
|
|
1184
|
+
// {
|
|
1185
|
+
// "clientOrderId": "64507d02921f1c0001ff6892-123-zeb",
|
|
1186
|
+
// "datetime": "2025-03-14T14:34:34.4567",
|
|
1187
|
+
// "timestamp": 1741962557553,
|
|
1188
|
+
// "status": "open",
|
|
1189
|
+
// "symbol": "BTCINR",
|
|
1190
|
+
// "type": "market",
|
|
1191
|
+
// "timeInForce": "GTC",
|
|
1192
|
+
// "side": "buy",
|
|
1193
|
+
// "price": 700000,
|
|
1194
|
+
// "amount": 0.002,
|
|
1195
|
+
// "filled": null,
|
|
1196
|
+
// "remaining": 0.002,
|
|
1197
|
+
// "trades": []
|
|
1198
|
+
// }
|
|
1199
|
+
// ]
|
|
1200
|
+
// }
|
|
1201
|
+
// }
|
|
1202
|
+
//
|
|
1203
|
+
return this.parseOrders(orders, market, undefined, limit);
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* @method
|
|
1207
|
+
* @name zebpay#fetchOrder
|
|
1208
|
+
* @description fetches information on an order made by the user
|
|
1209
|
+
* @see [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-details
|
|
1210
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-order-details
|
|
1211
|
+
* @param {string} id order id
|
|
1212
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1213
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1214
|
+
* @param {string} [params.clientOrderId] cancel order by client order id
|
|
1215
|
+
* @param {string} [params.timestamp] cancel order by client order id
|
|
1216
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1217
|
+
*/
|
|
1218
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1219
|
+
await this.loadMarkets();
|
|
1220
|
+
const market = this.market(symbol);
|
|
1221
|
+
const request = {};
|
|
1222
|
+
let response = undefined;
|
|
1223
|
+
if (market['spot']) {
|
|
1224
|
+
request['orderId'] = id;
|
|
1225
|
+
response = await this.privateSpotGetV2ExOrder(this.extend(request, params));
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
request['id'] = id;
|
|
1229
|
+
response = await this.privateSwapGetV1TradeOrder(this.extend(request, params));
|
|
1230
|
+
}
|
|
1231
|
+
//
|
|
1232
|
+
// {
|
|
1233
|
+
// "data": {
|
|
1234
|
+
// "nextTimeStamp": null,
|
|
1235
|
+
// "totalCount": 100,
|
|
1236
|
+
// "data": [
|
|
1237
|
+
// {
|
|
1238
|
+
// "clientOrderId": "64507d02921f1c0001ff6892-123-zeb",
|
|
1239
|
+
// "datetime": "2025-03-14T14:34:34.4567",
|
|
1240
|
+
// "timestamp": 1741962557553,
|
|
1241
|
+
// "status": "open",
|
|
1242
|
+
// "symbol": "BTCINR",
|
|
1243
|
+
// "type": "market",
|
|
1244
|
+
// "timeInForce": "GTC",
|
|
1245
|
+
// "side": "buy",
|
|
1246
|
+
// "price": 700000,
|
|
1247
|
+
// "amount": 0.002,
|
|
1248
|
+
// "filled": null,
|
|
1249
|
+
// "remaining": 0.002,
|
|
1250
|
+
// "trades": []
|
|
1251
|
+
// }
|
|
1252
|
+
// ]
|
|
1253
|
+
// }
|
|
1254
|
+
// }
|
|
1255
|
+
//
|
|
1256
|
+
const responseData = this.safeDict(response, 'data');
|
|
1257
|
+
return this.parseOrder(responseData, market);
|
|
1258
|
+
}
|
|
1259
|
+
parseOrder(order, market = undefined) {
|
|
1260
|
+
//
|
|
1261
|
+
// {
|
|
1262
|
+
// "clientOrderId": "64507d02921f1c0001ff6892-123-zeb",
|
|
1263
|
+
// "datetime": "2025-03-14T14:34:34.4567",
|
|
1264
|
+
// "timestamp": 1741962557553,
|
|
1265
|
+
// "status": "open",
|
|
1266
|
+
// "symbol": "BTCINR",
|
|
1267
|
+
// "type": "market",
|
|
1268
|
+
// "timeInForce": "GTC",
|
|
1269
|
+
// "side": "buy",
|
|
1270
|
+
// "price": 700000,
|
|
1271
|
+
// "amount": 0.002,
|
|
1272
|
+
// "filled": null,
|
|
1273
|
+
// "remaining": 0.002,
|
|
1274
|
+
// "trades": []
|
|
1275
|
+
// }
|
|
1276
|
+
//
|
|
1277
|
+
const marketId = this.safeString(order, 'symbol');
|
|
1278
|
+
market = this.safeMarket(marketId, market);
|
|
1279
|
+
const symbol = market['symbol'];
|
|
1280
|
+
const type = this.safeString(order, 'type');
|
|
1281
|
+
const timestamp = this.safeNumber(order, 'timestamp');
|
|
1282
|
+
const datetime = this.iso8601(timestamp);
|
|
1283
|
+
const price = this.safeString(order, 'price');
|
|
1284
|
+
const side = this.safeString(order, 'side');
|
|
1285
|
+
const amount = this.safeString(order, 'amount');
|
|
1286
|
+
const clientOrderId = this.safeString(order, 'clientOrderId');
|
|
1287
|
+
const timeInForce = this.safeString(order, 'timeInForce');
|
|
1288
|
+
const status = this.safeStringLower(order, 'status');
|
|
1289
|
+
const orderId = this.safeString(order, 'orderId', undefined);
|
|
1290
|
+
const parsedOrder = this.safeOrder({
|
|
1291
|
+
'id': orderId,
|
|
1292
|
+
'clientOrderId': clientOrderId,
|
|
1293
|
+
'symbol': symbol,
|
|
1294
|
+
'type': type,
|
|
1295
|
+
'timeInForce': timeInForce,
|
|
1296
|
+
'postOnly': undefined,
|
|
1297
|
+
'reduceOnly': undefined,
|
|
1298
|
+
'side': side,
|
|
1299
|
+
'amount': amount,
|
|
1300
|
+
'price': price,
|
|
1301
|
+
'triggerPrice': undefined,
|
|
1302
|
+
'cost': undefined,
|
|
1303
|
+
'filled': undefined,
|
|
1304
|
+
'remaining': undefined,
|
|
1305
|
+
'timestamp': timestamp,
|
|
1306
|
+
'datetime': datetime,
|
|
1307
|
+
'fee': undefined,
|
|
1308
|
+
'status': status,
|
|
1309
|
+
'info': order,
|
|
1310
|
+
'lastTradeTimestamp': undefined,
|
|
1311
|
+
'lastUpdateTimestamp': undefined,
|
|
1312
|
+
'average': undefined,
|
|
1313
|
+
'trades': undefined,
|
|
1314
|
+
}, market);
|
|
1315
|
+
return parsedOrder;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* @method
|
|
1319
|
+
* @name zebpay#closePosition
|
|
1320
|
+
* @description closes open positions for a market
|
|
1321
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-close-position
|
|
1322
|
+
* @param {string} symbol Unified CCXT market symbol
|
|
1323
|
+
* @param {string} side not used by kucoinfutures closePositions
|
|
1324
|
+
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
1325
|
+
* @param {string} [params.positionId] client order id of the order
|
|
1326
|
+
* @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
1327
|
+
*/
|
|
1328
|
+
async closePosition(symbol, side = undefined, params = {}) {
|
|
1329
|
+
await this.loadMarkets();
|
|
1330
|
+
const market = this.market(symbol);
|
|
1331
|
+
const request = {
|
|
1332
|
+
'symbol': market['id'],
|
|
1333
|
+
};
|
|
1334
|
+
const response = await this.privateSwapPostV1TradePositionClose(this.extend(request, params));
|
|
1335
|
+
const data = this.safeDict(response, 'data', {});
|
|
1336
|
+
return this.parseOrder(data, market);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* @method
|
|
1340
|
+
* @name zebpay#fetchLeverages
|
|
1341
|
+
* @description fetch the set leverage for all contract and margin markets
|
|
1342
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-all-user-leverages
|
|
1343
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
1344
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1345
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
1346
|
+
*/
|
|
1347
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
1348
|
+
await this.loadMarkets();
|
|
1349
|
+
const response = await this.privateSwapGetV1TradeUserLeverages(params);
|
|
1350
|
+
//
|
|
1351
|
+
// {
|
|
1352
|
+
// "leveragePreferences": [
|
|
1353
|
+
// {
|
|
1354
|
+
// "symbol": "ETHINR",
|
|
1355
|
+
// "shortLeverage": 1,
|
|
1356
|
+
// "longLeverage": 10,
|
|
1357
|
+
// "marginMode": "isolated"
|
|
1358
|
+
// },
|
|
1359
|
+
// ]
|
|
1360
|
+
// }
|
|
1361
|
+
//
|
|
1362
|
+
const leveragePreferences = this.safeList(response, 'data', []);
|
|
1363
|
+
return this.parseLeverages(leveragePreferences, symbols, 'symbol');
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* @method
|
|
1367
|
+
* @name zebpay#fetchLeverage
|
|
1368
|
+
* @description fetch the set leverage for a market
|
|
1369
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#get-user-leverage-single-symbol
|
|
1370
|
+
* @param {string} symbol unified market symbol
|
|
1371
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1372
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
1373
|
+
*/
|
|
1374
|
+
async fetchLeverage(symbol, params = {}) {
|
|
1375
|
+
await this.loadMarkets();
|
|
1376
|
+
const market = this.market(symbol);
|
|
1377
|
+
const request = {
|
|
1378
|
+
'symbol': market['id'].toUpperCase(),
|
|
1379
|
+
};
|
|
1380
|
+
const response = await this.privateSwapGetV1TradeUserLeverage(this.extend(request, params));
|
|
1381
|
+
//
|
|
1382
|
+
// {
|
|
1383
|
+
// "data": { symbol: "ETHINR", longLeverage: 1, shortLeverage: 1, marginMode: "isolated" }
|
|
1384
|
+
// }
|
|
1385
|
+
//
|
|
1386
|
+
const data = this.safeDict(response, 'data', {});
|
|
1387
|
+
return this.parseLeverage(data, market);
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* @method
|
|
1391
|
+
* @name zebpay#setLeverage
|
|
1392
|
+
* @description set the level of leverage for a market
|
|
1393
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-update-user-leverage
|
|
1394
|
+
* @param {float} leverage the rate of leverage
|
|
1395
|
+
* @param {string} symbol unified market symbol
|
|
1396
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1397
|
+
* @returns {object} response from the exchange
|
|
1398
|
+
*/
|
|
1399
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
1400
|
+
if (symbol === undefined) {
|
|
1401
|
+
throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
|
|
1402
|
+
}
|
|
1403
|
+
await this.loadMarkets();
|
|
1404
|
+
const market = this.market(symbol);
|
|
1405
|
+
const request = {
|
|
1406
|
+
'leverage': leverage,
|
|
1407
|
+
'symbol': market['id'],
|
|
1408
|
+
};
|
|
1409
|
+
//
|
|
1410
|
+
// { data: { "symbol", "longLeverage": 10, "shortLeverage": 1, "marginMode": "isolated" }
|
|
1411
|
+
//
|
|
1412
|
+
const response = await this.privateSwapPostV1TradeUpdateUserLeverage(this.extend(request, params));
|
|
1413
|
+
return response;
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* @method
|
|
1417
|
+
* @name zebpay#fetchPositions
|
|
1418
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--get-positions
|
|
1419
|
+
* @description Fetches current contract trading positions
|
|
1420
|
+
* @param {string[]} symbols List of unified symbols
|
|
1421
|
+
* @param {object} [params] Not used by krakenfutures
|
|
1422
|
+
* @returns Parsed exchange response for positions
|
|
1423
|
+
*/
|
|
1424
|
+
async fetchPositions(symbols = undefined, params = {}) {
|
|
1425
|
+
await this.loadMarkets();
|
|
1426
|
+
const request = {};
|
|
1427
|
+
if (symbols !== undefined) {
|
|
1428
|
+
request['symbols'] = this.marketIds(symbols);
|
|
1429
|
+
}
|
|
1430
|
+
const response = await this.privateSwapGetV1TradePositions(this.extend(request, params));
|
|
1431
|
+
//
|
|
1432
|
+
// {
|
|
1433
|
+
// "data": [
|
|
1434
|
+
// {
|
|
1435
|
+
// "id": "31998678-6056-413f-9d0d-fc3678641650",
|
|
1436
|
+
// "symbol": "ETHINR",
|
|
1437
|
+
// "entryPrice": "0.7533",
|
|
1438
|
+
// "datetime": "2022-03-03T22:51:16.566Z",
|
|
1439
|
+
// "contractSize": "230"
|
|
1440
|
+
// }
|
|
1441
|
+
// ],
|
|
1442
|
+
// }
|
|
1443
|
+
//
|
|
1444
|
+
const positions = this.safeList(response, 'data', []);
|
|
1445
|
+
const result = this.parsePositions(positions);
|
|
1446
|
+
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* @method
|
|
1450
|
+
* @name zebpayfutures#addMargin
|
|
1451
|
+
* @description add margin
|
|
1452
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-add-margin-to-position
|
|
1453
|
+
* @param {string} symbol unified market symbol
|
|
1454
|
+
* @param {float} amount amount of margin to add
|
|
1455
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint.
|
|
1456
|
+
* @param {string} [params.positionId] PositionId of the order to add margin.
|
|
1457
|
+
* @param {string} [params.timestamp] Tiemstamp.
|
|
1458
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
1459
|
+
*/
|
|
1460
|
+
async addMargin(symbol, amount, params = {}) {
|
|
1461
|
+
await this.loadMarkets();
|
|
1462
|
+
const market = this.market(symbol);
|
|
1463
|
+
const request = {
|
|
1464
|
+
'symbol': market['id'],
|
|
1465
|
+
'amount': amount,
|
|
1466
|
+
};
|
|
1467
|
+
const response = await this.privateSwapPostV1TradeAddMargin(this.extend(request, params));
|
|
1468
|
+
//
|
|
1469
|
+
// {
|
|
1470
|
+
// "code": "200000",
|
|
1471
|
+
// "data": {
|
|
1472
|
+
// "symbol": "BTCINR",
|
|
1473
|
+
// "type": "add",
|
|
1474
|
+
// "amount": 1000,
|
|
1475
|
+
// "code": "INR",
|
|
1476
|
+
// "status": "ok"
|
|
1477
|
+
// }
|
|
1478
|
+
// }
|
|
1479
|
+
//
|
|
1480
|
+
//
|
|
1481
|
+
// {
|
|
1482
|
+
// "code":"200000",
|
|
1483
|
+
// "msg":"Position does not exist"
|
|
1484
|
+
// }
|
|
1485
|
+
//
|
|
1486
|
+
const data = this.safeDict(response, 'data', {});
|
|
1487
|
+
return this.extend(this.parseMarginModification(data, market), {
|
|
1488
|
+
'amount': amount,
|
|
1489
|
+
'direction': 'in',
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* @method
|
|
1494
|
+
* @name zebpayfutures#reduceMargin
|
|
1495
|
+
* @description add margin
|
|
1496
|
+
* @see [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-reduce-margin-from-position
|
|
1497
|
+
* @param {string} symbol unified market symbol.
|
|
1498
|
+
* @param {float} amount amount of margin to add.
|
|
1499
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint.
|
|
1500
|
+
* @param {string} [params.positionId] PositionId of the order to add margin.
|
|
1501
|
+
* @param {string} [params.timestamp] Tiemstamp.
|
|
1502
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
1503
|
+
*/
|
|
1504
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
1505
|
+
await this.loadMarkets();
|
|
1506
|
+
const market = this.market(symbol);
|
|
1507
|
+
const request = {
|
|
1508
|
+
'symbol': market['id'],
|
|
1509
|
+
'amount': amount,
|
|
1510
|
+
};
|
|
1511
|
+
const response = await this.privateSwapPostV1TradeReduceMargin(this.extend(request, params));
|
|
1512
|
+
//
|
|
1513
|
+
// {
|
|
1514
|
+
// "code": "200000",
|
|
1515
|
+
// "data": {
|
|
1516
|
+
// "symbol": "BTCINR",
|
|
1517
|
+
// "type": "reduce",
|
|
1518
|
+
// "amount": 1000,
|
|
1519
|
+
// "code": "INR",
|
|
1520
|
+
// "status": "ok"
|
|
1521
|
+
// }
|
|
1522
|
+
// }
|
|
1523
|
+
//
|
|
1524
|
+
const data = this.safeDict(response, 'data', {});
|
|
1525
|
+
return this.extend(this.parseMarginModification(data, market), {
|
|
1526
|
+
'amount': amount,
|
|
1527
|
+
'direction': 'out',
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
async fetchSpotMarkets(params = {}) {
|
|
1531
|
+
const response = await this.publicSpotGetV2ExExchangeInfo(params);
|
|
1532
|
+
//
|
|
1533
|
+
// {
|
|
1534
|
+
// "data": {
|
|
1535
|
+
// "symbol": "ETH-INR",
|
|
1536
|
+
// "name": "ETH-INR",
|
|
1537
|
+
// "baseCurrency": "ETH",
|
|
1538
|
+
// "quoteCurrency": "INR",
|
|
1539
|
+
// "feeCurrency": "INR",
|
|
1540
|
+
// "baseMinSize": "",
|
|
1541
|
+
// "quoteMinSize": "100",
|
|
1542
|
+
// "baseMaxSize": "",
|
|
1543
|
+
// "quoteMaxSize": "2000",
|
|
1544
|
+
// "baseIncrement": "0.00001"
|
|
1545
|
+
// "quoteIncrement": "0.00001",
|
|
1546
|
+
// "enableTrading": true
|
|
1547
|
+
// }
|
|
1548
|
+
// }
|
|
1549
|
+
//
|
|
1550
|
+
const result = [];
|
|
1551
|
+
const data = this.safeDict(response, 'data', {});
|
|
1552
|
+
const markets = this.safeList(data, 'symbols', []);
|
|
1553
|
+
for (let i = 0; i < markets.length; i++) {
|
|
1554
|
+
const market = markets[i];
|
|
1555
|
+
const id = this.safeString(market, 'symbol');
|
|
1556
|
+
const baseId = this.safeString(market, 'baseAsset');
|
|
1557
|
+
const quoteId = this.safeString(market, 'quoteAsset');
|
|
1558
|
+
const base = this.safeCurrencyCode(baseId);
|
|
1559
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
1560
|
+
const symbol = base + '/' + quote;
|
|
1561
|
+
result.push({
|
|
1562
|
+
'id': id,
|
|
1563
|
+
'symbol': symbol,
|
|
1564
|
+
'base': base,
|
|
1565
|
+
'quote': quote,
|
|
1566
|
+
'baseId': baseId,
|
|
1567
|
+
'quoteId': quoteId,
|
|
1568
|
+
'type': 'spot',
|
|
1569
|
+
'spot': true,
|
|
1570
|
+
'swap': false,
|
|
1571
|
+
'margin': false,
|
|
1572
|
+
'future': false,
|
|
1573
|
+
'option': false,
|
|
1574
|
+
'active': undefined,
|
|
1575
|
+
'contract': undefined,
|
|
1576
|
+
'taker': this.safeNumber(market, 'takerFee'),
|
|
1577
|
+
'maker': this.safeNumber(market, 'makerFee'),
|
|
1578
|
+
'strike': undefined,
|
|
1579
|
+
'optionType': undefined,
|
|
1580
|
+
'precision': {
|
|
1581
|
+
'amount': this.safeNumber(market, 'lotSz'),
|
|
1582
|
+
'price': this.safeNumber(market, 'tickSz'),
|
|
1583
|
+
},
|
|
1584
|
+
'limits': {
|
|
1585
|
+
'amount': {
|
|
1586
|
+
'min': undefined,
|
|
1587
|
+
'max': undefined,
|
|
1588
|
+
},
|
|
1589
|
+
'price': {
|
|
1590
|
+
'min': undefined,
|
|
1591
|
+
'max': undefined,
|
|
1592
|
+
},
|
|
1593
|
+
'cost': {
|
|
1594
|
+
'min': undefined,
|
|
1595
|
+
'max': undefined,
|
|
1596
|
+
},
|
|
1597
|
+
},
|
|
1598
|
+
'info': market,
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
return result;
|
|
1602
|
+
}
|
|
1603
|
+
async fetchSwapMarkets(params = {}) {
|
|
1604
|
+
const response = await this.publicSwapGetV1MarketMarkets(params);
|
|
1605
|
+
//
|
|
1606
|
+
// {
|
|
1607
|
+
// "data": {
|
|
1608
|
+
// "symbol": "ETHUSDT",
|
|
1609
|
+
// "status": "TRADING",
|
|
1610
|
+
// "mainMarginPercent": "10",
|
|
1611
|
+
// "baseAsset": "ETH",
|
|
1612
|
+
// "quoteAsset": "USDT",
|
|
1613
|
+
// "pricePrecision": 1,
|
|
1614
|
+
// "quantityPrecision": 0.05,
|
|
1615
|
+
// "baseAssetPrecision": 0,
|
|
1616
|
+
// "quotePrecision": 0,
|
|
1617
|
+
// "orderType": ["LIMIT", "MARKET" ]
|
|
1618
|
+
// "timeInForce": ["GTC"],
|
|
1619
|
+
// "makerFee": "0.01",
|
|
1620
|
+
// "takerFee": "0.01",
|
|
1621
|
+
// "minLeverage": "1",
|
|
1622
|
+
// "maxLeverage": "20"
|
|
1623
|
+
// "tickSz": "0.1",
|
|
1624
|
+
// "lotSz": "0.1"
|
|
1625
|
+
// }
|
|
1626
|
+
// }
|
|
1627
|
+
//
|
|
1628
|
+
const result = [];
|
|
1629
|
+
const data = this.safeDict(response, 'data', {});
|
|
1630
|
+
const markets = this.safeList(data, 'symbols', []);
|
|
1631
|
+
for (let i = 0; i < markets.length; i++) {
|
|
1632
|
+
const market = markets[i];
|
|
1633
|
+
const id = this.safeString(market, 'symbol');
|
|
1634
|
+
const baseId = this.safeString(market, 'baseAsset');
|
|
1635
|
+
const quoteId = this.safeString(market, 'quoteAsset');
|
|
1636
|
+
const base = this.safeCurrencyCode(baseId);
|
|
1637
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
1638
|
+
const settle = this.safeCurrencyCode(quoteId);
|
|
1639
|
+
const status = this.safeString(market, 'status');
|
|
1640
|
+
const symbol = base + '/' + quote;
|
|
1641
|
+
result.push(this.safeMarketStructure({
|
|
1642
|
+
'id': id,
|
|
1643
|
+
'symbol': symbol + ':' + settle,
|
|
1644
|
+
'base': base,
|
|
1645
|
+
'quote': quote,
|
|
1646
|
+
'baseId': baseId,
|
|
1647
|
+
'quoteId': quoteId,
|
|
1648
|
+
'spot': false,
|
|
1649
|
+
'margin': false,
|
|
1650
|
+
'swap': true,
|
|
1651
|
+
'future': false,
|
|
1652
|
+
'type': 'swap',
|
|
1653
|
+
'option': false,
|
|
1654
|
+
'active': (status === 'Open'),
|
|
1655
|
+
'contract': true,
|
|
1656
|
+
'taker': this.safeNumber(market, 'takerFee'),
|
|
1657
|
+
'maker': this.safeNumber(market, 'makerFee'),
|
|
1658
|
+
'strike': undefined,
|
|
1659
|
+
'optionType': undefined,
|
|
1660
|
+
'precision': {
|
|
1661
|
+
'amount': this.safeNumber(market, 'lotSz'),
|
|
1662
|
+
'price': this.safeNumber(market, 'tickSz'),
|
|
1663
|
+
},
|
|
1664
|
+
'limits': {
|
|
1665
|
+
'leverage': {
|
|
1666
|
+
'min': this.safeNumber(market, 'minLeverage'),
|
|
1667
|
+
'max': this.safeNumber(market, 'maxLeverage'),
|
|
1668
|
+
},
|
|
1669
|
+
},
|
|
1670
|
+
'info': market,
|
|
1671
|
+
}));
|
|
1672
|
+
}
|
|
1673
|
+
return result;
|
|
1674
|
+
}
|
|
1675
|
+
parseBalance(response) {
|
|
1676
|
+
const result = {
|
|
1677
|
+
'info': response,
|
|
1678
|
+
'timestamp': undefined,
|
|
1679
|
+
'datetime': undefined,
|
|
1680
|
+
};
|
|
1681
|
+
const currencyList = this.safeList(response, 'data', []);
|
|
1682
|
+
for (let i = 0; i < currencyList.length; i++) {
|
|
1683
|
+
const entry = currencyList[i];
|
|
1684
|
+
const account = this.account();
|
|
1685
|
+
account['total'] = this.safeString(entry, 'total');
|
|
1686
|
+
account['free'] = this.safeString(entry, 'free');
|
|
1687
|
+
account['used'] = this.safeString(entry, 'used');
|
|
1688
|
+
const currencyId = this.safeString(entry, 'currency');
|
|
1689
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1690
|
+
result[code] = account;
|
|
1691
|
+
}
|
|
1692
|
+
return this.safeBalance(result);
|
|
1693
|
+
}
|
|
1694
|
+
parsePosition(position, market = undefined) {
|
|
1695
|
+
//
|
|
1696
|
+
// isolated
|
|
1697
|
+
// {
|
|
1698
|
+
// "id":"long",
|
|
1699
|
+
// "symbol":"pf_ftmusd",
|
|
1700
|
+
// "entryPrice":"0.4921",
|
|
1701
|
+
// "datetime":"2023-02-22T11:37:16.685Z",
|
|
1702
|
+
// "contractSize":"1",
|
|
1703
|
+
// "leverage":"1.0"
|
|
1704
|
+
// }
|
|
1705
|
+
//
|
|
1706
|
+
const leverage = this.safeNumber(position, 'leverage');
|
|
1707
|
+
const datetime = this.safeString(position, 'datetime');
|
|
1708
|
+
const marketId = this.safeString(position, 'symbol');
|
|
1709
|
+
market = this.safeMarket(marketId, market);
|
|
1710
|
+
return {
|
|
1711
|
+
'info': position,
|
|
1712
|
+
'symbol': marketId,
|
|
1713
|
+
'timestamp': this.parse8601(datetime),
|
|
1714
|
+
'datetime': datetime,
|
|
1715
|
+
'initialMargin': this.safeNumber(position, 'initialMargin'),
|
|
1716
|
+
'initialMarginPercentage': undefined,
|
|
1717
|
+
'maintenanceMargin': undefined,
|
|
1718
|
+
'maintenanceMarginPercentage': undefined,
|
|
1719
|
+
'entryPrice': this.safeNumber(position, 'entryPrice'),
|
|
1720
|
+
'notional': this.safeNumber(position, 'notional'),
|
|
1721
|
+
'leverage': leverage,
|
|
1722
|
+
'unrealizedPnl': undefined,
|
|
1723
|
+
'contracts': this.safeNumber(position, 'contracts'),
|
|
1724
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
1725
|
+
'marginRatio': undefined,
|
|
1726
|
+
'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
|
|
1727
|
+
'markPrice': undefined,
|
|
1728
|
+
'collateral': undefined,
|
|
1729
|
+
'marginType': 'isolated',
|
|
1730
|
+
'side': this.safeString(position, 'side'),
|
|
1731
|
+
'percentage': undefined,
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
parseLeverage(leverage, market = undefined) {
|
|
1735
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
1736
|
+
const info = this.safeDict(leverage, 'info');
|
|
1737
|
+
const leverageValue = this.safeInteger(leverage, 'longLeverage');
|
|
1738
|
+
const leverageValueShort = this.safeInteger(leverage, 'shortLeverage');
|
|
1739
|
+
const marginMode = this.safeString(leverage, 'marginMode');
|
|
1740
|
+
return {
|
|
1741
|
+
'info': info,
|
|
1742
|
+
'symbol': marketId,
|
|
1743
|
+
'marginMode': marginMode,
|
|
1744
|
+
'longLeverage': leverageValue,
|
|
1745
|
+
'shortLeverage': leverageValueShort,
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
parseTradingFee(fee, market = undefined) {
|
|
1749
|
+
const marketId = this.safeString(fee, 'symbol');
|
|
1750
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
1751
|
+
return {
|
|
1752
|
+
'info': fee,
|
|
1753
|
+
'symbol': symbol,
|
|
1754
|
+
'maker': this.safeNumber2(fee, 'makerFeeRate', 'makerFee'),
|
|
1755
|
+
'taker': this.safeNumber2(fee, 'takerFeeRate', 'takerFee'),
|
|
1756
|
+
'percentage': undefined,
|
|
1757
|
+
'tierBased': undefined,
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
parseTicker(ticker, market = undefined) {
|
|
1761
|
+
//
|
|
1762
|
+
// [
|
|
1763
|
+
// {
|
|
1764
|
+
// "symbol": "BTC-INR",
|
|
1765
|
+
// "bestBid": "4900000",
|
|
1766
|
+
// "bestBidQty": "0.00014938",
|
|
1767
|
+
// "bestAsk": "",
|
|
1768
|
+
// "bestAskQty": "0",
|
|
1769
|
+
// "priceChange": "-98134.56",
|
|
1770
|
+
// "priceChangePercent": "-1.84",
|
|
1771
|
+
// "high": "5433400",
|
|
1772
|
+
// "low": "5333400",
|
|
1773
|
+
// "vol": "0.0002",
|
|
1774
|
+
// "volValue": "1066.68",
|
|
1775
|
+
// "last": "5333400"
|
|
1776
|
+
// }
|
|
1777
|
+
// ]
|
|
1778
|
+
//
|
|
1779
|
+
const timestamp = this.safeInteger2(ticker, 'timestamp', 'ts', undefined);
|
|
1780
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
1781
|
+
market = this.safeMarket(marketId);
|
|
1782
|
+
const close = this.safeString(ticker, 'close', undefined);
|
|
1783
|
+
const last = this.safeString(ticker, 'last', undefined);
|
|
1784
|
+
const percentage = this.safeString(ticker, 'percentage');
|
|
1785
|
+
const bidVolume = this.safeString(ticker, 'bidVolume');
|
|
1786
|
+
const askVolume = this.safeString(ticker, 'askVolume');
|
|
1787
|
+
return this.safeTicker({
|
|
1788
|
+
'id': marketId,
|
|
1789
|
+
'symbol': market['symbol'],
|
|
1790
|
+
'timestamp': timestamp,
|
|
1791
|
+
'datetime': this.iso8601(timestamp),
|
|
1792
|
+
'high': this.safeString(ticker, 'high'),
|
|
1793
|
+
'low': this.safeString(ticker, 'low'),
|
|
1794
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
1795
|
+
'bidVolume': bidVolume,
|
|
1796
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
1797
|
+
'askVolume': askVolume,
|
|
1798
|
+
'vwap': undefined,
|
|
1799
|
+
'open': undefined,
|
|
1800
|
+
'close': close,
|
|
1801
|
+
'last': last,
|
|
1802
|
+
'previousClose': this.safeString(ticker, 'previousClose'),
|
|
1803
|
+
'change': this.safeString(ticker, 'change'),
|
|
1804
|
+
'percentage': percentage,
|
|
1805
|
+
'average': this.safeString(ticker, 'average'),
|
|
1806
|
+
'baseVolume': this.safeString(ticker, 'baseVolume'),
|
|
1807
|
+
'quoteVolume': this.safeString(ticker, 'quoteVolume'),
|
|
1808
|
+
'markPrice': undefined,
|
|
1809
|
+
'info': ticker,
|
|
1810
|
+
}, market);
|
|
1811
|
+
}
|
|
1812
|
+
parseMarginModification(info, market = undefined) {
|
|
1813
|
+
//
|
|
1814
|
+
// {
|
|
1815
|
+
// "symbol": "BTCINR",
|
|
1816
|
+
// "type": "reduce",
|
|
1817
|
+
// "amount": 1000,
|
|
1818
|
+
// "code": "INR",
|
|
1819
|
+
// "status": "ok"
|
|
1820
|
+
// }
|
|
1821
|
+
//
|
|
1822
|
+
const timestamp = this.milliseconds();
|
|
1823
|
+
return {
|
|
1824
|
+
'info': info,
|
|
1825
|
+
'symbol': market['id'],
|
|
1826
|
+
'type': undefined,
|
|
1827
|
+
'marginMode': undefined,
|
|
1828
|
+
'amount': this.safeNumber(info, 'amount'),
|
|
1829
|
+
'total': undefined,
|
|
1830
|
+
'code': this.safeString(info, 'code'),
|
|
1831
|
+
'status': this.safeString(info, 'status'),
|
|
1832
|
+
'timestamp': timestamp,
|
|
1833
|
+
'datetime': this.iso8601(timestamp),
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1837
|
+
params = this.omit(params, 'defaultType');
|
|
1838
|
+
const isV1 = path.indexOf('v1/') > -1;
|
|
1839
|
+
const marketType = isV1 ? 'swap' : 'spot';
|
|
1840
|
+
let url = this.urls['api'][marketType];
|
|
1841
|
+
const tail = '/api/' + this.implodeParams(path, params);
|
|
1842
|
+
url += tail;
|
|
1843
|
+
const timestamp = this.milliseconds().toString();
|
|
1844
|
+
let signature = '';
|
|
1845
|
+
const query = this.omit(params, this.extractParams(path));
|
|
1846
|
+
const queryLength = Object.keys(query).length;
|
|
1847
|
+
const access = this.safeString(api, 0, 'public');
|
|
1848
|
+
if (access === 'public') {
|
|
1849
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
1850
|
+
if (queryLength) {
|
|
1851
|
+
url += '?' + this.urlencode(query);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
body = JSON.stringify(params);
|
|
1856
|
+
headers = {
|
|
1857
|
+
'Referrer': 'ccxt',
|
|
1858
|
+
'Content-Type': 'application/json',
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1863
|
+
this.checkRequiredCredentials();
|
|
1864
|
+
const isSpot = marketType === 'spot';
|
|
1865
|
+
params['timestamp'] = timestamp;
|
|
1866
|
+
if (method === 'GET' || (method === 'DELETE' && isSpot)) {
|
|
1867
|
+
// For GET/DELETE: Append params to URL and sign the query string
|
|
1868
|
+
const queryString = this.urlencode(params);
|
|
1869
|
+
signature = this.hmac(this.encode(queryString), this.encode(this.secret), sha256.sha256, 'hex');
|
|
1870
|
+
url += '?' + queryString;
|
|
1871
|
+
}
|
|
1872
|
+
else {
|
|
1873
|
+
// For POST/PUT: Convert body to JSON and sign the stringified payload
|
|
1874
|
+
body = this.json(params);
|
|
1875
|
+
signature = this.hmac(this.encode(body), this.encode(this.secret), sha256.sha256, 'hex');
|
|
1876
|
+
}
|
|
1877
|
+
headers = {
|
|
1878
|
+
'Referrer': 'ccxt',
|
|
1879
|
+
'X-AUTH-APIKEY': this.apiKey,
|
|
1880
|
+
'X-AUTH-SIGNATURE': signature,
|
|
1881
|
+
};
|
|
1882
|
+
headers['Content-Type'] = 'application/json';
|
|
1883
|
+
}
|
|
1884
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1885
|
+
}
|
|
1886
|
+
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1887
|
+
if (!response) {
|
|
1888
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], body, body);
|
|
1889
|
+
return undefined;
|
|
1890
|
+
}
|
|
1891
|
+
//
|
|
1892
|
+
// bad
|
|
1893
|
+
// { "code": "400100", "msg": "validation.createOrder.clientOidIsRequired" }
|
|
1894
|
+
// good
|
|
1895
|
+
// { code: "200000", data: { ... }}
|
|
1896
|
+
// {"statusDescription":"Order quantity is out of range","data":{},"statusCode":400,"customMessage":["Order quantity is out of range"]}
|
|
1897
|
+
//
|
|
1898
|
+
const errorCode = this.safeString2(response, 'code', 'statusCode');
|
|
1899
|
+
const message = this.safeString2(response, 'msg', 'statusDescription');
|
|
1900
|
+
const feedback = this.id + ' ' + message;
|
|
1901
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
1902
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
|
|
1903
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
1904
|
+
return undefined;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
exports["default"] = zebpay;
|