ccxt 4.4.7 → 4.4.8
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 +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +51 -12
- package/dist/cjs/src/bybit.js +363 -0
- package/dist/cjs/src/htx.js +22 -0
- package/dist/cjs/src/okx.js +4 -0
- package/dist/cjs/src/pro/bitmart.js +81 -0
- package/dist/cjs/src/pro/bitvavo.js +92 -1
- package/dist/cjs/src/pro/blofin.js +64 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bybit.d.ts +5 -0
- package/js/src/abstract/okx.d.ts +2 -0
- package/js/src/binance.d.ts +15 -15
- package/js/src/binance.js +51 -12
- package/js/src/bybit.d.ts +7 -1
- package/js/src/bybit.js +363 -0
- package/js/src/htx.js +22 -0
- package/js/src/okx.js +4 -0
- package/js/src/pro/bitmart.d.ts +3 -0
- package/js/src/pro/bitmart.js +81 -0
- package/js/src/pro/bitvavo.d.ts +7 -2
- package/js/src/pro/bitvavo.js +92 -1
- package/js/src/pro/blofin.d.ts +3 -0
- package/js/src/pro/blofin.js +64 -0
- package/package.json +1 -1
package/js/src/bybit.js
CHANGED
|
@@ -43,6 +43,7 @@ export default class bybit extends Exchange {
|
|
|
43
43
|
'cancelOrdersForSymbols': true,
|
|
44
44
|
'closeAllPositions': false,
|
|
45
45
|
'closePosition': false,
|
|
46
|
+
'createConvertTrade': true,
|
|
46
47
|
'createMarketBuyOrderWithCost': true,
|
|
47
48
|
'createMarketSellOrderWithCost': true,
|
|
48
49
|
'createOrder': true,
|
|
@@ -66,6 +67,10 @@ export default class bybit extends Exchange {
|
|
|
66
67
|
'fetchCanceledOrders': true,
|
|
67
68
|
'fetchClosedOrder': true,
|
|
68
69
|
'fetchClosedOrders': true,
|
|
70
|
+
'fetchConvertCurrencies': true,
|
|
71
|
+
'fetchConvertQuote': true,
|
|
72
|
+
'fetchConvertTrade': true,
|
|
73
|
+
'fetchConvertTradeHistory': true,
|
|
69
74
|
'fetchCrossBorrowRate': true,
|
|
70
75
|
'fetchCrossBorrowRates': false,
|
|
71
76
|
'fetchCurrencies': true,
|
|
@@ -332,6 +337,9 @@ export default class bybit extends Exchange {
|
|
|
332
337
|
'v5/account/smp-group': 1,
|
|
333
338
|
'v5/account/mmp-state': 5,
|
|
334
339
|
// asset
|
|
340
|
+
'v5/asset/exchange/query-coin-list': 0.5,
|
|
341
|
+
'v5/asset/exchange/convert-result-query': 0.5,
|
|
342
|
+
'v5/asset/exchange/query-convert-history': 0.5,
|
|
335
343
|
'v5/asset/exchange/order-record': 5,
|
|
336
344
|
'v5/asset/delivery-record': 5,
|
|
337
345
|
'v5/asset/settlement-record': 5,
|
|
@@ -490,6 +498,8 @@ export default class bybit extends Exchange {
|
|
|
490
498
|
'v5/account/mmp-modify': 5,
|
|
491
499
|
'v5/account/mmp-reset': 5,
|
|
492
500
|
// asset
|
|
501
|
+
'v5/asset/exchange/quote-apply': 1,
|
|
502
|
+
'v5/asset/exchange/convert-execute': 1,
|
|
493
503
|
'v5/asset/transfer/inter-transfer': 50,
|
|
494
504
|
'v5/asset/transfer/save-transfer-sub-member': 150,
|
|
495
505
|
'v5/asset/transfer/universal-transfer': 10,
|
|
@@ -8875,6 +8885,359 @@ export default class bybit extends Exchange {
|
|
|
8875
8885
|
const positions = this.parsePositions(rawPositions, symbols, params);
|
|
8876
8886
|
return this.filterBySinceLimit(positions, since, limit);
|
|
8877
8887
|
}
|
|
8888
|
+
async fetchConvertCurrencies(params = {}) {
|
|
8889
|
+
/**
|
|
8890
|
+
* @method
|
|
8891
|
+
* @name bybit#fetchConvertCurrencies
|
|
8892
|
+
* @description fetches all available currencies that can be converted
|
|
8893
|
+
* @see https://bybit-exchange.github.io/docs/v5/asset/convert/convert-coin-list
|
|
8894
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8895
|
+
* @param {string} [params.accountType] eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
|
|
8896
|
+
* @returns {object} an associative dictionary of currencies
|
|
8897
|
+
*/
|
|
8898
|
+
await this.loadMarkets();
|
|
8899
|
+
let accountType = undefined;
|
|
8900
|
+
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
8901
|
+
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
8902
|
+
const accountTypeDefault = isUnifiedAccount ? 'eb_convert_uta' : 'eb_convert_spot';
|
|
8903
|
+
[accountType, params] = this.handleOptionAndParams(params, 'fetchConvertCurrencies', 'accountType', accountTypeDefault);
|
|
8904
|
+
const request = {
|
|
8905
|
+
'accountType': accountType,
|
|
8906
|
+
};
|
|
8907
|
+
const response = await this.privateGetV5AssetExchangeQueryCoinList(this.extend(request, params));
|
|
8908
|
+
//
|
|
8909
|
+
// {
|
|
8910
|
+
// "retCode": 0,
|
|
8911
|
+
// "retMsg": "ok",
|
|
8912
|
+
// "result": {
|
|
8913
|
+
// "coins": [
|
|
8914
|
+
// {
|
|
8915
|
+
// "coin": "MATIC",
|
|
8916
|
+
// "fullName": "MATIC",
|
|
8917
|
+
// "icon": "https://s1.bycsi.com/app/assets/token/0552ae79c535c3095fa18f7b377dd2e9.svg",
|
|
8918
|
+
// "iconNight": "https://t1.bycsi.com/app/assets/token/f59301aef2d6ac2165c4c4603e672fb4.svg",
|
|
8919
|
+
// "accuracyLength": 8,
|
|
8920
|
+
// "coinType": "crypto",
|
|
8921
|
+
// "balance": "0",
|
|
8922
|
+
// "uBalance": "0",
|
|
8923
|
+
// "timePeriod": 0,
|
|
8924
|
+
// "singleFromMinLimit": "1.1",
|
|
8925
|
+
// "singleFromMaxLimit": "20001",
|
|
8926
|
+
// "singleToMinLimit": "0",
|
|
8927
|
+
// "singleToMaxLimit": "0",
|
|
8928
|
+
// "dailyFromMinLimit": "0",
|
|
8929
|
+
// "dailyFromMaxLimit": "0",
|
|
8930
|
+
// "dailyToMinLimit": "0",
|
|
8931
|
+
// "dailyToMaxLimit": "0",
|
|
8932
|
+
// "disableFrom": false,
|
|
8933
|
+
// "disableTo": false
|
|
8934
|
+
// },
|
|
8935
|
+
// ]
|
|
8936
|
+
// },
|
|
8937
|
+
// "retExtInfo": {},
|
|
8938
|
+
// "time": 1727256416250
|
|
8939
|
+
// }
|
|
8940
|
+
//
|
|
8941
|
+
const result = {};
|
|
8942
|
+
const data = this.safeDict(response, 'result', {});
|
|
8943
|
+
const coins = this.safeList(data, 'coins', []);
|
|
8944
|
+
for (let i = 0; i < coins.length; i++) {
|
|
8945
|
+
const entry = coins[i];
|
|
8946
|
+
const id = this.safeString(entry, 'coin');
|
|
8947
|
+
const disableFrom = this.safeBool(entry, 'disableFrom');
|
|
8948
|
+
const disableTo = this.safeBool(entry, 'disableTo');
|
|
8949
|
+
const inactive = (disableFrom || disableTo);
|
|
8950
|
+
const code = this.safeCurrencyCode(id);
|
|
8951
|
+
result[code] = {
|
|
8952
|
+
'info': entry,
|
|
8953
|
+
'id': id,
|
|
8954
|
+
'code': code,
|
|
8955
|
+
'networks': undefined,
|
|
8956
|
+
'type': this.safeString(entry, 'coinType'),
|
|
8957
|
+
'name': this.safeString(entry, 'fullName'),
|
|
8958
|
+
'active': !inactive,
|
|
8959
|
+
'deposit': undefined,
|
|
8960
|
+
'withdraw': this.safeNumber(entry, 'balance'),
|
|
8961
|
+
'fee': undefined,
|
|
8962
|
+
'precision': undefined,
|
|
8963
|
+
'limits': {
|
|
8964
|
+
'amount': {
|
|
8965
|
+
'min': this.safeNumber(entry, 'singleFromMinLimit'),
|
|
8966
|
+
'max': this.safeNumber(entry, 'singleFromMaxLimit'),
|
|
8967
|
+
},
|
|
8968
|
+
'withdraw': {
|
|
8969
|
+
'min': undefined,
|
|
8970
|
+
'max': undefined,
|
|
8971
|
+
},
|
|
8972
|
+
'deposit': {
|
|
8973
|
+
'min': undefined,
|
|
8974
|
+
'max': undefined,
|
|
8975
|
+
},
|
|
8976
|
+
},
|
|
8977
|
+
'created': undefined,
|
|
8978
|
+
};
|
|
8979
|
+
}
|
|
8980
|
+
return result;
|
|
8981
|
+
}
|
|
8982
|
+
async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
|
|
8983
|
+
/**
|
|
8984
|
+
* @method
|
|
8985
|
+
* @name bybit#fetchConvertQuote
|
|
8986
|
+
* @description fetch a quote for converting from one currency to another
|
|
8987
|
+
* @see https://bybit-exchange.github.io/docs/v5/asset/convert/apply-quote
|
|
8988
|
+
* @param {string} fromCode the currency that you want to sell and convert from
|
|
8989
|
+
* @param {string} toCode the currency that you want to buy and convert into
|
|
8990
|
+
* @param {float} [amount] how much you want to trade in units of the from currency
|
|
8991
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8992
|
+
* @param {string} [params.accountType] eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
|
|
8993
|
+
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
8994
|
+
*/
|
|
8995
|
+
await this.loadMarkets();
|
|
8996
|
+
let accountType = undefined;
|
|
8997
|
+
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
8998
|
+
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
8999
|
+
const accountTypeDefault = isUnifiedAccount ? 'eb_convert_uta' : 'eb_convert_spot';
|
|
9000
|
+
[accountType, params] = this.handleOptionAndParams(params, 'fetchConvertQuote', 'accountType', accountTypeDefault);
|
|
9001
|
+
const request = {
|
|
9002
|
+
'fromCoin': fromCode,
|
|
9003
|
+
'toCoin': toCode,
|
|
9004
|
+
'requestAmount': this.numberToString(amount),
|
|
9005
|
+
'requestCoin': fromCode,
|
|
9006
|
+
'accountType': accountType,
|
|
9007
|
+
};
|
|
9008
|
+
const response = await this.privatePostV5AssetExchangeQuoteApply(this.extend(request, params));
|
|
9009
|
+
//
|
|
9010
|
+
// {
|
|
9011
|
+
// "retCode": 0,
|
|
9012
|
+
// "retMsg": "ok",
|
|
9013
|
+
// "result": {
|
|
9014
|
+
// "quoteTxId": "1010020692439481682687668224",
|
|
9015
|
+
// "exchangeRate": "0.000015330836780000",
|
|
9016
|
+
// "fromCoin": "USDT",
|
|
9017
|
+
// "fromCoinType": "crypto",
|
|
9018
|
+
// "toCoin": "BTC",
|
|
9019
|
+
// "toCoinType": "crypto",
|
|
9020
|
+
// "fromAmount": "10",
|
|
9021
|
+
// "toAmount": "0.000153308367800000",
|
|
9022
|
+
// "expiredTime": "1727257413353",
|
|
9023
|
+
// "requestId": ""
|
|
9024
|
+
// },
|
|
9025
|
+
// "retExtInfo": {},
|
|
9026
|
+
// "time": 1727257398375
|
|
9027
|
+
// }
|
|
9028
|
+
//
|
|
9029
|
+
const data = this.safeDict(response, 'result', {});
|
|
9030
|
+
const fromCurrencyId = this.safeString(data, 'fromCoin', fromCode);
|
|
9031
|
+
const fromCurrency = this.currency(fromCurrencyId);
|
|
9032
|
+
const toCurrencyId = this.safeString(data, 'toCoin', toCode);
|
|
9033
|
+
const toCurrency = this.currency(toCurrencyId);
|
|
9034
|
+
return this.parseConversion(data, fromCurrency, toCurrency);
|
|
9035
|
+
}
|
|
9036
|
+
async createConvertTrade(id, fromCode, toCode, amount = undefined, params = {}) {
|
|
9037
|
+
/**
|
|
9038
|
+
* @method
|
|
9039
|
+
* @name bybit#createConvertTrade
|
|
9040
|
+
* @description convert from one currency to another
|
|
9041
|
+
* @see https://bybit-exchange.github.io/docs/v5/asset/convert/confirm-quote
|
|
9042
|
+
* @param {string} id the id of the trade that you want to make
|
|
9043
|
+
* @param {string} fromCode the currency that you want to sell and convert from
|
|
9044
|
+
* @param {string} toCode the currency that you want to buy and convert into
|
|
9045
|
+
* @param {float} amount how much you want to trade in units of the from currency
|
|
9046
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9047
|
+
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
9048
|
+
*/
|
|
9049
|
+
await this.loadMarkets();
|
|
9050
|
+
const request = {
|
|
9051
|
+
'quoteTxId': id,
|
|
9052
|
+
};
|
|
9053
|
+
const response = await this.privatePostV5AssetExchangeConvertExecute(this.extend(request, params));
|
|
9054
|
+
//
|
|
9055
|
+
// {
|
|
9056
|
+
// "retCode": 0,
|
|
9057
|
+
// "retMsg": "ok",
|
|
9058
|
+
// "result": {
|
|
9059
|
+
// "exchangeStatus": "processing",
|
|
9060
|
+
// "quoteTxId": "1010020692439483803499737088"
|
|
9061
|
+
// },
|
|
9062
|
+
// "retExtInfo": {},
|
|
9063
|
+
// "time": 1727257904969
|
|
9064
|
+
// }
|
|
9065
|
+
//
|
|
9066
|
+
const data = this.safeDict(response, 'result', {});
|
|
9067
|
+
return this.parseConversion(data);
|
|
9068
|
+
}
|
|
9069
|
+
async fetchConvertTrade(id, code = undefined, params = {}) {
|
|
9070
|
+
/**
|
|
9071
|
+
* @method
|
|
9072
|
+
* @name bybit#fetchConvertTrade
|
|
9073
|
+
* @description fetch the data for a conversion trade
|
|
9074
|
+
* @see https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-result
|
|
9075
|
+
* @param {string} id the id of the trade that you want to fetch
|
|
9076
|
+
* @param {string} [code] the unified currency code of the conversion trade
|
|
9077
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9078
|
+
* @param {string} [params.accountType] eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
|
|
9079
|
+
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
9080
|
+
*/
|
|
9081
|
+
await this.loadMarkets();
|
|
9082
|
+
let accountType = undefined;
|
|
9083
|
+
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
9084
|
+
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
9085
|
+
const accountTypeDefault = isUnifiedAccount ? 'eb_convert_uta' : 'eb_convert_spot';
|
|
9086
|
+
[accountType, params] = this.handleOptionAndParams(params, 'fetchConvertQuote', 'accountType', accountTypeDefault);
|
|
9087
|
+
const request = {
|
|
9088
|
+
'quoteTxId': id,
|
|
9089
|
+
'accountType': accountType,
|
|
9090
|
+
};
|
|
9091
|
+
const response = await this.privateGetV5AssetExchangeConvertResultQuery(this.extend(request, params));
|
|
9092
|
+
//
|
|
9093
|
+
// {
|
|
9094
|
+
// "retCode": 0,
|
|
9095
|
+
// "retMsg": "ok",
|
|
9096
|
+
// "result": {
|
|
9097
|
+
// "result": {
|
|
9098
|
+
// "accountType": "eb_convert_uta",
|
|
9099
|
+
// "exchangeTxId": "1010020692439483803499737088",
|
|
9100
|
+
// "userId": "100406395",
|
|
9101
|
+
// "fromCoin": "USDT",
|
|
9102
|
+
// "fromCoinType": "crypto",
|
|
9103
|
+
// "fromAmount": "10",
|
|
9104
|
+
// "toCoin": "BTC",
|
|
9105
|
+
// "toCoinType": "crypto",
|
|
9106
|
+
// "toAmount": "0.00015344889",
|
|
9107
|
+
// "exchangeStatus": "success",
|
|
9108
|
+
// "extInfo": {},
|
|
9109
|
+
// "convertRate": "0.000015344889",
|
|
9110
|
+
// "createdAt": "1727257904726"
|
|
9111
|
+
// }
|
|
9112
|
+
// },
|
|
9113
|
+
// "retExtInfo": {},
|
|
9114
|
+
// "time": 1727258257216
|
|
9115
|
+
// }
|
|
9116
|
+
//
|
|
9117
|
+
const data = this.safeDict(response, 'result', {});
|
|
9118
|
+
const result = this.safeDict(data, 'result', {});
|
|
9119
|
+
const fromCurrencyId = this.safeString(result, 'fromCoin');
|
|
9120
|
+
const toCurrencyId = this.safeString(result, 'toCoin');
|
|
9121
|
+
let fromCurrency = undefined;
|
|
9122
|
+
let toCurrency = undefined;
|
|
9123
|
+
if (fromCurrencyId !== undefined) {
|
|
9124
|
+
fromCurrency = this.currency(fromCurrencyId);
|
|
9125
|
+
}
|
|
9126
|
+
if (toCurrencyId !== undefined) {
|
|
9127
|
+
toCurrency = this.currency(toCurrencyId);
|
|
9128
|
+
}
|
|
9129
|
+
return this.parseConversion(result, fromCurrency, toCurrency);
|
|
9130
|
+
}
|
|
9131
|
+
async fetchConvertTradeHistory(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
9132
|
+
/**
|
|
9133
|
+
* @method
|
|
9134
|
+
* @name bybit#fetchConvertTradeHistory
|
|
9135
|
+
* @description fetch the users history of conversion trades
|
|
9136
|
+
* @see https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-history
|
|
9137
|
+
* @param {string} [code] the unified currency code
|
|
9138
|
+
* @param {int} [since] the earliest time in ms to fetch conversions for
|
|
9139
|
+
* @param {int} [limit] the maximum number of conversion structures to retrieve
|
|
9140
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9141
|
+
* @param {string} [params.accountType] eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
|
|
9142
|
+
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
9143
|
+
*/
|
|
9144
|
+
await this.loadMarkets();
|
|
9145
|
+
const request = {};
|
|
9146
|
+
if (limit !== undefined) {
|
|
9147
|
+
request['limit'] = limit;
|
|
9148
|
+
}
|
|
9149
|
+
const response = await this.privateGetV5AssetExchangeQueryConvertHistory(this.extend(request, params));
|
|
9150
|
+
//
|
|
9151
|
+
// {
|
|
9152
|
+
// "retCode": 0,
|
|
9153
|
+
// "retMsg": "ok",
|
|
9154
|
+
// "result": {
|
|
9155
|
+
// "list": [
|
|
9156
|
+
// {
|
|
9157
|
+
// "accountType": "eb_convert_uta",
|
|
9158
|
+
// "exchangeTxId": "1010020692439483803499737088",
|
|
9159
|
+
// "userId": "100406395",
|
|
9160
|
+
// "fromCoin": "USDT",
|
|
9161
|
+
// "fromCoinType": "crypto",
|
|
9162
|
+
// "fromAmount": "10",
|
|
9163
|
+
// "toCoin": "BTC",
|
|
9164
|
+
// "toCoinType": "crypto",
|
|
9165
|
+
// "toAmount": "0.00015344889",
|
|
9166
|
+
// "exchangeStatus": "success",
|
|
9167
|
+
// "extInfo": {},
|
|
9168
|
+
// "convertRate": "0.000015344889",
|
|
9169
|
+
// "createdAt": "1727257904726"
|
|
9170
|
+
// }
|
|
9171
|
+
// ]
|
|
9172
|
+
// },
|
|
9173
|
+
// "retExtInfo": {},
|
|
9174
|
+
// "time": 1727258761874
|
|
9175
|
+
// }
|
|
9176
|
+
//
|
|
9177
|
+
const data = this.safeDict(response, 'result', {});
|
|
9178
|
+
const dataList = this.safeList(data, 'list', []);
|
|
9179
|
+
return this.parseConversions(dataList, code, 'fromCoin', 'toCoin', since, limit);
|
|
9180
|
+
}
|
|
9181
|
+
parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
|
|
9182
|
+
//
|
|
9183
|
+
// fetchConvertQuote
|
|
9184
|
+
//
|
|
9185
|
+
// {
|
|
9186
|
+
// "quoteTxId": "1010020692439481682687668224",
|
|
9187
|
+
// "exchangeRate": "0.000015330836780000",
|
|
9188
|
+
// "fromCoin": "USDT",
|
|
9189
|
+
// "fromCoinType": "crypto",
|
|
9190
|
+
// "toCoin": "BTC",
|
|
9191
|
+
// "toCoinType": "crypto",
|
|
9192
|
+
// "fromAmount": "10",
|
|
9193
|
+
// "toAmount": "0.000153308367800000",
|
|
9194
|
+
// "expiredTime": "1727257413353",
|
|
9195
|
+
// "requestId": ""
|
|
9196
|
+
// }
|
|
9197
|
+
//
|
|
9198
|
+
// createConvertTrade
|
|
9199
|
+
//
|
|
9200
|
+
// {
|
|
9201
|
+
// "exchangeStatus": "processing",
|
|
9202
|
+
// "quoteTxId": "1010020692439483803499737088"
|
|
9203
|
+
// }
|
|
9204
|
+
//
|
|
9205
|
+
// fetchConvertTrade, fetchConvertTradeHistory
|
|
9206
|
+
//
|
|
9207
|
+
// {
|
|
9208
|
+
// "accountType": "eb_convert_uta",
|
|
9209
|
+
// "exchangeTxId": "1010020692439483803499737088",
|
|
9210
|
+
// "userId": "100406395",
|
|
9211
|
+
// "fromCoin": "USDT",
|
|
9212
|
+
// "fromCoinType": "crypto",
|
|
9213
|
+
// "fromAmount": "10",
|
|
9214
|
+
// "toCoin": "BTC",
|
|
9215
|
+
// "toCoinType": "crypto",
|
|
9216
|
+
// "toAmount": "0.00015344889",
|
|
9217
|
+
// "exchangeStatus": "success",
|
|
9218
|
+
// "extInfo": {},
|
|
9219
|
+
// "convertRate": "0.000015344889",
|
|
9220
|
+
// "createdAt": "1727257904726"
|
|
9221
|
+
// }
|
|
9222
|
+
//
|
|
9223
|
+
const timestamp = this.safeInteger2(conversion, 'expiredTime', 'createdAt');
|
|
9224
|
+
const fromCoin = this.safeString(conversion, 'fromCoin');
|
|
9225
|
+
const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
|
|
9226
|
+
const to = this.safeString(conversion, 'toCoin');
|
|
9227
|
+
const toCode = this.safeCurrencyCode(to, toCurrency);
|
|
9228
|
+
return {
|
|
9229
|
+
'info': conversion,
|
|
9230
|
+
'timestamp': timestamp,
|
|
9231
|
+
'datetime': this.iso8601(timestamp),
|
|
9232
|
+
'id': this.safeString2(conversion, 'quoteTxId', 'exchangeTxId'),
|
|
9233
|
+
'fromCurrency': fromCode,
|
|
9234
|
+
'fromAmount': this.safeNumber(conversion, 'fromAmount'),
|
|
9235
|
+
'toCurrency': toCode,
|
|
9236
|
+
'toAmount': this.safeNumber(conversion, 'toAmount'),
|
|
9237
|
+
'price': undefined,
|
|
9238
|
+
'fee': undefined,
|
|
9239
|
+
};
|
|
9240
|
+
}
|
|
8878
9241
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
8879
9242
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
8880
9243
|
if (api === 'public') {
|
package/js/src/htx.js
CHANGED
|
@@ -2081,6 +2081,10 @@ export default class htx extends Exchange {
|
|
|
2081
2081
|
* @method
|
|
2082
2082
|
* @name htx#fetchTicker
|
|
2083
2083
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
2084
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-latest-aggregated-ticker
|
|
2085
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-market-data-overview
|
|
2086
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-data-overview
|
|
2087
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-data-overview
|
|
2084
2088
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
2085
2089
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2086
2090
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -2401,6 +2405,10 @@ export default class htx extends Exchange {
|
|
|
2401
2405
|
* @method
|
|
2402
2406
|
* @name htx#fetchOrderBook
|
|
2403
2407
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
2408
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-market-depth
|
|
2409
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-market-depth
|
|
2410
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-depth
|
|
2411
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-depth
|
|
2404
2412
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
2405
2413
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
2406
2414
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2630,6 +2638,7 @@ export default class htx extends Exchange {
|
|
|
2630
2638
|
* @method
|
|
2631
2639
|
* @name htx#fetchOrderTrades
|
|
2632
2640
|
* @description fetch all the trades made from a single order
|
|
2641
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
|
|
2633
2642
|
* @param {string} id order id
|
|
2634
2643
|
* @param {string} symbol unified market symbol
|
|
2635
2644
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
@@ -2649,6 +2658,19 @@ export default class htx extends Exchange {
|
|
|
2649
2658
|
return await this.fetchSpotOrderTrades(id, symbol, since, limit, params);
|
|
2650
2659
|
}
|
|
2651
2660
|
async fetchSpotOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2661
|
+
/**
|
|
2662
|
+
* @ignore
|
|
2663
|
+
* @method
|
|
2664
|
+
* @name htx#fetchOrderTrades
|
|
2665
|
+
* @description fetch all the trades made from a single order
|
|
2666
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
|
|
2667
|
+
* @param {string} id order id
|
|
2668
|
+
* @param {string} symbol unified market symbol
|
|
2669
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
2670
|
+
* @param {int} [limit] the maximum number of trades to retrieve
|
|
2671
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2672
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2673
|
+
*/
|
|
2652
2674
|
await this.loadMarkets();
|
|
2653
2675
|
const request = {
|
|
2654
2676
|
'order-id': id,
|
package/js/src/okx.js
CHANGED
|
@@ -269,6 +269,7 @@ export default class okx extends Exchange {
|
|
|
269
269
|
'copytrading/public-preference-currency': 4,
|
|
270
270
|
'copytrading/public-current-subpositions': 4,
|
|
271
271
|
'copytrading/public-subpositions-history': 4,
|
|
272
|
+
'support/announcements-types': 20,
|
|
272
273
|
},
|
|
273
274
|
},
|
|
274
275
|
'private': {
|
|
@@ -414,6 +415,7 @@ export default class okx extends Exchange {
|
|
|
414
415
|
// affiliate
|
|
415
416
|
'affiliate/invitee/detail': 1,
|
|
416
417
|
'users/partner/if-rebate': 1,
|
|
418
|
+
'support/announcements': 4,
|
|
417
419
|
},
|
|
418
420
|
'post': {
|
|
419
421
|
// rfq
|
|
@@ -793,6 +795,8 @@ export default class okx extends Exchange {
|
|
|
793
795
|
// SPOT/MARGIN error codes 54000-54999
|
|
794
796
|
'54000': ExchangeError,
|
|
795
797
|
'54001': ExchangeError,
|
|
798
|
+
'54008': InvalidOrder,
|
|
799
|
+
'54009': InvalidOrder,
|
|
796
800
|
'54011': InvalidOrder,
|
|
797
801
|
// Trading bot Error Code from 55100 to 55999
|
|
798
802
|
'55100': InvalidOrder,
|
package/js/src/pro/bitmart.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export default class bitmart extends bitmartRest {
|
|
|
14
14
|
getParamsForMultipleSub(methodName: string, symbols: string[], limit?: Int, params?: {}): any[];
|
|
15
15
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
16
16
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
17
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
18
|
+
handleBidAsk(client: Client, message: any): void;
|
|
19
|
+
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
17
20
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
18
21
|
handleOrders(client: Client, message: any): void;
|
|
19
22
|
parseWsOrder(order: Dict, market?: Market): Order;
|
package/js/src/pro/bitmart.js
CHANGED
|
@@ -26,6 +26,7 @@ export default class bitmart extends bitmartRest {
|
|
|
26
26
|
'watchBalance': true,
|
|
27
27
|
'watchTicker': true,
|
|
28
28
|
'watchTickers': true,
|
|
29
|
+
'watchBidsAsks': true,
|
|
29
30
|
'watchOrderBook': true,
|
|
30
31
|
'watchOrderBookForSymbols': true,
|
|
31
32
|
'watchOrders': true,
|
|
@@ -337,6 +338,7 @@ export default class bitmart extends bitmartRest {
|
|
|
337
338
|
/**
|
|
338
339
|
* @method
|
|
339
340
|
* @name bitmart#watchTickers
|
|
341
|
+
* @see https://developer-pro.bitmart.com/en/spot/#public-ticker-channel
|
|
340
342
|
* @see https://developer-pro.bitmart.com/en/futuresv2/#public-ticker-channel
|
|
341
343
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
|
|
342
344
|
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
@@ -355,6 +357,84 @@ export default class bitmart extends bitmartRest {
|
|
|
355
357
|
}
|
|
356
358
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
357
359
|
}
|
|
360
|
+
async watchBidsAsks(symbols = undefined, params = {}) {
|
|
361
|
+
/**
|
|
362
|
+
* @method
|
|
363
|
+
* @name bitmart#watchBidsAsks
|
|
364
|
+
* @see https://developer-pro.bitmart.com/en/spot/#public-ticker-channel
|
|
365
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#public-ticker-channel
|
|
366
|
+
* @description watches best bid & ask for symbols
|
|
367
|
+
* @param {string[]} symbols unified symbol of the market to fetch the ticker for
|
|
368
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
369
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
370
|
+
*/
|
|
371
|
+
await this.loadMarkets();
|
|
372
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
373
|
+
const firstMarket = this.getMarketFromSymbols(symbols);
|
|
374
|
+
let marketType = undefined;
|
|
375
|
+
[marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', firstMarket, params);
|
|
376
|
+
const url = this.implodeHostname(this.urls['api']['ws'][marketType]['public']);
|
|
377
|
+
const channelType = (marketType === 'spot') ? 'spot' : 'futures';
|
|
378
|
+
const actionType = (marketType === 'spot') ? 'op' : 'action';
|
|
379
|
+
let rawSubscriptions = [];
|
|
380
|
+
const messageHashes = [];
|
|
381
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
382
|
+
const market = this.market(symbols[i]);
|
|
383
|
+
rawSubscriptions.push(channelType + '/ticker:' + market['id']);
|
|
384
|
+
messageHashes.push('bidask:' + symbols[i]);
|
|
385
|
+
}
|
|
386
|
+
if (marketType !== 'spot') {
|
|
387
|
+
rawSubscriptions = [channelType + '/ticker'];
|
|
388
|
+
}
|
|
389
|
+
const request = {
|
|
390
|
+
'args': rawSubscriptions,
|
|
391
|
+
};
|
|
392
|
+
request[actionType] = 'subscribe';
|
|
393
|
+
const newTickers = await this.watchMultiple(url, messageHashes, request, rawSubscriptions);
|
|
394
|
+
if (this.newUpdates) {
|
|
395
|
+
const tickers = {};
|
|
396
|
+
tickers[newTickers['symbol']] = newTickers;
|
|
397
|
+
return tickers;
|
|
398
|
+
}
|
|
399
|
+
return this.filterByArray(this.bidsasks, 'symbol', symbols);
|
|
400
|
+
}
|
|
401
|
+
handleBidAsk(client, message) {
|
|
402
|
+
const table = this.safeString(message, 'table');
|
|
403
|
+
const isSpot = (table !== undefined);
|
|
404
|
+
let rawTickers = [];
|
|
405
|
+
if (isSpot) {
|
|
406
|
+
rawTickers = this.safeList(message, 'data', []);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
rawTickers = [this.safeValue(message, 'data', {})];
|
|
410
|
+
}
|
|
411
|
+
if (!rawTickers.length) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
for (let i = 0; i < rawTickers.length; i++) {
|
|
415
|
+
const ticker = this.parseWsBidAsk(rawTickers[i]);
|
|
416
|
+
const symbol = ticker['symbol'];
|
|
417
|
+
this.bidsasks[symbol] = ticker;
|
|
418
|
+
const messageHash = 'bidask:' + symbol;
|
|
419
|
+
client.resolve(ticker, messageHash);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
parseWsBidAsk(ticker, market = undefined) {
|
|
423
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
424
|
+
market = this.safeMarket(marketId, market);
|
|
425
|
+
const symbol = this.safeString(market, 'symbol');
|
|
426
|
+
const timestamp = this.safeInteger(ticker, 'ms_t');
|
|
427
|
+
return this.safeTicker({
|
|
428
|
+
'symbol': symbol,
|
|
429
|
+
'timestamp': timestamp,
|
|
430
|
+
'datetime': this.iso8601(timestamp),
|
|
431
|
+
'ask': this.safeString2(ticker, 'ask_px', 'ask_price'),
|
|
432
|
+
'askVolume': this.safeString2(ticker, 'ask_sz', 'ask_vol'),
|
|
433
|
+
'bid': this.safeString2(ticker, 'bid_px', 'bid_price'),
|
|
434
|
+
'bidVolume': this.safeString2(ticker, 'bid_sz', 'bid_vol'),
|
|
435
|
+
'info': ticker,
|
|
436
|
+
}, market);
|
|
437
|
+
}
|
|
358
438
|
async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
359
439
|
/**
|
|
360
440
|
* @method
|
|
@@ -934,6 +1014,7 @@ export default class bitmart extends bitmartRest {
|
|
|
934
1014
|
// }
|
|
935
1015
|
// }
|
|
936
1016
|
//
|
|
1017
|
+
this.handleBidAsk(client, message);
|
|
937
1018
|
const table = this.safeString(message, 'table');
|
|
938
1019
|
const isSpot = (table !== undefined);
|
|
939
1020
|
let rawTickers = [];
|
package/js/src/pro/bitvavo.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import bitvavoRest from '../bitvavo.js';
|
|
2
|
-
import { Int, Str, OrderSide, OrderType, OrderBook, Ticker, Trade, Order, OHLCV, Balances, Num, TradingFees } from '../base/types.js';
|
|
2
|
+
import { Int, Str, OrderSide, OrderType, OrderBook, Ticker, Trade, Order, OHLCV, Balances, Num, TradingFees, Strings, Tickers } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class bitvavo extends bitvavoRest {
|
|
5
5
|
describe(): any;
|
|
6
6
|
watchPublic(name: any, symbol: any, params?: {}): Promise<any>;
|
|
7
|
+
watchPublicMultiple(methodName: any, channelName: string, symbols: any, params?: {}): Promise<any>;
|
|
7
8
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
8
|
-
|
|
9
|
+
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
10
|
+
handleTicker(client: Client, message: any): void;
|
|
11
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
12
|
+
handleBidAsk(client: Client, message: any): void;
|
|
13
|
+
parseWsBidAsk(ticker: any, market?: any): Ticker;
|
|
9
14
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
10
15
|
handleTrade(client: Client, message: any): void;
|
|
11
16
|
watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|