ccxt 4.3.34 → 4.3.35
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/alpaca.js +1 -1
- package/dist/cjs/src/base/Exchange.js +11 -0
- package/dist/cjs/src/bitmart.js +2 -9
- package/dist/cjs/src/coinbase.js +63 -2
- package/dist/cjs/src/coinex.js +26 -19
- package/dist/cjs/src/kraken.js +3 -1
- package/dist/cjs/src/pro/bitget.js +31 -1
- package/dist/cjs/src/pro/okx.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/alpaca.d.ts +1 -1
- package/js/src/alpaca.js +1 -1
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +11 -0
- package/js/src/bitmart.js +2 -9
- package/js/src/coinbase.d.ts +2 -1
- package/js/src/coinbase.js +63 -2
- package/js/src/coinex.js +26 -19
- package/js/src/kraken.js +3 -1
- package/js/src/pro/bitget.js +31 -1
- package/js/src/pro/okx.js +1 -1
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -185,7 +185,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
|
|
|
185
185
|
|
|
186
186
|
//-----------------------------------------------------------------------------
|
|
187
187
|
// this is updated by vss.js when building
|
|
188
|
-
const version = '4.3.
|
|
188
|
+
const version = '4.3.35';
|
|
189
189
|
Exchange["default"].ccxtVersion = version;
|
|
190
190
|
const exchanges = {
|
|
191
191
|
'ace': ace,
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -791,7 +791,7 @@ class alpaca extends alpaca$1 {
|
|
|
791
791
|
// "message": "order is not found."
|
|
792
792
|
// }
|
|
793
793
|
//
|
|
794
|
-
return this.
|
|
794
|
+
return this.parseOrder(response);
|
|
795
795
|
}
|
|
796
796
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
797
797
|
/**
|
|
@@ -2962,6 +2962,17 @@ class Exchange {
|
|
|
2962
2962
|
trade['cost'] = this.parseNumber(cost);
|
|
2963
2963
|
return trade;
|
|
2964
2964
|
}
|
|
2965
|
+
findNearestCeiling(arr, providedValue) {
|
|
2966
|
+
// i.e. findNearestCeiling ([ 10, 30, 50], 23) returns 30
|
|
2967
|
+
const length = arr.length;
|
|
2968
|
+
for (let i = 0; i < length; i++) {
|
|
2969
|
+
const current = arr[i];
|
|
2970
|
+
if (providedValue <= current) {
|
|
2971
|
+
return current;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
return arr[length - 1];
|
|
2975
|
+
}
|
|
2965
2976
|
invertFlatStringDictionary(dict) {
|
|
2966
2977
|
const reversed = {};
|
|
2967
2978
|
const keys = Object.keys(dict);
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -1182,16 +1182,9 @@ class bitmart extends bitmart$1 {
|
|
|
1182
1182
|
market = this.safeMarket(marketId, market);
|
|
1183
1183
|
const symbol = market['symbol'];
|
|
1184
1184
|
const last = this.safeString2(ticker, 'close_24h', 'last_price');
|
|
1185
|
-
let percentage = this.safeString(ticker, 'price_change_percent_24h');
|
|
1185
|
+
let percentage = Precise["default"].stringAbs(this.safeString(ticker, 'price_change_percent_24h'));
|
|
1186
1186
|
if (percentage === undefined) {
|
|
1187
|
-
|
|
1188
|
-
if ((percentageRaw !== undefined) && (percentageRaw !== '0')) { // a few tickers show strictly '0' in fluctuation field
|
|
1189
|
-
const direction = percentageRaw[0];
|
|
1190
|
-
percentage = direction + Precise["default"].stringMul(percentageRaw.replace(direction, ''), '100');
|
|
1191
|
-
}
|
|
1192
|
-
else if (percentageRaw === '0') {
|
|
1193
|
-
percentage = '0';
|
|
1194
|
-
}
|
|
1187
|
+
percentage = Precise["default"].stringAbs(Precise["default"].stringMul(this.safeString(ticker, 'fluctuation'), '100'));
|
|
1195
1188
|
}
|
|
1196
1189
|
let baseVolume = this.safeString(ticker, 'base_volume_24h');
|
|
1197
1190
|
let quoteVolume = this.safeString(ticker, 'quote_volume_24h');
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -111,8 +111,8 @@ class coinbase extends coinbase$1 {
|
|
|
111
111
|
'fetchTickers': true,
|
|
112
112
|
'fetchTime': true,
|
|
113
113
|
'fetchTrades': true,
|
|
114
|
-
'fetchTradingFee':
|
|
115
|
-
'fetchTradingFees':
|
|
114
|
+
'fetchTradingFee': 'emulated',
|
|
115
|
+
'fetchTradingFees': true,
|
|
116
116
|
'fetchWithdrawals': true,
|
|
117
117
|
'reduceMargin': false,
|
|
118
118
|
'setLeverage': false,
|
|
@@ -4537,6 +4537,67 @@ class coinbase extends coinbase$1 {
|
|
|
4537
4537
|
'takeProfitPrice': undefined,
|
|
4538
4538
|
});
|
|
4539
4539
|
}
|
|
4540
|
+
async fetchTradingFees(params = {}) {
|
|
4541
|
+
/**
|
|
4542
|
+
* @method
|
|
4543
|
+
* @name coinbase#fetchTradingFees
|
|
4544
|
+
* @see https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gettransactionsummary/
|
|
4545
|
+
* @description fetch the trading fees for multiple markets
|
|
4546
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4547
|
+
* @param {string} [params.type] 'spot' or 'swap'
|
|
4548
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
4549
|
+
*/
|
|
4550
|
+
await this.loadMarkets();
|
|
4551
|
+
let type = undefined;
|
|
4552
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
4553
|
+
const isSpot = (type === 'spot');
|
|
4554
|
+
const productType = isSpot ? 'SPOT' : 'FUTURE';
|
|
4555
|
+
const request = {
|
|
4556
|
+
'product_type': productType,
|
|
4557
|
+
};
|
|
4558
|
+
const response = await this.v3PrivateGetBrokerageTransactionSummary(this.extend(request, params));
|
|
4559
|
+
//
|
|
4560
|
+
// {
|
|
4561
|
+
// total_volume: '0',
|
|
4562
|
+
// total_fees: '0',
|
|
4563
|
+
// fee_tier: {
|
|
4564
|
+
// pricing_tier: 'Advanced 1',
|
|
4565
|
+
// usd_from: '0',
|
|
4566
|
+
// usd_to: '1000',
|
|
4567
|
+
// taker_fee_rate: '0.008',
|
|
4568
|
+
// maker_fee_rate: '0.006',
|
|
4569
|
+
// aop_from: '',
|
|
4570
|
+
// aop_to: ''
|
|
4571
|
+
// },
|
|
4572
|
+
// margin_rate: null,
|
|
4573
|
+
// goods_and_services_tax: null,
|
|
4574
|
+
// advanced_trade_only_volume: '0',
|
|
4575
|
+
// advanced_trade_only_fees: '0',
|
|
4576
|
+
// coinbase_pro_volume: '0',
|
|
4577
|
+
// coinbase_pro_fees: '0',
|
|
4578
|
+
// total_balance: '',
|
|
4579
|
+
// has_promo_fee: false
|
|
4580
|
+
// }
|
|
4581
|
+
//
|
|
4582
|
+
const data = this.safeDict(response, 'fee_tier', {});
|
|
4583
|
+
const taker_fee = this.safeNumber(data, 'taker_fee_rate');
|
|
4584
|
+
const marker_fee = this.safeNumber(data, 'maker_fee_rate');
|
|
4585
|
+
const result = {};
|
|
4586
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
|
4587
|
+
const symbol = this.symbols[i];
|
|
4588
|
+
const market = this.market(symbol);
|
|
4589
|
+
if ((isSpot && market['spot']) || (!isSpot && !market['spot'])) {
|
|
4590
|
+
result[symbol] = {
|
|
4591
|
+
'info': response,
|
|
4592
|
+
'symbol': symbol,
|
|
4593
|
+
'maker': taker_fee,
|
|
4594
|
+
'taker': marker_fee,
|
|
4595
|
+
'percentage': true,
|
|
4596
|
+
};
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
return result;
|
|
4600
|
+
}
|
|
4540
4601
|
createAuthToken(seconds, method = undefined, url = undefined) {
|
|
4541
4602
|
// it may not work for v2
|
|
4542
4603
|
let uri = undefined;
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -4643,7 +4643,7 @@ class coinex extends coinex$1 {
|
|
|
4643
4643
|
* @method
|
|
4644
4644
|
* @name coinex#withdraw
|
|
4645
4645
|
* @description make a withdrawal
|
|
4646
|
-
* @see https://
|
|
4646
|
+
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
|
|
4647
4647
|
* @param {string} code unified currency code
|
|
4648
4648
|
* @param {float} amount the amount to withdraw
|
|
4649
4649
|
* @param {string} address the address to withdraw to
|
|
@@ -4656,37 +4656,44 @@ class coinex extends coinex$1 {
|
|
|
4656
4656
|
this.checkAddress(address);
|
|
4657
4657
|
await this.loadMarkets();
|
|
4658
4658
|
const currency = this.currency(code);
|
|
4659
|
-
const networkCode = this.
|
|
4659
|
+
const networkCode = this.safeStringUpper2(params, 'network', 'chain');
|
|
4660
4660
|
params = this.omit(params, 'network');
|
|
4661
4661
|
if (tag) {
|
|
4662
4662
|
address = address + ':' + tag;
|
|
4663
4663
|
}
|
|
4664
4664
|
const request = {
|
|
4665
|
-
'
|
|
4666
|
-
'
|
|
4667
|
-
'
|
|
4668
|
-
'transfer_method': 'onchain', // onchain, local
|
|
4665
|
+
'ccy': currency['id'],
|
|
4666
|
+
'to_address': address,
|
|
4667
|
+
'amount': this.numberToString(amount), // the actual amount without fees, https://www.coinex.com/fees
|
|
4669
4668
|
};
|
|
4670
4669
|
if (networkCode !== undefined) {
|
|
4671
|
-
request['
|
|
4670
|
+
request['chain'] = this.networkCodeToId(networkCode); // required for on-chain, not required for inter-user transfer
|
|
4672
4671
|
}
|
|
4673
|
-
const response = await this.
|
|
4672
|
+
const response = await this.v2PrivatePostAssetsWithdraw(this.extend(request, params));
|
|
4674
4673
|
//
|
|
4675
4674
|
// {
|
|
4676
4675
|
// "code": 0,
|
|
4677
4676
|
// "data": {
|
|
4678
|
-
// "
|
|
4679
|
-
// "
|
|
4680
|
-
// "
|
|
4681
|
-
// "
|
|
4682
|
-
// "
|
|
4677
|
+
// "withdraw_id": 31193755,
|
|
4678
|
+
// "created_at": 1716874165038,
|
|
4679
|
+
// "withdraw_method": "ON_CHAIN",
|
|
4680
|
+
// "ccy": "USDT",
|
|
4681
|
+
// "amount": "17.3",
|
|
4682
|
+
// "actual_amount": "15",
|
|
4683
|
+
// "chain": "TRC20",
|
|
4684
|
+
// "tx_fee": "2.3",
|
|
4685
|
+
// "fee_asset": "USDT",
|
|
4686
|
+
// "fee_amount": "2.3",
|
|
4687
|
+
// "to_address": "TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
|
|
4688
|
+
// "memo": "",
|
|
4689
|
+
// "tx_id": "",
|
|
4683
4690
|
// "confirmations": 0,
|
|
4684
|
-
// "
|
|
4685
|
-
// "
|
|
4686
|
-
// "
|
|
4687
|
-
// "
|
|
4691
|
+
// "explorer_address_url": "https://tronscan.org/#/address/TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
|
|
4692
|
+
// "explorer_tx_url": "https://tronscan.org/#/transaction/",
|
|
4693
|
+
// "remark": "",
|
|
4694
|
+
// "status": "audit_required"
|
|
4688
4695
|
// },
|
|
4689
|
-
// "message": "
|
|
4696
|
+
// "message": "OK"
|
|
4690
4697
|
// }
|
|
4691
4698
|
//
|
|
4692
4699
|
const transaction = this.safeDict(response, 'data', {});
|
|
@@ -4797,7 +4804,7 @@ class coinex extends coinex$1 {
|
|
|
4797
4804
|
// "remark": ""
|
|
4798
4805
|
// }
|
|
4799
4806
|
//
|
|
4800
|
-
// fetchWithdrawals
|
|
4807
|
+
// fetchWithdrawals and withdraw
|
|
4801
4808
|
//
|
|
4802
4809
|
// {
|
|
4803
4810
|
// "withdraw_id": 259364,
|
package/dist/cjs/src/kraken.js
CHANGED
|
@@ -986,7 +986,9 @@ class kraken extends kraken$1 {
|
|
|
986
986
|
request['interval'] = timeframe;
|
|
987
987
|
}
|
|
988
988
|
if (since !== undefined) {
|
|
989
|
-
|
|
989
|
+
const scaledSince = this.parseToInt(since / 1000);
|
|
990
|
+
const timeFrameInSeconds = parsedTimeframe * 60;
|
|
991
|
+
request['since'] = this.numberToString(scaledSince - timeFrameInSeconds); // expected to be in seconds
|
|
990
992
|
}
|
|
991
993
|
const response = await this.publicGetOHLC(this.extend(request, params));
|
|
992
994
|
//
|
|
@@ -966,7 +966,9 @@ class bitget extends bitget$1 {
|
|
|
966
966
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
967
967
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
968
968
|
* @param {boolean} [params.stop] *contract only* set to true for watching trigger orders
|
|
969
|
-
* @param {string} [params.marginMode] 'isolated' or 'cross' for watching spot margin orders
|
|
969
|
+
* @param {string} [params.marginMode] 'isolated' or 'cross' for watching spot margin orders]
|
|
970
|
+
* @param {string} [params.type] 'spot', 'swap'
|
|
971
|
+
* @param {string} [params.subType] 'linear', 'inverse'
|
|
970
972
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
|
|
971
973
|
*/
|
|
972
974
|
await this.loadMarkets();
|
|
@@ -982,11 +984,26 @@ class bitget extends bitget$1 {
|
|
|
982
984
|
marketId = market['id'];
|
|
983
985
|
messageHash = messageHash + ':' + symbol;
|
|
984
986
|
}
|
|
987
|
+
const productType = this.safeString(params, 'productType');
|
|
985
988
|
let type = undefined;
|
|
986
989
|
[type, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
|
|
990
|
+
let subType = undefined;
|
|
991
|
+
[subType, params] = this.handleSubTypeAndParams('watchOrders', market, params, 'linear');
|
|
987
992
|
if ((type === 'spot') && (symbol === undefined)) {
|
|
988
993
|
throw new errors.ArgumentsRequired(this.id + ' watchOrders requires a symbol argument for ' + type + ' markets.');
|
|
989
994
|
}
|
|
995
|
+
if ((productType === undefined) && (type !== 'spot') && (symbol === undefined)) {
|
|
996
|
+
messageHash = messageHash + ':' + subType;
|
|
997
|
+
}
|
|
998
|
+
else if (productType === 'USDT-FUTURES') {
|
|
999
|
+
messageHash = messageHash + ':linear';
|
|
1000
|
+
}
|
|
1001
|
+
else if (productType === 'COIN-FUTURES') {
|
|
1002
|
+
messageHash = messageHash + ':inverse';
|
|
1003
|
+
}
|
|
1004
|
+
else if (productType === 'USDC-FUTURES') {
|
|
1005
|
+
messageHash = messageHash + ':usdcfutures'; // non unified channel
|
|
1006
|
+
}
|
|
990
1007
|
let instType = undefined;
|
|
991
1008
|
[instType, params] = this.getInstType(market, params);
|
|
992
1009
|
if (type === 'spot') {
|
|
@@ -1008,6 +1025,7 @@ class bitget extends bitget$1 {
|
|
|
1008
1025
|
channel = 'orders-crossed';
|
|
1009
1026
|
}
|
|
1010
1027
|
}
|
|
1028
|
+
subscriptionHash = subscriptionHash + ':' + instType;
|
|
1011
1029
|
const args = {
|
|
1012
1030
|
'instType': instType,
|
|
1013
1031
|
'channel': channel,
|
|
@@ -1067,6 +1085,9 @@ class bitget extends bitget$1 {
|
|
|
1067
1085
|
else {
|
|
1068
1086
|
marketType = 'contract';
|
|
1069
1087
|
}
|
|
1088
|
+
const isLinearSwap = (instType === 'USDT-FUTURES');
|
|
1089
|
+
const isInverseSwap = (instType === 'COIN-FUTURES');
|
|
1090
|
+
const isUSDCFutures = (instType === 'USDC-FUTURES');
|
|
1070
1091
|
const data = this.safeValue(message, 'data', []);
|
|
1071
1092
|
if (this.orders === undefined) {
|
|
1072
1093
|
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
@@ -1093,6 +1114,15 @@ class bitget extends bitget$1 {
|
|
|
1093
1114
|
client.resolve(stored, innerMessageHash);
|
|
1094
1115
|
}
|
|
1095
1116
|
client.resolve(stored, messageHash);
|
|
1117
|
+
if (isLinearSwap) {
|
|
1118
|
+
client.resolve(stored, 'order:linear');
|
|
1119
|
+
}
|
|
1120
|
+
if (isInverseSwap) {
|
|
1121
|
+
client.resolve(stored, 'order:inverse');
|
|
1122
|
+
}
|
|
1123
|
+
if (isUSDCFutures) {
|
|
1124
|
+
client.resolve(stored, 'order:usdcfutures');
|
|
1125
|
+
}
|
|
1096
1126
|
}
|
|
1097
1127
|
parseWsOrder(order, market = undefined) {
|
|
1098
1128
|
//
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -159,7 +159,7 @@ class okx extends okx$1 {
|
|
|
159
159
|
this.deepExtend(firstArgument, params),
|
|
160
160
|
],
|
|
161
161
|
};
|
|
162
|
-
return this.watch(url, messageHash, request, messageHash);
|
|
162
|
+
return await this.watch(url, messageHash, request, messageHash);
|
|
163
163
|
}
|
|
164
164
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
165
165
|
/**
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.3.
|
|
7
|
+
declare const version = "4.3.34";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.3.
|
|
41
|
+
const version = '4.3.35';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/alpaca.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default class alpaca extends Exchange {
|
|
|
14
14
|
fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
|
|
15
15
|
parseOHLCV(ohlcv: any, market?: Market): OHLCV;
|
|
16
16
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
|
|
17
|
-
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<
|
|
17
|
+
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
18
18
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
19
19
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
20
20
|
fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
package/js/src/alpaca.js
CHANGED
|
@@ -794,7 +794,7 @@ export default class alpaca extends Exchange {
|
|
|
794
794
|
// "message": "order is not found."
|
|
795
795
|
// }
|
|
796
796
|
//
|
|
797
|
-
return this.
|
|
797
|
+
return this.parseOrder(response);
|
|
798
798
|
}
|
|
799
799
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
800
800
|
/**
|
|
@@ -807,6 +807,7 @@ export default class Exchange {
|
|
|
807
807
|
};
|
|
808
808
|
safeLiquidation(liquidation: object, market?: Market): Liquidation;
|
|
809
809
|
safeTrade(trade: object, market?: Market): Trade;
|
|
810
|
+
findNearestCeiling(arr: number[], providedValue: number): number;
|
|
810
811
|
invertFlatStringDictionary(dict: any): {};
|
|
811
812
|
reduceFeesByCurrency(fees: any): any[];
|
|
812
813
|
safeTicker(ticker: object, market?: Market): Ticker;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -2949,6 +2949,17 @@ export default class Exchange {
|
|
|
2949
2949
|
trade['cost'] = this.parseNumber(cost);
|
|
2950
2950
|
return trade;
|
|
2951
2951
|
}
|
|
2952
|
+
findNearestCeiling(arr, providedValue) {
|
|
2953
|
+
// i.e. findNearestCeiling ([ 10, 30, 50], 23) returns 30
|
|
2954
|
+
const length = arr.length;
|
|
2955
|
+
for (let i = 0; i < length; i++) {
|
|
2956
|
+
const current = arr[i];
|
|
2957
|
+
if (providedValue <= current) {
|
|
2958
|
+
return current;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
return arr[length - 1];
|
|
2962
|
+
}
|
|
2952
2963
|
invertFlatStringDictionary(dict) {
|
|
2953
2964
|
const reversed = {};
|
|
2954
2965
|
const keys = Object.keys(dict);
|
package/js/src/bitmart.js
CHANGED
|
@@ -1185,16 +1185,9 @@ export default class bitmart extends Exchange {
|
|
|
1185
1185
|
market = this.safeMarket(marketId, market);
|
|
1186
1186
|
const symbol = market['symbol'];
|
|
1187
1187
|
const last = this.safeString2(ticker, 'close_24h', 'last_price');
|
|
1188
|
-
let percentage = this.safeString(ticker, 'price_change_percent_24h');
|
|
1188
|
+
let percentage = Precise.stringAbs(this.safeString(ticker, 'price_change_percent_24h'));
|
|
1189
1189
|
if (percentage === undefined) {
|
|
1190
|
-
|
|
1191
|
-
if ((percentageRaw !== undefined) && (percentageRaw !== '0')) { // a few tickers show strictly '0' in fluctuation field
|
|
1192
|
-
const direction = percentageRaw[0];
|
|
1193
|
-
percentage = direction + Precise.stringMul(percentageRaw.replace(direction, ''), '100');
|
|
1194
|
-
}
|
|
1195
|
-
else if (percentageRaw === '0') {
|
|
1196
|
-
percentage = '0';
|
|
1197
|
-
}
|
|
1190
|
+
percentage = Precise.stringAbs(Precise.stringMul(this.safeString(ticker, 'fluctuation'), '100'));
|
|
1198
1191
|
}
|
|
1199
1192
|
let baseVolume = this.safeString(ticker, 'base_volume_24h');
|
|
1200
1193
|
let quoteVolume = this.safeString(ticker, 'quote_volume_24h');
|
package/js/src/coinbase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/coinbase.js';
|
|
2
|
-
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int } from './base/types.js';
|
|
2
|
+
import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int, TradingFees } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class coinbase
|
|
5
5
|
* @augments Exchange
|
|
@@ -110,6 +110,7 @@ export default class coinbase extends Exchange {
|
|
|
110
110
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
111
111
|
fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
|
|
112
112
|
parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
|
|
113
|
+
fetchTradingFees(params?: {}): Promise<TradingFees>;
|
|
113
114
|
createAuthToken(seconds: Int, method?: Str, url?: Str): string;
|
|
114
115
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
115
116
|
url: string;
|
package/js/src/coinbase.js
CHANGED
|
@@ -114,8 +114,8 @@ export default class coinbase extends Exchange {
|
|
|
114
114
|
'fetchTickers': true,
|
|
115
115
|
'fetchTime': true,
|
|
116
116
|
'fetchTrades': true,
|
|
117
|
-
'fetchTradingFee':
|
|
118
|
-
'fetchTradingFees':
|
|
117
|
+
'fetchTradingFee': 'emulated',
|
|
118
|
+
'fetchTradingFees': true,
|
|
119
119
|
'fetchWithdrawals': true,
|
|
120
120
|
'reduceMargin': false,
|
|
121
121
|
'setLeverage': false,
|
|
@@ -4540,6 +4540,67 @@ export default class coinbase extends Exchange {
|
|
|
4540
4540
|
'takeProfitPrice': undefined,
|
|
4541
4541
|
});
|
|
4542
4542
|
}
|
|
4543
|
+
async fetchTradingFees(params = {}) {
|
|
4544
|
+
/**
|
|
4545
|
+
* @method
|
|
4546
|
+
* @name coinbase#fetchTradingFees
|
|
4547
|
+
* @see https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gettransactionsummary/
|
|
4548
|
+
* @description fetch the trading fees for multiple markets
|
|
4549
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4550
|
+
* @param {string} [params.type] 'spot' or 'swap'
|
|
4551
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
4552
|
+
*/
|
|
4553
|
+
await this.loadMarkets();
|
|
4554
|
+
let type = undefined;
|
|
4555
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
4556
|
+
const isSpot = (type === 'spot');
|
|
4557
|
+
const productType = isSpot ? 'SPOT' : 'FUTURE';
|
|
4558
|
+
const request = {
|
|
4559
|
+
'product_type': productType,
|
|
4560
|
+
};
|
|
4561
|
+
const response = await this.v3PrivateGetBrokerageTransactionSummary(this.extend(request, params));
|
|
4562
|
+
//
|
|
4563
|
+
// {
|
|
4564
|
+
// total_volume: '0',
|
|
4565
|
+
// total_fees: '0',
|
|
4566
|
+
// fee_tier: {
|
|
4567
|
+
// pricing_tier: 'Advanced 1',
|
|
4568
|
+
// usd_from: '0',
|
|
4569
|
+
// usd_to: '1000',
|
|
4570
|
+
// taker_fee_rate: '0.008',
|
|
4571
|
+
// maker_fee_rate: '0.006',
|
|
4572
|
+
// aop_from: '',
|
|
4573
|
+
// aop_to: ''
|
|
4574
|
+
// },
|
|
4575
|
+
// margin_rate: null,
|
|
4576
|
+
// goods_and_services_tax: null,
|
|
4577
|
+
// advanced_trade_only_volume: '0',
|
|
4578
|
+
// advanced_trade_only_fees: '0',
|
|
4579
|
+
// coinbase_pro_volume: '0',
|
|
4580
|
+
// coinbase_pro_fees: '0',
|
|
4581
|
+
// total_balance: '',
|
|
4582
|
+
// has_promo_fee: false
|
|
4583
|
+
// }
|
|
4584
|
+
//
|
|
4585
|
+
const data = this.safeDict(response, 'fee_tier', {});
|
|
4586
|
+
const taker_fee = this.safeNumber(data, 'taker_fee_rate');
|
|
4587
|
+
const marker_fee = this.safeNumber(data, 'maker_fee_rate');
|
|
4588
|
+
const result = {};
|
|
4589
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
|
4590
|
+
const symbol = this.symbols[i];
|
|
4591
|
+
const market = this.market(symbol);
|
|
4592
|
+
if ((isSpot && market['spot']) || (!isSpot && !market['spot'])) {
|
|
4593
|
+
result[symbol] = {
|
|
4594
|
+
'info': response,
|
|
4595
|
+
'symbol': symbol,
|
|
4596
|
+
'maker': taker_fee,
|
|
4597
|
+
'taker': marker_fee,
|
|
4598
|
+
'percentage': true,
|
|
4599
|
+
};
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
return result;
|
|
4603
|
+
}
|
|
4543
4604
|
createAuthToken(seconds, method = undefined, url = undefined) {
|
|
4544
4605
|
// it may not work for v2
|
|
4545
4606
|
let uri = undefined;
|
package/js/src/coinex.js
CHANGED
|
@@ -4646,7 +4646,7 @@ export default class coinex extends Exchange {
|
|
|
4646
4646
|
* @method
|
|
4647
4647
|
* @name coinex#withdraw
|
|
4648
4648
|
* @description make a withdrawal
|
|
4649
|
-
* @see https://
|
|
4649
|
+
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
|
|
4650
4650
|
* @param {string} code unified currency code
|
|
4651
4651
|
* @param {float} amount the amount to withdraw
|
|
4652
4652
|
* @param {string} address the address to withdraw to
|
|
@@ -4659,37 +4659,44 @@ export default class coinex extends Exchange {
|
|
|
4659
4659
|
this.checkAddress(address);
|
|
4660
4660
|
await this.loadMarkets();
|
|
4661
4661
|
const currency = this.currency(code);
|
|
4662
|
-
const networkCode = this.
|
|
4662
|
+
const networkCode = this.safeStringUpper2(params, 'network', 'chain');
|
|
4663
4663
|
params = this.omit(params, 'network');
|
|
4664
4664
|
if (tag) {
|
|
4665
4665
|
address = address + ':' + tag;
|
|
4666
4666
|
}
|
|
4667
4667
|
const request = {
|
|
4668
|
-
'
|
|
4669
|
-
'
|
|
4670
|
-
'
|
|
4671
|
-
'transfer_method': 'onchain', // onchain, local
|
|
4668
|
+
'ccy': currency['id'],
|
|
4669
|
+
'to_address': address,
|
|
4670
|
+
'amount': this.numberToString(amount), // the actual amount without fees, https://www.coinex.com/fees
|
|
4672
4671
|
};
|
|
4673
4672
|
if (networkCode !== undefined) {
|
|
4674
|
-
request['
|
|
4673
|
+
request['chain'] = this.networkCodeToId(networkCode); // required for on-chain, not required for inter-user transfer
|
|
4675
4674
|
}
|
|
4676
|
-
const response = await this.
|
|
4675
|
+
const response = await this.v2PrivatePostAssetsWithdraw(this.extend(request, params));
|
|
4677
4676
|
//
|
|
4678
4677
|
// {
|
|
4679
4678
|
// "code": 0,
|
|
4680
4679
|
// "data": {
|
|
4681
|
-
// "
|
|
4682
|
-
// "
|
|
4683
|
-
// "
|
|
4684
|
-
// "
|
|
4685
|
-
// "
|
|
4680
|
+
// "withdraw_id": 31193755,
|
|
4681
|
+
// "created_at": 1716874165038,
|
|
4682
|
+
// "withdraw_method": "ON_CHAIN",
|
|
4683
|
+
// "ccy": "USDT",
|
|
4684
|
+
// "amount": "17.3",
|
|
4685
|
+
// "actual_amount": "15",
|
|
4686
|
+
// "chain": "TRC20",
|
|
4687
|
+
// "tx_fee": "2.3",
|
|
4688
|
+
// "fee_asset": "USDT",
|
|
4689
|
+
// "fee_amount": "2.3",
|
|
4690
|
+
// "to_address": "TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
|
|
4691
|
+
// "memo": "",
|
|
4692
|
+
// "tx_id": "",
|
|
4686
4693
|
// "confirmations": 0,
|
|
4687
|
-
// "
|
|
4688
|
-
// "
|
|
4689
|
-
// "
|
|
4690
|
-
// "
|
|
4694
|
+
// "explorer_address_url": "https://tronscan.org/#/address/TY5vq3MT6b5cQVAHWHtpGyPg1ERcQgi3UN",
|
|
4695
|
+
// "explorer_tx_url": "https://tronscan.org/#/transaction/",
|
|
4696
|
+
// "remark": "",
|
|
4697
|
+
// "status": "audit_required"
|
|
4691
4698
|
// },
|
|
4692
|
-
// "message": "
|
|
4699
|
+
// "message": "OK"
|
|
4693
4700
|
// }
|
|
4694
4701
|
//
|
|
4695
4702
|
const transaction = this.safeDict(response, 'data', {});
|
|
@@ -4800,7 +4807,7 @@ export default class coinex extends Exchange {
|
|
|
4800
4807
|
// "remark": ""
|
|
4801
4808
|
// }
|
|
4802
4809
|
//
|
|
4803
|
-
// fetchWithdrawals
|
|
4810
|
+
// fetchWithdrawals and withdraw
|
|
4804
4811
|
//
|
|
4805
4812
|
// {
|
|
4806
4813
|
// "withdraw_id": 259364,
|
package/js/src/kraken.js
CHANGED
|
@@ -989,7 +989,9 @@ export default class kraken extends Exchange {
|
|
|
989
989
|
request['interval'] = timeframe;
|
|
990
990
|
}
|
|
991
991
|
if (since !== undefined) {
|
|
992
|
-
|
|
992
|
+
const scaledSince = this.parseToInt(since / 1000);
|
|
993
|
+
const timeFrameInSeconds = parsedTimeframe * 60;
|
|
994
|
+
request['since'] = this.numberToString(scaledSince - timeFrameInSeconds); // expected to be in seconds
|
|
993
995
|
}
|
|
994
996
|
const response = await this.publicGetOHLC(this.extend(request, params));
|
|
995
997
|
//
|