ccxt 4.1.8 → 4.1.10
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/.git-templates/hooks/pre-push +55 -0
- package/README.md +3 -3
- package/dist/ccxt.browser.js +1458 -302
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +3 -1
- package/dist/cjs/src/base/Exchange.js +59 -3
- package/dist/cjs/src/bingx.js +103 -41
- package/dist/cjs/src/bitbns.js +107 -83
- package/dist/cjs/src/bitget.js +35 -17
- package/dist/cjs/src/btcalpha.js +9 -1
- package/dist/cjs/src/btcmarkets.js +5 -5
- package/dist/cjs/src/coinex.js +14 -2
- package/dist/cjs/src/deribit.js +6 -0
- package/dist/cjs/src/gate.js +9 -1
- package/dist/cjs/src/hitbtc.js +20 -2
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/phemex.js +20 -1
- package/dist/cjs/src/pro/bingx.js +891 -0
- package/dist/cjs/src/probit.js +3 -0
- package/dist/cjs/src/woo.js +21 -1
- package/js/ccxt.d.ts +6 -3
- package/js/ccxt.js +3 -1
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +6 -3
- package/js/src/base/Exchange.js +59 -3
- package/js/src/base/types.d.ts +7 -0
- package/js/src/binance.d.ts +17 -17
- package/js/src/bingx.d.ts +4 -3
- package/js/src/bingx.js +103 -41
- package/js/src/bitbns.d.ts +1 -1
- package/js/src/bitbns.js +107 -83
- package/js/src/bitfinex2.d.ts +13 -13
- package/js/src/bitget.d.ts +15 -15
- package/js/src/bitget.js +35 -17
- package/js/src/bitmex.d.ts +15 -15
- package/js/src/btcalpha.js +9 -1
- package/js/src/btcmarkets.js +5 -5
- package/js/src/bybit.d.ts +23 -23
- package/js/src/coinbase.d.ts +16 -16
- package/js/src/coinbasepro.d.ts +12 -12
- package/js/src/coinex.d.ts +2 -2
- package/js/src/coinex.js +14 -2
- package/js/src/cryptocom.d.ts +12 -12
- package/js/src/deribit.d.ts +2 -2
- package/js/src/deribit.js +6 -0
- package/js/src/digifinex.d.ts +2 -2
- package/js/src/gate.d.ts +10 -10
- package/js/src/gate.js +9 -1
- package/js/src/hitbtc.d.ts +2 -2
- package/js/src/hitbtc.js +20 -2
- package/js/src/huobi.d.ts +16 -16
- package/js/src/kraken.d.ts +2 -2
- package/js/src/krakenfutures.d.ts +6 -6
- package/js/src/kucoin.d.ts +13 -13
- package/js/src/kucoinfutures.d.ts +10 -10
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/mexc.d.ts +3 -3
- package/js/src/okx.d.ts +13 -13
- package/js/src/phemex.d.ts +2 -2
- package/js/src/phemex.js +20 -1
- package/js/src/poloniex.d.ts +5 -5
- package/js/src/pro/bingx.d.ts +24 -0
- package/js/src/pro/bingx.js +892 -0
- package/js/src/probit.js +3 -0
- package/js/src/woo.d.ts +2 -2
- package/js/src/woo.js +21 -1
- package/package.json +1 -1
- package/pyproject.toml +8 -0
- package/skip-tests.json +4 -1
package/dist/cjs/src/probit.js
CHANGED
|
@@ -1496,6 +1496,9 @@ class probit extends probit$1 {
|
|
|
1496
1496
|
if (limit !== undefined) {
|
|
1497
1497
|
request['limit'] = limit;
|
|
1498
1498
|
}
|
|
1499
|
+
else {
|
|
1500
|
+
request['limit'] = 100;
|
|
1501
|
+
}
|
|
1499
1502
|
const response = await this.privateGetTransferPayment(this.extend(request, params));
|
|
1500
1503
|
//
|
|
1501
1504
|
// {
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -1397,6 +1397,7 @@ class woo extends woo$1 {
|
|
|
1397
1397
|
/**
|
|
1398
1398
|
* @method
|
|
1399
1399
|
* @name woo#fetchOHLCV
|
|
1400
|
+
* @see https://docs.woo.org/#kline-public
|
|
1400
1401
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1401
1402
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1402
1403
|
* @param {string} timeframe the length of time each candle represents
|
|
@@ -2363,8 +2364,26 @@ class woo extends woo$1 {
|
|
|
2363
2364
|
return this.filterByArray(result, 'symbol', symbols);
|
|
2364
2365
|
}
|
|
2365
2366
|
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2367
|
+
/**
|
|
2368
|
+
* @method
|
|
2369
|
+
* @name woo#fetchFundingRateHistory
|
|
2370
|
+
* @description fetches historical funding rate prices
|
|
2371
|
+
* @see https://docs.woo.org/#get-funding-rate-history-for-one-market-public
|
|
2372
|
+
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
2373
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
2374
|
+
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
|
|
2375
|
+
* @param {object} [params] extra parameters specific to the woo api endpoint
|
|
2376
|
+
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
2377
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2378
|
+
* @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
|
|
2379
|
+
*/
|
|
2366
2380
|
await this.loadMarkets();
|
|
2367
|
-
|
|
2381
|
+
let paginate = false;
|
|
2382
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
|
|
2383
|
+
if (paginate) {
|
|
2384
|
+
return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25);
|
|
2385
|
+
}
|
|
2386
|
+
let request = {};
|
|
2368
2387
|
if (symbol !== undefined) {
|
|
2369
2388
|
const market = this.market(symbol);
|
|
2370
2389
|
symbol = market['symbol'];
|
|
@@ -2373,6 +2392,7 @@ class woo extends woo$1 {
|
|
|
2373
2392
|
if (since !== undefined) {
|
|
2374
2393
|
request['start_t'] = this.parseToInt(since / 1000);
|
|
2375
2394
|
}
|
|
2395
|
+
[request, params] = this.handleUntilOption('end_t', request, params, 0.001);
|
|
2376
2396
|
const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params));
|
|
2377
2397
|
//
|
|
2378
2398
|
// {
|
package/js/ccxt.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
|
|
|
2
2
|
import { Precise } from './src/base/Precise.js';
|
|
3
3
|
import * as functions from './src/base/functions.js';
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
|
-
import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } from './src/base/types.js';
|
|
5
|
+
import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.1.
|
|
7
|
+
declare const version = "4.1.9";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -117,6 +117,7 @@ import binancePro from './src/pro/binance.js';
|
|
|
117
117
|
import binancecoinmPro from './src/pro/binancecoinm.js';
|
|
118
118
|
import binanceusPro from './src/pro/binanceus.js';
|
|
119
119
|
import binanceusdmPro from './src/pro/binanceusdm.js';
|
|
120
|
+
import bingxPro from './src/pro/bingx.js';
|
|
120
121
|
import bitcoincomPro from './src/pro/bitcoincom.js';
|
|
121
122
|
import bitfinexPro from './src/pro/bitfinex.js';
|
|
122
123
|
import bitfinex2Pro from './src/pro/bitfinex2.js';
|
|
@@ -284,6 +285,7 @@ declare const pro: {
|
|
|
284
285
|
binancecoinm: typeof binancecoinmPro;
|
|
285
286
|
binanceus: typeof binanceusPro;
|
|
286
287
|
binanceusdm: typeof binanceusdmPro;
|
|
288
|
+
bingx: typeof bingxPro;
|
|
287
289
|
bitcoincom: typeof bitcoincomPro;
|
|
288
290
|
bitfinex: typeof bitfinexPro;
|
|
289
291
|
bitfinex2: typeof bitfinex2Pro;
|
|
@@ -350,6 +352,7 @@ declare const ccxt: {
|
|
|
350
352
|
binancecoinm: typeof binancecoinmPro;
|
|
351
353
|
binanceus: typeof binanceusPro;
|
|
352
354
|
binanceusdm: typeof binanceusdmPro;
|
|
355
|
+
bingx: typeof bingxPro;
|
|
353
356
|
bitcoincom: typeof bitcoincomPro;
|
|
354
357
|
bitfinex: typeof bitfinexPro;
|
|
355
358
|
bitfinex2: typeof bitfinex2Pro;
|
|
@@ -510,5 +513,5 @@ declare const ccxt: {
|
|
|
510
513
|
zaif: typeof zaif;
|
|
511
514
|
zonda: typeof zonda;
|
|
512
515
|
} & typeof functions & typeof errors;
|
|
513
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
516
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
|
|
514
517
|
export default ccxt;
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.1.
|
|
41
|
+
const version = '4.1.10';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -154,6 +154,7 @@ import binancePro from './src/pro/binance.js';
|
|
|
154
154
|
import binancecoinmPro from './src/pro/binancecoinm.js';
|
|
155
155
|
import binanceusPro from './src/pro/binanceus.js';
|
|
156
156
|
import binanceusdmPro from './src/pro/binanceusdm.js';
|
|
157
|
+
import bingxPro from './src/pro/bingx.js';
|
|
157
158
|
import bitcoincomPro from './src/pro/bitcoincom.js';
|
|
158
159
|
import bitfinexPro from './src/pro/bitfinex.js';
|
|
159
160
|
import bitfinex2Pro from './src/pro/bitfinex2.js';
|
|
@@ -321,6 +322,7 @@ const pro = {
|
|
|
321
322
|
'binancecoinm': binancecoinmPro,
|
|
322
323
|
'binanceus': binanceusPro,
|
|
323
324
|
'binanceusdm': binanceusdmPro,
|
|
325
|
+
'bingx': bingxPro,
|
|
324
326
|
'bitcoincom': bitcoincomPro,
|
|
325
327
|
'bitfinex': bitfinexPro,
|
|
326
328
|
'bitfinex2': bitfinex2Pro,
|
|
@@ -76,6 +76,7 @@ interface Exchange {
|
|
|
76
76
|
subAccountV1PrivatePostUpdateStatus(params?: {}): Promise<implicitReturnType>;
|
|
77
77
|
accountV1PrivateGetUid(params?: {}): Promise<implicitReturnType>;
|
|
78
78
|
accountV1PrivatePostInnerTransferAuthorizeSubAccount(params?: {}): Promise<implicitReturnType>;
|
|
79
|
+
userAuthPrivatePostUserDataStream(params?: {}): Promise<implicitReturnType>;
|
|
79
80
|
copyTradingV1PrivateGetSwapTraceCurrentTrack(params?: {}): Promise<implicitReturnType>;
|
|
80
81
|
copyTradingV1PrivatePostSwapTraceCloseTrackOrder(params?: {}): Promise<implicitReturnType>;
|
|
81
82
|
copyTradingV1PrivatePostSwapTraceSetTPSL(params?: {}): Promise<implicitReturnType>;
|
|
@@ -4,7 +4,7 @@ ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotA
|
|
|
4
4
|
import WsClient from './ws/WsClient.js';
|
|
5
5
|
import { Future } from './ws/Future.js';
|
|
6
6
|
import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
|
|
7
|
-
import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position } from './types.js';
|
|
7
|
+
import { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRateHistory } from './types.js';
|
|
8
8
|
export { Market, Trade, Fee, Position, Ticker } from './types.js';
|
|
9
9
|
/**
|
|
10
10
|
* @class Exchange
|
|
@@ -557,7 +557,7 @@ export default class Exchange {
|
|
|
557
557
|
parseMarketLeverageTiers(info: any, market?: any): void;
|
|
558
558
|
fetchLeverageTiers(symbols?: string[], params?: {}): Promise<any>;
|
|
559
559
|
parsePosition(position: any, market?: any): void;
|
|
560
|
-
parseFundingRateHistory(info: any, market?: any):
|
|
560
|
+
parseFundingRateHistory(info: any, market?: any): FundingRateHistory;
|
|
561
561
|
parseBorrowInterest(info: any, market?: any): void;
|
|
562
562
|
parseWsTrade(trade: any, market?: any): Trade;
|
|
563
563
|
parseWsOrder(order: any, market?: any): Order;
|
|
@@ -731,6 +731,7 @@ export default class Exchange {
|
|
|
731
731
|
fetchDeposits(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
732
732
|
fetchWithdrawals(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
733
733
|
fetchOpenInterest(symbol: string, params?: {}): Promise<any>;
|
|
734
|
+
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
734
735
|
parseLastPrice(price: any, market?: any): any;
|
|
735
736
|
fetchDepositAddress(code: string, params?: {}): Promise<any>;
|
|
736
737
|
account(): Balance;
|
|
@@ -771,7 +772,7 @@ export default class Exchange {
|
|
|
771
772
|
parseTickers(tickers: any, symbols?: string[], params?: {}): Dictionary<Ticker>;
|
|
772
773
|
parseDepositAddresses(addresses: any, codes?: string[], indexed?: boolean, params?: {}): {};
|
|
773
774
|
parseBorrowInterests(response: any, market?: any): any[];
|
|
774
|
-
parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int):
|
|
775
|
+
parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): FundingRateHistory[];
|
|
775
776
|
safeSymbol(marketId: any, market?: any, delimiter?: any, marketType?: any): any;
|
|
776
777
|
parseFundingRate(contract: string, market?: any): void;
|
|
777
778
|
parseFundingRates(response: any, market?: any): {};
|
|
@@ -810,6 +811,8 @@ export default class Exchange {
|
|
|
810
811
|
safeDeterministicCall(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}): Promise<any>;
|
|
811
812
|
fetchPaginatedCallDeterministic(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}, maxEntriesPerRequest?: any): Promise<any>;
|
|
812
813
|
fetchPaginatedCallCursor(method: string, symbol?: string, since?: any, limit?: any, params?: {}, cursorReceived?: any, cursorSent?: any, cursorIncrement?: any, maxEntriesPerRequest?: any): Promise<any>;
|
|
814
|
+
fetchPaginatedCallIncremental(method: string, symbol?: string, since?: any, limit?: any, params?: {}, pageKey?: any, maxEntriesPerRequest?: any): Promise<any>;
|
|
815
|
+
sortCursorPaginatedResult(result: any): any;
|
|
813
816
|
removeRepeatedElementsFromArray(input: any): any;
|
|
814
817
|
handleUntilOption(key: any, request: any, params: any, multiplier?: number): any[];
|
|
815
818
|
}
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -2095,7 +2095,7 @@ export default class Exchange {
|
|
|
2095
2095
|
// string = true
|
|
2096
2096
|
//
|
|
2097
2097
|
// [
|
|
2098
|
-
// { 'currency': 'BTC', 'cost': '0.
|
|
2098
|
+
// { 'currency': 'BTC', 'cost': '0.4' },
|
|
2099
2099
|
// { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
|
|
2100
2100
|
// { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
|
|
2101
2101
|
// { 'currency': 'USDT', 'cost': '12.3456' },
|
|
@@ -3285,6 +3285,9 @@ export default class Exchange {
|
|
|
3285
3285
|
async fetchOpenInterest(symbol, params = {}) {
|
|
3286
3286
|
throw new NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
|
|
3287
3287
|
}
|
|
3288
|
+
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3289
|
+
throw new NotSupported(this.id + ' fetchFundingRateHistory() is not supported yet');
|
|
3290
|
+
}
|
|
3288
3291
|
parseLastPrice(price, market = undefined) {
|
|
3289
3292
|
throw new NotSupported(this.id + ' parseLastPrice() is not supported yet');
|
|
3290
3293
|
}
|
|
@@ -4175,7 +4178,9 @@ export default class Exchange {
|
|
|
4175
4178
|
}
|
|
4176
4179
|
}
|
|
4177
4180
|
}
|
|
4178
|
-
|
|
4181
|
+
const uniqueResults = this.removeRepeatedElementsFromArray(result);
|
|
4182
|
+
const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
|
|
4183
|
+
return this.filterBySinceLimit(uniqueResults, since, limit, key);
|
|
4179
4184
|
}
|
|
4180
4185
|
async safeDeterministicCall(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}) {
|
|
4181
4186
|
let maxRetries = undefined;
|
|
@@ -4230,7 +4235,9 @@ export default class Exchange {
|
|
|
4230
4235
|
for (let i = 0; i < results.length; i++) {
|
|
4231
4236
|
result = this.arrayConcat(result, results[i]);
|
|
4232
4237
|
}
|
|
4233
|
-
|
|
4238
|
+
const uniqueResults = this.removeRepeatedElementsFromArray(result);
|
|
4239
|
+
const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
|
|
4240
|
+
return this.filterBySinceLimit(uniqueResults, since, limit, key);
|
|
4234
4241
|
}
|
|
4235
4242
|
async fetchPaginatedCallCursor(method, symbol = undefined, since = undefined, limit = undefined, params = {}, cursorReceived = undefined, cursorSent = undefined, cursorIncrement = undefined, maxEntriesPerRequest = undefined) {
|
|
4236
4243
|
let maxCalls = undefined;
|
|
@@ -4274,6 +4281,55 @@ export default class Exchange {
|
|
|
4274
4281
|
}
|
|
4275
4282
|
i += 1;
|
|
4276
4283
|
}
|
|
4284
|
+
const sorted = this.sortCursorPaginatedResult(result);
|
|
4285
|
+
const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
|
|
4286
|
+
return this.filterBySinceLimit(sorted, since, limit, key);
|
|
4287
|
+
}
|
|
4288
|
+
async fetchPaginatedCallIncremental(method, symbol = undefined, since = undefined, limit = undefined, params = {}, pageKey = undefined, maxEntriesPerRequest = undefined) {
|
|
4289
|
+
let maxCalls = undefined;
|
|
4290
|
+
[maxCalls, params] = this.handleOptionAndParams(params, method, 'paginationCalls', 10);
|
|
4291
|
+
let maxRetries = undefined;
|
|
4292
|
+
[maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
|
|
4293
|
+
[maxEntriesPerRequest, params] = this.handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest, params);
|
|
4294
|
+
let i = 0;
|
|
4295
|
+
let errors = 0;
|
|
4296
|
+
let result = [];
|
|
4297
|
+
while (i < maxCalls) {
|
|
4298
|
+
try {
|
|
4299
|
+
params[pageKey] = i + 1;
|
|
4300
|
+
const response = await this[method](symbol, since, maxEntriesPerRequest, params);
|
|
4301
|
+
errors = 0;
|
|
4302
|
+
const responseLength = response.length;
|
|
4303
|
+
if (this.verbose) {
|
|
4304
|
+
this.log('Incremental pagination call', i + 1, 'method', method, 'response length', responseLength);
|
|
4305
|
+
}
|
|
4306
|
+
if (responseLength === 0) {
|
|
4307
|
+
break;
|
|
4308
|
+
}
|
|
4309
|
+
result = this.arrayConcat(result, response);
|
|
4310
|
+
}
|
|
4311
|
+
catch (e) {
|
|
4312
|
+
errors += 1;
|
|
4313
|
+
if (errors > maxRetries) {
|
|
4314
|
+
throw e;
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
i += 1;
|
|
4318
|
+
}
|
|
4319
|
+
const sorted = this.sortCursorPaginatedResult(result);
|
|
4320
|
+
const key = (method === 'fetchOHLCV') ? 0 : 'timestamp';
|
|
4321
|
+
return this.filterBySinceLimit(sorted, since, limit, key);
|
|
4322
|
+
}
|
|
4323
|
+
sortCursorPaginatedResult(result) {
|
|
4324
|
+
const first = this.safeValue(result, 0);
|
|
4325
|
+
if (first !== undefined) {
|
|
4326
|
+
if ('timestamp' in first) {
|
|
4327
|
+
return this.sortBy(result, 'timestamp');
|
|
4328
|
+
}
|
|
4329
|
+
if ('id' in first) {
|
|
4330
|
+
return this.sortBy(result, 'id');
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4277
4333
|
return result;
|
|
4278
4334
|
}
|
|
4279
4335
|
removeRepeatedElementsFromArray(input) {
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -201,6 +201,13 @@ export interface Position {
|
|
|
201
201
|
takeProfitPrice?: number;
|
|
202
202
|
info: any;
|
|
203
203
|
}
|
|
204
|
+
export interface FundingRateHistory {
|
|
205
|
+
info: any;
|
|
206
|
+
symbol: string;
|
|
207
|
+
fundingRate: number;
|
|
208
|
+
timestamp?: number;
|
|
209
|
+
datetime?: string;
|
|
210
|
+
}
|
|
204
211
|
/** [ timestamp, open, high, low, close, volume ] */
|
|
205
212
|
export declare type OHLCV = [number, number, number, number, number, number];
|
|
206
213
|
/** [ timestamp, open, high, low, close, volume, count ] */
|
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import { Market, Int, OrderSide, Balances, OrderType } from './base/types.js';
|
|
2
|
+
import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @extends Exchange
|
|
@@ -97,8 +97,8 @@ export default class binance extends Exchange {
|
|
|
97
97
|
};
|
|
98
98
|
fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
|
|
99
99
|
parseOHLCV(ohlcv: any, market?: any): number[];
|
|
100
|
-
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
101
|
-
parseTrade(trade: any, market?: any):
|
|
100
|
+
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
101
|
+
parseTrade(trade: any, market?: any): Trade | {
|
|
102
102
|
id: any;
|
|
103
103
|
timestamp: number;
|
|
104
104
|
datetime: string;
|
|
@@ -116,25 +116,25 @@ export default class binance extends Exchange {
|
|
|
116
116
|
};
|
|
117
117
|
info: any;
|
|
118
118
|
};
|
|
119
|
-
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
120
|
-
editSpotOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<
|
|
119
|
+
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
120
|
+
editSpotOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
121
121
|
editSpotOrderRequest(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): any;
|
|
122
|
-
editContractOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<
|
|
123
|
-
editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<
|
|
122
|
+
editContractOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
123
|
+
editOrder(id: string, symbol: any, type: any, side: any, amount?: any, price?: any, params?: {}): Promise<Order>;
|
|
124
124
|
parseOrderStatus(status: any): string;
|
|
125
|
-
parseOrder(order: any, market?: any):
|
|
126
|
-
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<
|
|
125
|
+
parseOrder(order: any, market?: any): Order;
|
|
126
|
+
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
|
|
127
127
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
|
|
128
|
-
fetchOrder(id: string, symbol?: string, params?: {}): Promise<
|
|
129
|
-
fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
130
|
-
fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
128
|
+
fetchOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
|
|
129
|
+
fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
130
|
+
fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
131
131
|
fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
|
|
132
132
|
fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
133
|
-
cancelOrder(id: string, symbol?: string, params?: {}): Promise<
|
|
133
|
+
cancelOrder(id: string, symbol?: string, params?: {}): Promise<Order>;
|
|
134
134
|
cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
|
|
135
|
-
cancelOrders(ids: Int[], symbol?: string, params?: {}): Promise<
|
|
136
|
-
fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
137
|
-
fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
135
|
+
cancelOrders(ids: Int[], symbol?: string, params?: {}): Promise<Order[]>;
|
|
136
|
+
fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
137
|
+
fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
138
138
|
fetchMyDustTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
139
139
|
parseDustTrade(trade: any, market?: any): {
|
|
140
140
|
id: any;
|
|
@@ -289,7 +289,7 @@ export default class binance extends Exchange {
|
|
|
289
289
|
previousFundingTimestamp: any;
|
|
290
290
|
previousFundingDatetime: any;
|
|
291
291
|
}>;
|
|
292
|
-
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
292
|
+
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
293
293
|
fetchFundingRates(symbols?: string[], params?: {}): Promise<any>;
|
|
294
294
|
parseFundingRate(contract: any, market?: any): {
|
|
295
295
|
info: any;
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/bingx.js';
|
|
2
|
-
import { Int, OrderSide } from './base/types.js';
|
|
2
|
+
import { Int, OrderSide, OHLCV, FundingRateHistory } from './base/types.js';
|
|
3
3
|
export default class bingx extends Exchange {
|
|
4
4
|
describe(): any;
|
|
5
5
|
fetchTime(params?: {}): Promise<number>;
|
|
@@ -59,7 +59,7 @@ export default class bingx extends Exchange {
|
|
|
59
59
|
info: any;
|
|
60
60
|
};
|
|
61
61
|
fetchMarkets(params?: {}): Promise<any>;
|
|
62
|
-
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
62
|
+
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
63
63
|
parseOHLCV(ohlcv: any, market?: any): number[];
|
|
64
64
|
fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
|
|
65
65
|
parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
|
|
@@ -102,7 +102,7 @@ export default class bingx extends Exchange {
|
|
|
102
102
|
previousFundingTimestamp: any;
|
|
103
103
|
previousFundingDatetime: any;
|
|
104
104
|
};
|
|
105
|
-
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
105
|
+
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
106
106
|
fetchOpenInterest(symbol: string, params?: {}): Promise<{
|
|
107
107
|
symbol: any;
|
|
108
108
|
openInterestAmount: any;
|
|
@@ -127,6 +127,7 @@ export default class bingx extends Exchange {
|
|
|
127
127
|
fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
128
128
|
parsePosition(position: any, market?: any): import("./base/types.js").Position;
|
|
129
129
|
createOrder(symbol: string, type: any, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
|
|
130
|
+
parseOrderSide(side: any): string;
|
|
130
131
|
parseOrder(order: any, market?: any): import("./base/types.js").Order;
|
|
131
132
|
parseOrderStatus(status: any): string;
|
|
132
133
|
cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
|
package/js/src/bingx.js
CHANGED
|
@@ -69,6 +69,7 @@ export default class bingx extends Exchange {
|
|
|
69
69
|
'swap': 'https://open-api.{hostname}/openApi',
|
|
70
70
|
'contract': 'https://open-api.{hostname}/openApi',
|
|
71
71
|
'wallets': 'https://open-api.{hostname}/openApi',
|
|
72
|
+
'user': 'https://open-api.{hostname}/openApi',
|
|
72
73
|
'subAccount': 'https://open-api.{hostname}/openApi',
|
|
73
74
|
'account': 'https://open-api.{hostname}/openApi',
|
|
74
75
|
},
|
|
@@ -237,6 +238,15 @@ export default class bingx extends Exchange {
|
|
|
237
238
|
},
|
|
238
239
|
},
|
|
239
240
|
},
|
|
241
|
+
'user': {
|
|
242
|
+
'auth': {
|
|
243
|
+
'private': {
|
|
244
|
+
'post': {
|
|
245
|
+
'userDataStream': 1,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
240
250
|
'copyTrading': {
|
|
241
251
|
'v1': {
|
|
242
252
|
'private': {
|
|
@@ -314,6 +324,7 @@ export default class bingx extends Exchange {
|
|
|
314
324
|
},
|
|
315
325
|
'commonCurrencies': {},
|
|
316
326
|
'options': {
|
|
327
|
+
'defaultType': 'spot',
|
|
317
328
|
'accountsByType': {
|
|
318
329
|
'spot': 'FUND',
|
|
319
330
|
'swap': 'PFUTURES',
|
|
@@ -833,37 +844,63 @@ export default class bingx extends Exchange {
|
|
|
833
844
|
// filledTime: '2023-07-04T20:56:01.000+0800'
|
|
834
845
|
// }
|
|
835
846
|
//
|
|
836
|
-
|
|
847
|
+
//
|
|
848
|
+
// ws
|
|
849
|
+
//
|
|
850
|
+
// spot
|
|
851
|
+
//
|
|
852
|
+
// {
|
|
853
|
+
// E: 1690214529432,
|
|
854
|
+
// T: 1690214529386,
|
|
855
|
+
// e: 'trade',
|
|
856
|
+
// m: true,
|
|
857
|
+
// p: '29110.19',
|
|
858
|
+
// q: '0.1868',
|
|
859
|
+
// s: 'BTC-USDT',
|
|
860
|
+
// t: '57903921'
|
|
861
|
+
// }
|
|
862
|
+
//
|
|
863
|
+
// swap
|
|
864
|
+
//
|
|
865
|
+
// {
|
|
866
|
+
// q: '0.0421',
|
|
867
|
+
// p: '29023.5',
|
|
868
|
+
// T: 1690221401344,
|
|
869
|
+
// m: false,
|
|
870
|
+
// s: 'BTC-USDT'
|
|
871
|
+
// }
|
|
872
|
+
//
|
|
873
|
+
let time = this.safeIntegerN(trade, ['time', 'filledTm', 'T']);
|
|
837
874
|
const datetimeId = this.safeString(trade, 'filledTm');
|
|
838
875
|
if (datetimeId !== undefined) {
|
|
839
876
|
time = this.parse8601(datetimeId);
|
|
840
877
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
let side = undefined;
|
|
844
|
-
if (isBuyerMaker !== undefined) {
|
|
845
|
-
side = isBuyerMaker ? 'sell' : 'buy';
|
|
846
|
-
takeOrMaker = 'taker';
|
|
878
|
+
if (time === 0) {
|
|
879
|
+
time = undefined;
|
|
847
880
|
}
|
|
881
|
+
const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
|
|
882
|
+
const side = this.safeStringLower2(trade, 'side', 'S');
|
|
848
883
|
const cost = this.safeString(trade, 'quoteQty');
|
|
849
884
|
const type = (cost === undefined) ? 'spot' : 'swap';
|
|
850
|
-
const currencyId = this.
|
|
885
|
+
const currencyId = this.safeString2(trade, 'currency', 'N');
|
|
851
886
|
const currencyCode = this.safeCurrencyCode(currencyId);
|
|
887
|
+
const m = this.safeValue(trade, 'm', false);
|
|
888
|
+
const marketId = this.safeString(trade, 's');
|
|
852
889
|
return this.safeTrade({
|
|
853
|
-
'id': this.
|
|
890
|
+
'id': this.safeStringN(trade, ['id', 't']),
|
|
854
891
|
'info': trade,
|
|
855
892
|
'timestamp': time,
|
|
856
893
|
'datetime': this.iso8601(time),
|
|
857
|
-
'symbol': this.safeSymbol(
|
|
858
|
-
'order':
|
|
859
|
-
'type':
|
|
860
|
-
'side': side,
|
|
861
|
-
'takerOrMaker':
|
|
862
|
-
'price': this.
|
|
863
|
-
'amount': this.
|
|
894
|
+
'symbol': this.safeSymbol(marketId, market, '-', type),
|
|
895
|
+
'order': this.safeString2(trade, 'orderId', 'i'),
|
|
896
|
+
'type': this.safeStringLower(trade, 'o'),
|
|
897
|
+
'side': this.parseOrderSide(side),
|
|
898
|
+
'takerOrMaker': (isBuyerMaker || m) ? 'maker' : 'taker',
|
|
899
|
+
'price': this.safeString2(trade, 'price', 'p'),
|
|
900
|
+
'amount': this.safeStringN(trade, ['qty', 'amount', 'q']),
|
|
864
901
|
'cost': cost,
|
|
865
902
|
'fee': {
|
|
866
|
-
'cost': this.parseNumber(Precise.stringAbs(this.
|
|
903
|
+
'cost': this.parseNumber(Precise.stringAbs(this.safeString2(trade, 'commission', 'n'))),
|
|
867
904
|
'currency': currencyCode,
|
|
868
905
|
'rate': undefined,
|
|
869
906
|
},
|
|
@@ -1517,8 +1554,9 @@ export default class bingx extends Exchange {
|
|
|
1517
1554
|
'liquidationPrice': undefined,
|
|
1518
1555
|
'entryPrice': this.safeNumber2(position, 'avgPrice', 'entryPrice'),
|
|
1519
1556
|
'unrealizedPnl': this.safeNumber(position, 'unrealizedProfit'),
|
|
1557
|
+
'realizedPnl': this.safeNumber(position, 'realisedProfit'),
|
|
1520
1558
|
'percentage': undefined,
|
|
1521
|
-
'contracts':
|
|
1559
|
+
'contracts': this.safeNumber(position, 'positionAmt'),
|
|
1522
1560
|
'contractSize': undefined,
|
|
1523
1561
|
'markPrice': undefined,
|
|
1524
1562
|
'lastPrice': undefined,
|
|
@@ -1529,7 +1567,7 @@ export default class bingx extends Exchange {
|
|
|
1529
1567
|
'lastUpdateTimestamp': undefined,
|
|
1530
1568
|
'maintenanceMargin': undefined,
|
|
1531
1569
|
'maintenanceMarginPercentage': undefined,
|
|
1532
|
-
'collateral': this.
|
|
1570
|
+
'collateral': this.safeNumber(position, 'positionAmt'),
|
|
1533
1571
|
'initialMargin': this.safeNumber(position, 'initialMargin'),
|
|
1534
1572
|
'initialMarginPercentage': undefined,
|
|
1535
1573
|
'leverage': this.safeNumber(position, 'leverage'),
|
|
@@ -1583,15 +1621,20 @@ export default class bingx extends Exchange {
|
|
|
1583
1621
|
request['timeInForce'] = 'POC';
|
|
1584
1622
|
}
|
|
1585
1623
|
const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
|
|
1586
|
-
if (
|
|
1587
|
-
if (
|
|
1588
|
-
|
|
1624
|
+
if (isMarketOrder && (side === 'buy')) {
|
|
1625
|
+
if (createMarketBuyOrderRequiresPrice) {
|
|
1626
|
+
if (price === undefined) {
|
|
1627
|
+
throw new InvalidOrder(this.id + ' createOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
|
|
1628
|
+
}
|
|
1629
|
+
else {
|
|
1630
|
+
const amountString = this.numberToString(amount);
|
|
1631
|
+
const priceString = this.numberToString(price);
|
|
1632
|
+
const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
|
|
1633
|
+
request['quoteOrderQty'] = this.priceToPrecision(symbol, cost);
|
|
1634
|
+
}
|
|
1589
1635
|
}
|
|
1590
1636
|
else {
|
|
1591
|
-
|
|
1592
|
-
const priceString = this.numberToString(price);
|
|
1593
|
-
const cost = this.parseNumber(Precise.stringMul(amountString, priceString));
|
|
1594
|
-
request['quoteOrderQty'] = this.priceToPrecision(symbol, cost);
|
|
1637
|
+
request['quoteOrderQty'] = this.priceToPrecision(symbol, amount);
|
|
1595
1638
|
}
|
|
1596
1639
|
}
|
|
1597
1640
|
else {
|
|
@@ -1707,6 +1750,15 @@ export default class bingx extends Exchange {
|
|
|
1707
1750
|
const order = this.safeValue(data, 'order', data);
|
|
1708
1751
|
return this.parseOrder(order, market);
|
|
1709
1752
|
}
|
|
1753
|
+
parseOrderSide(side) {
|
|
1754
|
+
const sides = {
|
|
1755
|
+
'BUY': 'buy',
|
|
1756
|
+
'SELL': 'sell',
|
|
1757
|
+
'SHORT': 'sell',
|
|
1758
|
+
'LONG': 'buy',
|
|
1759
|
+
};
|
|
1760
|
+
return this.safeString(sides, side, side);
|
|
1761
|
+
}
|
|
1710
1762
|
parseOrder(order, market = undefined) {
|
|
1711
1763
|
//
|
|
1712
1764
|
// spot
|
|
@@ -1804,39 +1856,49 @@ export default class bingx extends Exchange {
|
|
|
1804
1856
|
// "workingType": "MARK_PRICE"
|
|
1805
1857
|
// }
|
|
1806
1858
|
//
|
|
1807
|
-
const positionSide = this.
|
|
1859
|
+
const positionSide = this.safeString2(order, 'positionSide', 'ps');
|
|
1808
1860
|
const marketType = (positionSide === undefined) ? 'spot' : 'swap';
|
|
1809
|
-
const marketId = this.
|
|
1861
|
+
const marketId = this.safeString2(order, 'symbol', 's');
|
|
1810
1862
|
const symbol = this.safeSymbol(marketId, market, '-', marketType);
|
|
1811
|
-
const
|
|
1863
|
+
const orderId = this.safeString2(order, 'orderId', 'i');
|
|
1864
|
+
const side = this.safeStringLower2(order, 'side', 'S');
|
|
1865
|
+
const type = this.safeStringLower2(order, 'type', 'o');
|
|
1866
|
+
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
|
|
1867
|
+
const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
|
|
1868
|
+
const price = this.safeString2(order, 'price', 'p');
|
|
1869
|
+
const average = this.safeString2(order, 'avgPrice', 'ap');
|
|
1870
|
+
const amount = this.safeString2(order, 'origQty', 'q');
|
|
1871
|
+
const filled = this.safeString2(order, 'executedQty', 'z');
|
|
1872
|
+
const statusId = this.safeString2(order, 'status', 'X');
|
|
1812
1873
|
const fee = {
|
|
1813
|
-
'currency': this.
|
|
1814
|
-
'rate': this.
|
|
1874
|
+
'currency': this.safeString2(order, 'feeAsset', 'N'),
|
|
1875
|
+
'rate': this.safeStringN(order, ['fee', 'commission', 'n']),
|
|
1815
1876
|
};
|
|
1877
|
+
const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
|
|
1816
1878
|
return this.safeOrder({
|
|
1817
1879
|
'info': order,
|
|
1818
|
-
'id':
|
|
1819
|
-
'clientOrderId':
|
|
1880
|
+
'id': orderId,
|
|
1881
|
+
'clientOrderId': clientOrderId,
|
|
1820
1882
|
'timestamp': timestamp,
|
|
1821
1883
|
'datetime': this.iso8601(timestamp),
|
|
1822
|
-
'lastTradeTimestamp':
|
|
1884
|
+
'lastTradeTimestamp': lastTradeTimestamp,
|
|
1823
1885
|
'lastUpdateTimestamp': this.safeInteger(order, 'updateTime'),
|
|
1824
1886
|
'symbol': symbol,
|
|
1825
|
-
'type':
|
|
1887
|
+
'type': type,
|
|
1826
1888
|
'timeInForce': undefined,
|
|
1827
1889
|
'postOnly': undefined,
|
|
1828
|
-
'side': this.
|
|
1829
|
-
'price':
|
|
1890
|
+
'side': this.parseOrderSide(side),
|
|
1891
|
+
'price': price,
|
|
1830
1892
|
'stopPrice': this.safeNumber(order, 'stopPrice'),
|
|
1831
1893
|
'triggerPrice': this.safeNumber(order, 'stopPrice'),
|
|
1832
1894
|
'stopLossPrice': this.safeNumber(order, 'stopLoss'),
|
|
1833
1895
|
'takeProfitPrice': this.safeNumber(order, 'takeProfit'),
|
|
1834
|
-
'average':
|
|
1896
|
+
'average': average,
|
|
1835
1897
|
'cost': undefined,
|
|
1836
|
-
'amount':
|
|
1837
|
-
'filled':
|
|
1898
|
+
'amount': amount,
|
|
1899
|
+
'filled': filled,
|
|
1838
1900
|
'remaining': undefined,
|
|
1839
|
-
'status': this.parseOrderStatus(
|
|
1901
|
+
'status': this.parseOrderStatus(statusId),
|
|
1840
1902
|
'fee': fee,
|
|
1841
1903
|
'trades': undefined,
|
|
1842
1904
|
}, market);
|