ccxt 4.2.51 → 4.2.53
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/CHANGELOG.md +76 -16
- package/README.md +5 -6
- package/dist/ccxt.browser.js +994 -1412
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -4
- package/dist/cjs/src/base/Exchange.js +65 -26
- package/dist/cjs/src/binance.js +92 -3
- package/dist/cjs/src/bingx.js +32 -1
- package/dist/cjs/src/bitget.js +1 -0
- package/dist/cjs/src/bitvavo.js +1 -1
- package/dist/cjs/src/coinbase.js +186 -12
- package/dist/cjs/src/htx.js +10 -4
- package/dist/cjs/src/pro/binance.js +156 -1
- package/dist/cjs/src/pro/bitfinex2.js +3 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/blockchaincom.js +7 -25
- package/dist/cjs/src/pro/deribit.js +2 -2
- package/dist/cjs/src/pro/gate.js +2 -1
- package/dist/cjs/src/pro/gemini.js +1 -1
- package/dist/cjs/src/pro/okx.js +18 -4
- package/dist/cjs/src/woo.js +3 -1
- package/js/ccxt.d.ts +2 -5
- package/js/ccxt.js +2 -4
- package/js/src/abstract/coinbase.d.ts +1 -1
- package/js/src/base/Exchange.d.ts +65 -26
- package/js/src/base/Exchange.js +65 -26
- package/js/src/binance.d.ts +6 -0
- package/js/src/binance.js +92 -3
- package/js/src/bingx.d.ts +4 -0
- package/js/src/bingx.js +32 -1
- package/js/src/bitget.js +1 -0
- package/js/src/bitvavo.js +1 -1
- package/js/src/coinbase.d.ts +2 -0
- package/js/src/coinbase.js +186 -12
- package/js/src/deribit.js +1 -1
- package/js/src/htx.js +10 -4
- package/js/src/ndax.js +1 -1
- package/js/src/pro/binance.d.ts +3 -0
- package/js/src/pro/binance.js +156 -1
- package/js/src/pro/bingx.js +1 -1
- package/js/src/pro/bitfinex2.js +3 -1
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/blockchaincom.d.ts +0 -1
- package/js/src/pro/blockchaincom.js +7 -25
- package/js/src/pro/deribit.js +2 -2
- package/js/src/pro/gate.js +2 -1
- package/js/src/pro/gemini.js +1 -1
- package/js/src/pro/okx.js +18 -4
- package/js/src/woo.js +4 -2
- package/package.json +2 -1
- package/skip-tests.json +29 -13
- package/dist/cjs/src/abstract/bitforex.js +0 -9
- package/dist/cjs/src/bitforex.js +0 -884
- package/js/src/abstract/bitforex.d.ts +0 -27
- package/js/src/abstract/bitforex.js +0 -11
- package/js/src/bitforex.d.ts +0 -39
- package/js/src/bitforex.js +0 -885
package/js/src/bitforex.js
DELETED
|
@@ -1,885 +0,0 @@
|
|
|
1
|
-
// ----------------------------------------------------------------------------
|
|
2
|
-
|
|
3
|
-
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
-
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
-
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
-
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
import Exchange from './abstract/bitforex.js';
|
|
9
|
-
import { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, DDoSProtection, PermissionDenied, BadSymbol, InvalidOrder, ArgumentsRequired } from './base/errors.js';
|
|
10
|
-
import { TICK_SIZE } from './base/functions/number.js';
|
|
11
|
-
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
/**
|
|
14
|
-
* @class bitforex
|
|
15
|
-
* @augments Exchange
|
|
16
|
-
*/
|
|
17
|
-
export default class bitforex extends Exchange {
|
|
18
|
-
describe() {
|
|
19
|
-
return this.deepExtend(super.describe(), {
|
|
20
|
-
'id': 'bitforex',
|
|
21
|
-
'name': 'Bitforex',
|
|
22
|
-
'countries': ['CN'],
|
|
23
|
-
'rateLimit': 500,
|
|
24
|
-
'version': 'v1',
|
|
25
|
-
'has': {
|
|
26
|
-
'CORS': undefined,
|
|
27
|
-
'spot': true,
|
|
28
|
-
'margin': false,
|
|
29
|
-
'swap': false,
|
|
30
|
-
'future': false,
|
|
31
|
-
'option': false,
|
|
32
|
-
'addMargin': false,
|
|
33
|
-
'cancelAllOrders': true,
|
|
34
|
-
'cancelOrder': true,
|
|
35
|
-
'createOrder': true,
|
|
36
|
-
'createReduceOnlyOrder': false,
|
|
37
|
-
'createStopLimitOrder': false,
|
|
38
|
-
'createStopMarketOrder': false,
|
|
39
|
-
'createStopOrder': false,
|
|
40
|
-
'fetchBalance': true,
|
|
41
|
-
'fetchBorrowInterest': false,
|
|
42
|
-
'fetchBorrowRateHistories': false,
|
|
43
|
-
'fetchBorrowRateHistory': false,
|
|
44
|
-
'fetchClosedOrders': true,
|
|
45
|
-
'fetchCrossBorrowRate': false,
|
|
46
|
-
'fetchCrossBorrowRates': false,
|
|
47
|
-
'fetchDepositAddress': false,
|
|
48
|
-
'fetchDepositAddresses': false,
|
|
49
|
-
'fetchDepositAddressesByNetwork': false,
|
|
50
|
-
'fetchFundingHistory': false,
|
|
51
|
-
'fetchFundingRate': false,
|
|
52
|
-
'fetchFundingRateHistory': false,
|
|
53
|
-
'fetchFundingRates': false,
|
|
54
|
-
'fetchIndexOHLCV': false,
|
|
55
|
-
'fetchIsolatedBorrowRate': false,
|
|
56
|
-
'fetchIsolatedBorrowRates': false,
|
|
57
|
-
'fetchIsolatedPositions': false,
|
|
58
|
-
'fetchLeverage': false,
|
|
59
|
-
'fetchLeverageTiers': false,
|
|
60
|
-
'fetchMarginMode': false,
|
|
61
|
-
'fetchMarketLeverageTiers': false,
|
|
62
|
-
'fetchMarkets': true,
|
|
63
|
-
'fetchMarkOHLCV': false,
|
|
64
|
-
'fetchMyTrades': true,
|
|
65
|
-
'fetchOHLCV': true,
|
|
66
|
-
'fetchOpenInterestHistory': false,
|
|
67
|
-
'fetchOpenOrders': true,
|
|
68
|
-
'fetchOrder': true,
|
|
69
|
-
'fetchOrderBook': true,
|
|
70
|
-
'fetchPosition': false,
|
|
71
|
-
'fetchPositionMode': false,
|
|
72
|
-
'fetchPositions': false,
|
|
73
|
-
'fetchPositionsRisk': false,
|
|
74
|
-
'fetchPremiumIndexOHLCV': false,
|
|
75
|
-
'fetchTicker': true,
|
|
76
|
-
'fetchTickers': false,
|
|
77
|
-
'fetchTrades': true,
|
|
78
|
-
'fetchTransactionFees': false,
|
|
79
|
-
'fetchTransfer': false,
|
|
80
|
-
'fetchTransfers': false,
|
|
81
|
-
'fetchWithdrawal': false,
|
|
82
|
-
'fetchWithdrawals': false,
|
|
83
|
-
'reduceMargin': false,
|
|
84
|
-
'repayCrossMargin': false,
|
|
85
|
-
'repayIsolatedMargin': false,
|
|
86
|
-
'setLeverage': false,
|
|
87
|
-
'setMargin': false,
|
|
88
|
-
'setMarginMode': false,
|
|
89
|
-
'setPositionMode': false,
|
|
90
|
-
'transfer': false,
|
|
91
|
-
'withdraw': false,
|
|
92
|
-
},
|
|
93
|
-
'timeframes': {
|
|
94
|
-
'1m': '1min',
|
|
95
|
-
'5m': '5min',
|
|
96
|
-
'15m': '15min',
|
|
97
|
-
'30m': '30min',
|
|
98
|
-
'1h': '1hour',
|
|
99
|
-
'2h': '2hour',
|
|
100
|
-
'4h': '4hour',
|
|
101
|
-
'12h': '12hour',
|
|
102
|
-
'1d': '1day',
|
|
103
|
-
'1w': '1week',
|
|
104
|
-
'1M': '1month',
|
|
105
|
-
},
|
|
106
|
-
'urls': {
|
|
107
|
-
'logo': 'https://user-images.githubusercontent.com/51840849/87295553-1160ec00-c50e-11ea-8ea0-df79276a9646.jpg',
|
|
108
|
-
'api': {
|
|
109
|
-
'rest': 'https://api.bitforex.com',
|
|
110
|
-
},
|
|
111
|
-
'www': 'https://www.bitforex.com',
|
|
112
|
-
'doc': 'https://github.com/githubdev2020/API_Doc_en/wiki',
|
|
113
|
-
'fees': 'https://help.bitforex.com/en_us/?cat=13',
|
|
114
|
-
'referral': 'https://www.bitforex.com/en/invitationRegister?inviterId=1867438',
|
|
115
|
-
},
|
|
116
|
-
'api': {
|
|
117
|
-
'public': {
|
|
118
|
-
'get': {
|
|
119
|
-
'/api/v1/ping': 0.2,
|
|
120
|
-
'/api/v1/time': 0.2,
|
|
121
|
-
'api/v1/market/symbols': 20,
|
|
122
|
-
'api/v1/market/ticker': 4,
|
|
123
|
-
'api/v1/market/ticker-all': 4,
|
|
124
|
-
'api/v1/market/depth': 4,
|
|
125
|
-
'api/v1/market/depth-all': 4,
|
|
126
|
-
'api/v1/market/trades': 20,
|
|
127
|
-
'api/v1/market/kline': 20,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
'private': {
|
|
131
|
-
'post': {
|
|
132
|
-
'api/v1/fund/mainAccount': 1,
|
|
133
|
-
'api/v1/fund/allAccount': 30,
|
|
134
|
-
'api/v1/trade/placeOrder': 1,
|
|
135
|
-
'api/v1/trade/placeMultiOrder': 10,
|
|
136
|
-
'api/v1/trade/cancelOrder': 1,
|
|
137
|
-
'api/v1/trade/cancelMultiOrder': 6.67,
|
|
138
|
-
'api/v1/trade/cancelAllOrder': 20,
|
|
139
|
-
'api/v1/trade/orderInfo': 1,
|
|
140
|
-
'api/v1/trade/multiOrderInfo': 10,
|
|
141
|
-
'api/v1/trade/orderInfos': 20,
|
|
142
|
-
'api/v1/trade/myTrades': 2,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
'fees': {
|
|
147
|
-
'trading': {
|
|
148
|
-
'tierBased': false,
|
|
149
|
-
'percentage': true,
|
|
150
|
-
'maker': this.parseNumber('0.001'),
|
|
151
|
-
'taker': this.parseNumber('0.001'),
|
|
152
|
-
},
|
|
153
|
-
'funding': {
|
|
154
|
-
'tierBased': false,
|
|
155
|
-
'percentage': true,
|
|
156
|
-
'deposit': {},
|
|
157
|
-
'withdraw': {},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
'commonCurrencies': {
|
|
161
|
-
'BKC': 'Bank Coin',
|
|
162
|
-
'CAPP': 'Crypto Application Token',
|
|
163
|
-
'CREDIT': 'TerraCredit',
|
|
164
|
-
'CTC': 'Culture Ticket Chain',
|
|
165
|
-
'EWT': 'EcoWatt Token',
|
|
166
|
-
'IQ': 'IQ.Cash',
|
|
167
|
-
'MIR': 'MIR COIN',
|
|
168
|
-
'NOIA': 'METANOIA',
|
|
169
|
-
'TON': 'To The Moon',
|
|
170
|
-
},
|
|
171
|
-
'precisionMode': TICK_SIZE,
|
|
172
|
-
'exceptions': {
|
|
173
|
-
'1000': OrderNotFound,
|
|
174
|
-
'1003': BadSymbol,
|
|
175
|
-
'1013': AuthenticationError,
|
|
176
|
-
'1016': AuthenticationError,
|
|
177
|
-
'1017': PermissionDenied,
|
|
178
|
-
'1019': BadSymbol,
|
|
179
|
-
'3002': InsufficientFunds,
|
|
180
|
-
'4002': InvalidOrder,
|
|
181
|
-
'4003': InvalidOrder,
|
|
182
|
-
'4004': OrderNotFound,
|
|
183
|
-
'10204': DDoSProtection,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
async fetchMarkets(params = {}) {
|
|
188
|
-
/**
|
|
189
|
-
* @method
|
|
190
|
-
* @name bitforex#fetchMarkets
|
|
191
|
-
* @description retrieves data on all markets for bitforex
|
|
192
|
-
* @see https://apidoc.bitforex.com/#exchange-information
|
|
193
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
194
|
-
* @returns {object[]} an array of objects representing market data
|
|
195
|
-
*/
|
|
196
|
-
const response = await this.publicGetApiV1MarketSymbols(params);
|
|
197
|
-
//
|
|
198
|
-
// {
|
|
199
|
-
// "data": [
|
|
200
|
-
// {
|
|
201
|
-
// "amountPrecision":4,
|
|
202
|
-
// "minOrderAmount":3.0E-4,
|
|
203
|
-
// "pricePrecision":2,
|
|
204
|
-
// "symbol":"coin-usdt-btc"
|
|
205
|
-
// },
|
|
206
|
-
// ...
|
|
207
|
-
// ]
|
|
208
|
-
// }
|
|
209
|
-
//
|
|
210
|
-
const data = response['data'];
|
|
211
|
-
const result = [];
|
|
212
|
-
for (let i = 0; i < data.length; i++) {
|
|
213
|
-
const market = data[i];
|
|
214
|
-
const id = this.safeString(market, 'symbol');
|
|
215
|
-
const symbolParts = id.split('-');
|
|
216
|
-
const baseId = symbolParts[2];
|
|
217
|
-
const quoteId = symbolParts[1];
|
|
218
|
-
const base = this.safeCurrencyCode(baseId);
|
|
219
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
220
|
-
result.push({
|
|
221
|
-
'id': id,
|
|
222
|
-
'symbol': base + '/' + quote,
|
|
223
|
-
'base': base,
|
|
224
|
-
'quote': quote,
|
|
225
|
-
'settle': undefined,
|
|
226
|
-
'baseId': baseId,
|
|
227
|
-
'quoteId': quoteId,
|
|
228
|
-
'settleId': undefined,
|
|
229
|
-
'type': 'spot',
|
|
230
|
-
'spot': true,
|
|
231
|
-
'margin': false,
|
|
232
|
-
'swap': false,
|
|
233
|
-
'future': false,
|
|
234
|
-
'option': false,
|
|
235
|
-
'active': true,
|
|
236
|
-
'contract': false,
|
|
237
|
-
'linear': undefined,
|
|
238
|
-
'inverse': undefined,
|
|
239
|
-
'contractSize': undefined,
|
|
240
|
-
'expiry': undefined,
|
|
241
|
-
'expiryDateTime': undefined,
|
|
242
|
-
'strike': undefined,
|
|
243
|
-
'optionType': undefined,
|
|
244
|
-
'precision': {
|
|
245
|
-
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'amountPrecision'))),
|
|
246
|
-
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
|
|
247
|
-
},
|
|
248
|
-
'limits': {
|
|
249
|
-
'leverage': {
|
|
250
|
-
'min': undefined,
|
|
251
|
-
'max': undefined,
|
|
252
|
-
},
|
|
253
|
-
'amount': {
|
|
254
|
-
'min': this.safeNumber(market, 'minOrderAmount'),
|
|
255
|
-
'max': undefined,
|
|
256
|
-
},
|
|
257
|
-
'price': {
|
|
258
|
-
'min': undefined,
|
|
259
|
-
'max': undefined,
|
|
260
|
-
},
|
|
261
|
-
'cost': {
|
|
262
|
-
'min': undefined,
|
|
263
|
-
'max': undefined,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
'created': undefined,
|
|
267
|
-
'info': market,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
return result;
|
|
271
|
-
}
|
|
272
|
-
parseTrade(trade, market = undefined) {
|
|
273
|
-
//
|
|
274
|
-
// fetchTrades (public) v1
|
|
275
|
-
//
|
|
276
|
-
// {
|
|
277
|
-
// "price":57594.53,
|
|
278
|
-
// "amount":0.3172,
|
|
279
|
-
// "time":1637329685322,
|
|
280
|
-
// "direction":1,
|
|
281
|
-
// "tid":"1131019666"
|
|
282
|
-
// }
|
|
283
|
-
//
|
|
284
|
-
// fetchMyTrades (private)
|
|
285
|
-
//
|
|
286
|
-
// {
|
|
287
|
-
// "symbol": "coin-usdt-babydoge",
|
|
288
|
-
// "tid": 7289,
|
|
289
|
-
// "orderId": "b6fe2b61-e5cb-4970-9bdc-8c7cd1fcb4d8",
|
|
290
|
-
// "price": "0.000007",
|
|
291
|
-
// "amount": "50000000",
|
|
292
|
-
// "tradeFee": "50000",
|
|
293
|
-
// "tradeFeeCurrency": "babydoge",
|
|
294
|
-
// "time": "1684750536460",
|
|
295
|
-
// "isBuyer": true,
|
|
296
|
-
// "isMaker": true,
|
|
297
|
-
// "isSelfTrade": true
|
|
298
|
-
// }
|
|
299
|
-
//
|
|
300
|
-
const marketId = this.safeString(trade, 'symbol');
|
|
301
|
-
market = this.safeMarket(marketId, market);
|
|
302
|
-
const timestamp = this.safeInteger(trade, 'time');
|
|
303
|
-
const id = this.safeString(trade, 'tid');
|
|
304
|
-
const orderId = this.safeString(trade, 'orderId');
|
|
305
|
-
const priceString = this.safeString(trade, 'price');
|
|
306
|
-
const amountString = this.safeString(trade, 'amount');
|
|
307
|
-
const sideId = this.safeInteger(trade, 'direction');
|
|
308
|
-
let side = this.parseSide(sideId);
|
|
309
|
-
if (side === undefined) {
|
|
310
|
-
const isBuyer = this.safeValue(trade, 'isBuyer');
|
|
311
|
-
side = isBuyer ? 'buy' : 'sell';
|
|
312
|
-
}
|
|
313
|
-
let takerOrMaker = undefined;
|
|
314
|
-
const isMaker = this.safeValue(trade, 'isMaker');
|
|
315
|
-
if (isMaker !== undefined) {
|
|
316
|
-
takerOrMaker = (isMaker) ? 'maker' : 'taker';
|
|
317
|
-
}
|
|
318
|
-
let fee = undefined;
|
|
319
|
-
const feeCostString = this.safeString(trade, 'tradeFee');
|
|
320
|
-
if (feeCostString !== undefined) {
|
|
321
|
-
const feeCurrencyId = this.safeString(trade, 'tradeFeeCurrency');
|
|
322
|
-
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
323
|
-
fee = {
|
|
324
|
-
'cost': feeCostString,
|
|
325
|
-
'currency': feeCurrencyCode,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
return this.safeTrade({
|
|
329
|
-
'info': trade,
|
|
330
|
-
'id': id,
|
|
331
|
-
'timestamp': timestamp,
|
|
332
|
-
'datetime': this.iso8601(timestamp),
|
|
333
|
-
'symbol': market['symbol'],
|
|
334
|
-
'type': undefined,
|
|
335
|
-
'side': side,
|
|
336
|
-
'price': priceString,
|
|
337
|
-
'amount': amountString,
|
|
338
|
-
'cost': undefined,
|
|
339
|
-
'order': orderId,
|
|
340
|
-
'fee': fee,
|
|
341
|
-
'takerOrMaker': takerOrMaker,
|
|
342
|
-
}, market);
|
|
343
|
-
}
|
|
344
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
345
|
-
/**
|
|
346
|
-
* @method
|
|
347
|
-
* @name bitforex#fetchTrades
|
|
348
|
-
* @description get the list of most recent trades for a particular symbol
|
|
349
|
-
* @see https://apidoc.bitforex.com/#recent-trades-list
|
|
350
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
351
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
352
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
353
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
354
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
355
|
-
*/
|
|
356
|
-
await this.loadMarkets();
|
|
357
|
-
const request = {
|
|
358
|
-
'symbol': this.marketId(symbol),
|
|
359
|
-
};
|
|
360
|
-
if (limit !== undefined) {
|
|
361
|
-
request['size'] = limit;
|
|
362
|
-
}
|
|
363
|
-
const market = this.market(symbol);
|
|
364
|
-
const response = await this.publicGetApiV1MarketTrades(this.extend(request, params));
|
|
365
|
-
//
|
|
366
|
-
// {
|
|
367
|
-
// "data":
|
|
368
|
-
// [
|
|
369
|
-
// {
|
|
370
|
-
// "price":57594.53,
|
|
371
|
-
// "amount":0.3172,
|
|
372
|
-
// "time":1637329685322,
|
|
373
|
-
// "direction":1,
|
|
374
|
-
// "tid":"1131019666"
|
|
375
|
-
// }
|
|
376
|
-
// ],
|
|
377
|
-
// "success": true,
|
|
378
|
-
// "time": 1637329688475
|
|
379
|
-
// }
|
|
380
|
-
//
|
|
381
|
-
return this.parseTrades(response['data'], market, since, limit);
|
|
382
|
-
}
|
|
383
|
-
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
384
|
-
/**
|
|
385
|
-
* @method
|
|
386
|
-
* @name bitforex#fetchMyTrades
|
|
387
|
-
* @description fetch all trades made by the user
|
|
388
|
-
* @see https://apidoc.bitforex.com/#spot-account-trade
|
|
389
|
-
* @param {string} symbol unified market symbol
|
|
390
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
391
|
-
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
392
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
393
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
394
|
-
*/
|
|
395
|
-
if (symbol === undefined) {
|
|
396
|
-
throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
397
|
-
}
|
|
398
|
-
await this.loadMarkets();
|
|
399
|
-
const request = {
|
|
400
|
-
// 'symbol': market['id'],
|
|
401
|
-
// 'orderId': orderId,
|
|
402
|
-
// 'startTime': timestamp,
|
|
403
|
-
// 'endTime': timestamp,
|
|
404
|
-
// 'limit': limit, // default 500, max 1000
|
|
405
|
-
};
|
|
406
|
-
const market = this.market(symbol);
|
|
407
|
-
request['symbol'] = market['id'];
|
|
408
|
-
if (limit !== undefined) {
|
|
409
|
-
request['limit'] = limit;
|
|
410
|
-
}
|
|
411
|
-
if (since !== undefined) {
|
|
412
|
-
request['startTime'] = Math.max(since - 1, 0);
|
|
413
|
-
}
|
|
414
|
-
const endTime = this.safeInteger2(params, 'until', 'endTime');
|
|
415
|
-
if (endTime !== undefined) {
|
|
416
|
-
request['endTime'] = endTime;
|
|
417
|
-
}
|
|
418
|
-
params = this.omit(params, ['until']);
|
|
419
|
-
const response = await this.privatePostApiV1TradeMyTrades(this.extend(request, params));
|
|
420
|
-
//
|
|
421
|
-
// {
|
|
422
|
-
// "data": [
|
|
423
|
-
// {
|
|
424
|
-
// "symbol": "coin-usdt-babydoge",
|
|
425
|
-
// "tid": 7289,
|
|
426
|
-
// "orderId": "a262d030-11a5-40fd-a07c-7ba84aa68752",
|
|
427
|
-
// "price": "0.000007",
|
|
428
|
-
// "amount": "50000000",
|
|
429
|
-
// "tradeFee": "0.35",
|
|
430
|
-
// "tradeFeeCurrency": "usdt",
|
|
431
|
-
// "time": "1684750536460",
|
|
432
|
-
// "isBuyer": false,
|
|
433
|
-
// "isMaker": false,
|
|
434
|
-
// "isSelfTrade": true
|
|
435
|
-
// }
|
|
436
|
-
// ],
|
|
437
|
-
// "success": true,
|
|
438
|
-
// "time": 1685009320042
|
|
439
|
-
// }
|
|
440
|
-
//
|
|
441
|
-
const data = this.safeValue(response, 'data', []);
|
|
442
|
-
return this.parseTrades(data, market, since, limit);
|
|
443
|
-
}
|
|
444
|
-
parseBalance(response) {
|
|
445
|
-
const data = response['data'];
|
|
446
|
-
const result = { 'info': response };
|
|
447
|
-
for (let i = 0; i < data.length; i++) {
|
|
448
|
-
const balance = data[i];
|
|
449
|
-
const currencyId = this.safeString(balance, 'currency');
|
|
450
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
451
|
-
const account = this.account();
|
|
452
|
-
account['used'] = this.safeString(balance, 'frozen');
|
|
453
|
-
account['free'] = this.safeString(balance, 'active');
|
|
454
|
-
account['total'] = this.safeString(balance, 'fix');
|
|
455
|
-
result[code] = account;
|
|
456
|
-
}
|
|
457
|
-
return this.safeBalance(result);
|
|
458
|
-
}
|
|
459
|
-
async fetchBalance(params = {}) {
|
|
460
|
-
/**
|
|
461
|
-
* @method
|
|
462
|
-
* @name bitforex#fetchBalance
|
|
463
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
464
|
-
* @see https://apidoc.bitforex.com/#user-all-asset-information-user_data
|
|
465
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
466
|
-
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
467
|
-
*/
|
|
468
|
-
await this.loadMarkets();
|
|
469
|
-
const response = await this.privatePostApiV1FundAllAccount(params);
|
|
470
|
-
return this.parseBalance(response);
|
|
471
|
-
}
|
|
472
|
-
parseTicker(ticker, market = undefined) {
|
|
473
|
-
//
|
|
474
|
-
// {
|
|
475
|
-
// "buy":7.04E-7,
|
|
476
|
-
// "date":1643371198598,
|
|
477
|
-
// "high":7.48E-7,
|
|
478
|
-
// "last":7.28E-7,
|
|
479
|
-
// "low":7.10E-7,
|
|
480
|
-
// "sell":7.54E-7,
|
|
481
|
-
// "vol":9877287.2874
|
|
482
|
-
// }
|
|
483
|
-
//
|
|
484
|
-
const symbol = this.safeSymbol(undefined, market);
|
|
485
|
-
const timestamp = this.safeInteger(ticker, 'date');
|
|
486
|
-
return this.safeTicker({
|
|
487
|
-
'symbol': symbol,
|
|
488
|
-
'timestamp': timestamp,
|
|
489
|
-
'datetime': this.iso8601(timestamp),
|
|
490
|
-
'high': this.safeString(ticker, 'high'),
|
|
491
|
-
'low': this.safeString(ticker, 'low'),
|
|
492
|
-
'bid': this.safeString(ticker, 'buy'),
|
|
493
|
-
'bidVolume': undefined,
|
|
494
|
-
'ask': this.safeString(ticker, 'sell'),
|
|
495
|
-
'askVolume': undefined,
|
|
496
|
-
'vwap': undefined,
|
|
497
|
-
'open': undefined,
|
|
498
|
-
'close': this.safeString(ticker, 'last'),
|
|
499
|
-
'last': this.safeString(ticker, 'last'),
|
|
500
|
-
'previousClose': undefined,
|
|
501
|
-
'change': undefined,
|
|
502
|
-
'percentage': undefined,
|
|
503
|
-
'average': undefined,
|
|
504
|
-
'baseVolume': this.safeString(ticker, 'vol'),
|
|
505
|
-
'quoteVolume': undefined,
|
|
506
|
-
'info': ticker,
|
|
507
|
-
}, market);
|
|
508
|
-
}
|
|
509
|
-
async fetchTicker(symbol, params = {}) {
|
|
510
|
-
/**
|
|
511
|
-
* @method
|
|
512
|
-
* @name bitforex#fetchTicker
|
|
513
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
514
|
-
* @see https://apidoc.bitforex.com/#exchange-information
|
|
515
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
516
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
517
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
518
|
-
*/
|
|
519
|
-
await this.loadMarkets();
|
|
520
|
-
const market = this.markets[symbol];
|
|
521
|
-
const request = {
|
|
522
|
-
'symbol': market['id'],
|
|
523
|
-
};
|
|
524
|
-
const response = await this.publicGetApiV1MarketTickerAll(this.extend(request, params));
|
|
525
|
-
const ticker = this.safeValue(response, 'data');
|
|
526
|
-
//
|
|
527
|
-
// {
|
|
528
|
-
// "data":{
|
|
529
|
-
// "buy":37082.83,
|
|
530
|
-
// "date":1643388686660,
|
|
531
|
-
// "high":37487.83,
|
|
532
|
-
// "last":37086.79,
|
|
533
|
-
// "low":35544.44,
|
|
534
|
-
// "sell":37090.52,
|
|
535
|
-
// "vol":690.9776
|
|
536
|
-
// },
|
|
537
|
-
// "success":true,
|
|
538
|
-
// "time":1643388686660
|
|
539
|
-
// }
|
|
540
|
-
//
|
|
541
|
-
return this.parseTicker(ticker, market);
|
|
542
|
-
}
|
|
543
|
-
parseOHLCV(ohlcv, market = undefined) {
|
|
544
|
-
//
|
|
545
|
-
// {
|
|
546
|
-
// "close":0.02505143,
|
|
547
|
-
// "currencyVol":0,
|
|
548
|
-
// "high":0.02506422,
|
|
549
|
-
// "low":0.02505143,
|
|
550
|
-
// "open":0.02506095,
|
|
551
|
-
// "time":1591508940000,
|
|
552
|
-
// "vol":51.1869
|
|
553
|
-
// }
|
|
554
|
-
//
|
|
555
|
-
return [
|
|
556
|
-
this.safeInteger(ohlcv, 'time'),
|
|
557
|
-
this.safeNumber(ohlcv, 'open'),
|
|
558
|
-
this.safeNumber(ohlcv, 'high'),
|
|
559
|
-
this.safeNumber(ohlcv, 'low'),
|
|
560
|
-
this.safeNumber(ohlcv, 'close'),
|
|
561
|
-
this.safeNumber(ohlcv, 'vol'),
|
|
562
|
-
];
|
|
563
|
-
}
|
|
564
|
-
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
565
|
-
/**
|
|
566
|
-
* @method
|
|
567
|
-
* @name bitforex#fetchOHLCV
|
|
568
|
-
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
569
|
-
* @see https://apidoc.bitforex.com/#kline
|
|
570
|
-
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
571
|
-
* @param {string} timeframe the length of time each candle represents
|
|
572
|
-
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
573
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
574
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
575
|
-
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
576
|
-
*/
|
|
577
|
-
await this.loadMarkets();
|
|
578
|
-
const market = this.market(symbol);
|
|
579
|
-
const request = {
|
|
580
|
-
'symbol': market['id'],
|
|
581
|
-
'ktype': this.safeString(this.timeframes, timeframe, timeframe),
|
|
582
|
-
};
|
|
583
|
-
if (limit !== undefined) {
|
|
584
|
-
request['size'] = limit; // default 1, max 600
|
|
585
|
-
}
|
|
586
|
-
const response = await this.publicGetApiV1MarketKline(this.extend(request, params));
|
|
587
|
-
//
|
|
588
|
-
// {
|
|
589
|
-
// "data":[
|
|
590
|
-
// {"close":0.02505143,"currencyVol":0,"high":0.02506422,"low":0.02505143,"open":0.02506095,"time":1591508940000,"vol":51.1869},
|
|
591
|
-
// {"close":0.02503914,"currencyVol":0,"high":0.02506687,"low":0.02503914,"open":0.02505358,"time":1591509000000,"vol":9.1082},
|
|
592
|
-
// {"close":0.02505172,"currencyVol":0,"high":0.02507466,"low":0.02503895,"open":0.02506371,"time":1591509060000,"vol":63.7431},
|
|
593
|
-
// ],
|
|
594
|
-
// "success":true,
|
|
595
|
-
// "time":1591509427131
|
|
596
|
-
// }
|
|
597
|
-
//
|
|
598
|
-
const data = this.safeValue(response, 'data', []);
|
|
599
|
-
return this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
600
|
-
}
|
|
601
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
602
|
-
/**
|
|
603
|
-
* @method
|
|
604
|
-
* @name bitforex#fetchOrderBook
|
|
605
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
606
|
-
* @see https://apidoc.bitforex.com/#order-book
|
|
607
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
608
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
609
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
610
|
-
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
611
|
-
*/
|
|
612
|
-
await this.loadMarkets();
|
|
613
|
-
const market = this.market(symbol);
|
|
614
|
-
const request = {
|
|
615
|
-
'symbol': market['id'],
|
|
616
|
-
};
|
|
617
|
-
if (limit !== undefined) {
|
|
618
|
-
request['size'] = limit;
|
|
619
|
-
}
|
|
620
|
-
const response = await this.publicGetApiV1MarketDepthAll(this.extend(request, params));
|
|
621
|
-
const data = this.safeValue(response, 'data');
|
|
622
|
-
const timestamp = this.safeInteger(response, 'time');
|
|
623
|
-
return this.parseOrderBook(data, market['symbol'], timestamp, 'bids', 'asks', 'price', 'amount');
|
|
624
|
-
}
|
|
625
|
-
parseOrderStatus(status) {
|
|
626
|
-
const statuses = {
|
|
627
|
-
'0': 'open',
|
|
628
|
-
'1': 'open',
|
|
629
|
-
'2': 'closed',
|
|
630
|
-
'3': 'canceled',
|
|
631
|
-
'4': 'canceled',
|
|
632
|
-
};
|
|
633
|
-
return (status in statuses) ? statuses[status] : status;
|
|
634
|
-
}
|
|
635
|
-
parseSide(sideId) {
|
|
636
|
-
if (sideId === 1) {
|
|
637
|
-
return 'buy';
|
|
638
|
-
}
|
|
639
|
-
else if (sideId === 2) {
|
|
640
|
-
return 'sell';
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
return undefined;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
parseOrder(order, market = undefined) {
|
|
647
|
-
const id = this.safeString(order, 'orderId');
|
|
648
|
-
const timestamp = this.safeInteger(order, 'createTime');
|
|
649
|
-
const lastTradeTimestamp = this.safeInteger(order, 'lastTime');
|
|
650
|
-
const symbol = market['symbol'];
|
|
651
|
-
const sideId = this.safeInteger(order, 'tradeType');
|
|
652
|
-
const side = this.parseSide(sideId);
|
|
653
|
-
const type = undefined;
|
|
654
|
-
const price = this.safeString(order, 'orderPrice');
|
|
655
|
-
const average = this.safeString(order, 'avgPrice');
|
|
656
|
-
const amount = this.safeString(order, 'orderAmount');
|
|
657
|
-
const filled = this.safeString(order, 'dealAmount');
|
|
658
|
-
const status = this.parseOrderStatus(this.safeString(order, 'orderState'));
|
|
659
|
-
const feeSide = (side === 'buy') ? 'base' : 'quote';
|
|
660
|
-
const feeCurrency = market[feeSide];
|
|
661
|
-
const fee = {
|
|
662
|
-
'cost': this.safeNumber(order, 'tradeFee'),
|
|
663
|
-
'currency': feeCurrency,
|
|
664
|
-
};
|
|
665
|
-
return this.safeOrder({
|
|
666
|
-
'info': order,
|
|
667
|
-
'id': id,
|
|
668
|
-
'clientOrderId': undefined,
|
|
669
|
-
'timestamp': timestamp,
|
|
670
|
-
'datetime': this.iso8601(timestamp),
|
|
671
|
-
'lastTradeTimestamp': lastTradeTimestamp,
|
|
672
|
-
'symbol': symbol,
|
|
673
|
-
'type': type,
|
|
674
|
-
'timeInForce': undefined,
|
|
675
|
-
'postOnly': undefined,
|
|
676
|
-
'side': side,
|
|
677
|
-
'price': price,
|
|
678
|
-
'stopPrice': undefined,
|
|
679
|
-
'triggerPrice': undefined,
|
|
680
|
-
'cost': undefined,
|
|
681
|
-
'average': average,
|
|
682
|
-
'amount': amount,
|
|
683
|
-
'filled': filled,
|
|
684
|
-
'remaining': undefined,
|
|
685
|
-
'status': status,
|
|
686
|
-
'fee': fee,
|
|
687
|
-
'trades': undefined,
|
|
688
|
-
}, market);
|
|
689
|
-
}
|
|
690
|
-
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
691
|
-
/**
|
|
692
|
-
* @method
|
|
693
|
-
* @name bitforex#cancelAllOrders
|
|
694
|
-
* @see https://github.com/githubdev2020/API_Doc_en/wiki/Cancle-all-orders
|
|
695
|
-
* @description cancel all open orders in a market
|
|
696
|
-
* @param {string} symbol unified market symbol of the market to cancel orders in
|
|
697
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
698
|
-
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
699
|
-
*/
|
|
700
|
-
if (symbol === undefined) {
|
|
701
|
-
throw new ArgumentsRequired(this.id + ' cancelAllOrders () requires a symbol argument');
|
|
702
|
-
}
|
|
703
|
-
await this.loadMarkets();
|
|
704
|
-
const market = this.market(symbol);
|
|
705
|
-
const request = {
|
|
706
|
-
'symbol': market['id'],
|
|
707
|
-
};
|
|
708
|
-
const response = await this.privatePostApiV1TradeCancelAllOrder(this.extend(request, params));
|
|
709
|
-
//
|
|
710
|
-
// {
|
|
711
|
-
// 'data': True,
|
|
712
|
-
// 'success': True,
|
|
713
|
-
// 'time': '1706542995252'
|
|
714
|
-
// }
|
|
715
|
-
//
|
|
716
|
-
return response;
|
|
717
|
-
}
|
|
718
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
719
|
-
/**
|
|
720
|
-
* @method
|
|
721
|
-
* @name bitforex#fetchOrder
|
|
722
|
-
* @description fetches information on an order made by the user
|
|
723
|
-
* @see https://apidoc.bitforex.com/#order-information-user_data
|
|
724
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
725
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
726
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
727
|
-
*/
|
|
728
|
-
await this.loadMarkets();
|
|
729
|
-
const market = this.market(symbol);
|
|
730
|
-
const request = {
|
|
731
|
-
'symbol': this.marketId(symbol),
|
|
732
|
-
'orderId': id,
|
|
733
|
-
};
|
|
734
|
-
const response = await this.privatePostApiV1TradeOrderInfo(this.extend(request, params));
|
|
735
|
-
const order = this.parseOrder(response['data'], market);
|
|
736
|
-
return order;
|
|
737
|
-
}
|
|
738
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
739
|
-
/**
|
|
740
|
-
* @method
|
|
741
|
-
* @name bitforex#fetchOpenOrders
|
|
742
|
-
* @description fetch all unfilled currently open orders
|
|
743
|
-
* @param {string} symbol unified market symbol
|
|
744
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
745
|
-
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
746
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
747
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
748
|
-
*/
|
|
749
|
-
if (symbol === undefined) {
|
|
750
|
-
throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
|
|
751
|
-
}
|
|
752
|
-
await this.loadMarkets();
|
|
753
|
-
const market = this.market(symbol);
|
|
754
|
-
const request = {
|
|
755
|
-
'symbol': market['id'],
|
|
756
|
-
'state': 0,
|
|
757
|
-
};
|
|
758
|
-
const response = await this.privatePostApiV1TradeOrderInfos(this.extend(request, params));
|
|
759
|
-
return this.parseOrders(response['data'], market, since, limit);
|
|
760
|
-
}
|
|
761
|
-
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
762
|
-
/**
|
|
763
|
-
* @method
|
|
764
|
-
* @name bitforex#fetchClosedOrders
|
|
765
|
-
* @description fetches information on multiple closed orders made by the user
|
|
766
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
767
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
768
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
769
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
770
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
771
|
-
*/
|
|
772
|
-
if (symbol === undefined) {
|
|
773
|
-
throw new ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
|
|
774
|
-
}
|
|
775
|
-
await this.loadMarkets();
|
|
776
|
-
const market = this.market(symbol);
|
|
777
|
-
const request = {
|
|
778
|
-
'symbol': market['id'],
|
|
779
|
-
'state': 1,
|
|
780
|
-
};
|
|
781
|
-
const response = await this.privatePostApiV1TradeOrderInfos(this.extend(request, params));
|
|
782
|
-
return this.parseOrders(response['data'], market, since, limit);
|
|
783
|
-
}
|
|
784
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
785
|
-
/**
|
|
786
|
-
* @method
|
|
787
|
-
* @name bitforex#createOrder
|
|
788
|
-
* @description create a trade order
|
|
789
|
-
* @see https://apidoc.bitforex.com/#new-order-trade
|
|
790
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
791
|
-
* @param {string} type 'market' or 'limit'
|
|
792
|
-
* @param {string} side 'buy' or 'sell'
|
|
793
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
794
|
-
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
795
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
796
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
797
|
-
*/
|
|
798
|
-
await this.loadMarkets();
|
|
799
|
-
let sideId = undefined;
|
|
800
|
-
if (side === 'buy') {
|
|
801
|
-
sideId = 1;
|
|
802
|
-
}
|
|
803
|
-
else if (side === 'sell') {
|
|
804
|
-
sideId = 2;
|
|
805
|
-
}
|
|
806
|
-
const market = this.market(symbol);
|
|
807
|
-
const request = {
|
|
808
|
-
'symbol': market['id'],
|
|
809
|
-
'price': price,
|
|
810
|
-
'amount': amount,
|
|
811
|
-
'tradeType': sideId,
|
|
812
|
-
};
|
|
813
|
-
const response = await this.privatePostApiV1TradePlaceOrder(this.extend(request, params));
|
|
814
|
-
const data = response['data'];
|
|
815
|
-
return this.safeOrder({
|
|
816
|
-
'info': response,
|
|
817
|
-
'id': this.safeString(data, 'orderId'),
|
|
818
|
-
}, market);
|
|
819
|
-
}
|
|
820
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
821
|
-
/**
|
|
822
|
-
* @method
|
|
823
|
-
* @name bitforex#cancelOrder
|
|
824
|
-
* @description cancels an open order
|
|
825
|
-
* @see https://apidoc.bitforex.com/#cancel-order-trade
|
|
826
|
-
* @param {string} id order id
|
|
827
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
828
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
829
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
830
|
-
*/
|
|
831
|
-
await this.loadMarkets();
|
|
832
|
-
const request = {
|
|
833
|
-
'orderId': id,
|
|
834
|
-
};
|
|
835
|
-
if (symbol !== undefined) {
|
|
836
|
-
request['symbol'] = this.marketId(symbol);
|
|
837
|
-
}
|
|
838
|
-
const results = await this.privatePostApiV1TradeCancelOrder(this.extend(request, params));
|
|
839
|
-
const success = results['success'];
|
|
840
|
-
const returnVal = { 'info': results, 'success': success };
|
|
841
|
-
return returnVal;
|
|
842
|
-
}
|
|
843
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
844
|
-
let url = this.urls['api']['rest'] + '/' + this.implodeParams(path, params);
|
|
845
|
-
const query = this.omit(params, this.extractParams(path));
|
|
846
|
-
if (api === 'public') {
|
|
847
|
-
if (Object.keys(query).length) {
|
|
848
|
-
url += '?' + this.urlencode(query);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
else {
|
|
852
|
-
this.checkRequiredCredentials();
|
|
853
|
-
let payload = this.urlencode({ 'accessKey': this.apiKey });
|
|
854
|
-
query['nonce'] = this.milliseconds();
|
|
855
|
-
if (Object.keys(query).length) {
|
|
856
|
-
payload += '&' + this.urlencode(this.keysort(query));
|
|
857
|
-
}
|
|
858
|
-
// let message = '/' + 'api/' + this.version + '/' + path + '?' + payload;
|
|
859
|
-
const message = '/' + path + '?' + payload;
|
|
860
|
-
const signature = this.hmac(this.encode(message), this.encode(this.secret), sha256);
|
|
861
|
-
body = payload + '&signData=' + signature;
|
|
862
|
-
headers = {
|
|
863
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
867
|
-
}
|
|
868
|
-
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
869
|
-
if (typeof body !== 'string') {
|
|
870
|
-
return undefined; // fallback to default error handler
|
|
871
|
-
}
|
|
872
|
-
if ((body[0] === '{') || (body[0] === '[')) {
|
|
873
|
-
const feedback = this.id + ' ' + body;
|
|
874
|
-
const success = this.safeValue(response, 'success');
|
|
875
|
-
if (success !== undefined) {
|
|
876
|
-
if (!success) {
|
|
877
|
-
const codeInner = this.safeString(response, 'code');
|
|
878
|
-
this.throwExactlyMatchedException(this.exceptions, codeInner, feedback);
|
|
879
|
-
throw new ExchangeError(feedback);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
return undefined;
|
|
884
|
-
}
|
|
885
|
-
}
|