ccxt 4.4.38 → 4.4.39
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 +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +73 -2
- package/dist/cjs/src/base/Exchange.js +26 -9
- package/dist/cjs/src/digifinex.js +58 -18
- package/dist/cjs/src/htx.js +154 -32
- package/dist/cjs/src/kucoin.js +1 -0
- package/dist/cjs/src/mexc.js +36 -25
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/woo.js +4 -4
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/digifinex.d.ts +1 -0
- package/js/src/abstract/mexc.d.ts +1 -0
- package/js/src/alpaca.d.ts +11 -1
- package/js/src/alpaca.js +73 -2
- package/js/src/base/Exchange.js +26 -9
- package/js/src/digifinex.d.ts +4 -2
- package/js/src/digifinex.js +58 -18
- package/js/src/htx.d.ts +5 -5
- package/js/src/htx.js +154 -32
- package/js/src/kucoin.js +1 -0
- package/js/src/mexc.d.ts +7 -7
- package/js/src/mexc.js +36 -25
- package/js/src/okx.d.ts +1 -0
- package/js/src/okx.js +1 -0
- package/js/src/pro/woo.js +1 -1
- package/js/src/woo.js +4 -4
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -200,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
200
200
|
|
|
201
201
|
//-----------------------------------------------------------------------------
|
|
202
202
|
// this is updated by vss.js when building
|
|
203
|
-
const version = '4.4.
|
|
203
|
+
const version = '4.4.39';
|
|
204
204
|
Exchange["default"].ccxtVersion = version;
|
|
205
205
|
const exchanges = {
|
|
206
206
|
'ace': ace,
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -34,7 +34,7 @@ class alpaca extends alpaca$1 {
|
|
|
34
34
|
'test': {
|
|
35
35
|
'broker': 'https://broker-api.sandbox.{hostname}',
|
|
36
36
|
'trader': 'https://paper-api.{hostname}',
|
|
37
|
-
'market': 'https://data.
|
|
37
|
+
'market': 'https://data.{hostname}',
|
|
38
38
|
},
|
|
39
39
|
'doc': 'https://alpaca.markets/docs/',
|
|
40
40
|
'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
|
|
@@ -54,7 +54,7 @@ class alpaca extends alpaca$1 {
|
|
|
54
54
|
'createStopOrder': true,
|
|
55
55
|
'createTriggerOrder': true,
|
|
56
56
|
'editOrder': true,
|
|
57
|
-
'fetchBalance':
|
|
57
|
+
'fetchBalance': true,
|
|
58
58
|
'fetchBidsAsks': false,
|
|
59
59
|
'fetchClosedOrders': true,
|
|
60
60
|
'fetchCurrencies': false,
|
|
@@ -1586,6 +1586,77 @@ class alpaca extends alpaca$1 {
|
|
|
1586
1586
|
};
|
|
1587
1587
|
return this.safeString(types, type, type);
|
|
1588
1588
|
}
|
|
1589
|
+
/**
|
|
1590
|
+
* @method
|
|
1591
|
+
* @name alpaca#fetchBalance
|
|
1592
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1593
|
+
* @see https://docs.alpaca.markets/reference/getaccount-1
|
|
1594
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1595
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1596
|
+
*/
|
|
1597
|
+
async fetchBalance(params = {}) {
|
|
1598
|
+
await this.loadMarkets();
|
|
1599
|
+
const response = await this.traderPrivateGetV2Account(params);
|
|
1600
|
+
//
|
|
1601
|
+
// {
|
|
1602
|
+
// "id": "43a01bde-4eb1-64fssc26adb5",
|
|
1603
|
+
// "admin_configurations": {
|
|
1604
|
+
// "allow_instant_ach": true,
|
|
1605
|
+
// "max_margin_multiplier": "4"
|
|
1606
|
+
// },
|
|
1607
|
+
// "user_configurations": {
|
|
1608
|
+
// "fractional_trading": true,
|
|
1609
|
+
// "max_margin_multiplier": "4"
|
|
1610
|
+
// },
|
|
1611
|
+
// "account_number": "744873727",
|
|
1612
|
+
// "status": "ACTIVE",
|
|
1613
|
+
// "crypto_status": "ACTIVE",
|
|
1614
|
+
// "currency": "USD",
|
|
1615
|
+
// "buying_power": "5.92",
|
|
1616
|
+
// "regt_buying_power": "5.92",
|
|
1617
|
+
// "daytrading_buying_power": "0",
|
|
1618
|
+
// "effective_buying_power": "5.92",
|
|
1619
|
+
// "non_marginable_buying_power": "5.92",
|
|
1620
|
+
// "bod_dtbp": "0",
|
|
1621
|
+
// "cash": "5.92",
|
|
1622
|
+
// "accrued_fees": "0",
|
|
1623
|
+
// "portfolio_value": "48.6",
|
|
1624
|
+
// "pattern_day_trader": false,
|
|
1625
|
+
// "trading_blocked": false,
|
|
1626
|
+
// "transfers_blocked": false,
|
|
1627
|
+
// "account_blocked": false,
|
|
1628
|
+
// "created_at": "2022-06-13T14:59:18.318096Z",
|
|
1629
|
+
// "trade_suspended_by_user": false,
|
|
1630
|
+
// "multiplier": "1",
|
|
1631
|
+
// "shorting_enabled": false,
|
|
1632
|
+
// "equity": "48.6",
|
|
1633
|
+
// "last_equity": "48.8014266",
|
|
1634
|
+
// "long_market_value": "42.68",
|
|
1635
|
+
// "short_market_value": "0",
|
|
1636
|
+
// "position_market_value": "42.68",
|
|
1637
|
+
// "initial_margin": "0",
|
|
1638
|
+
// "maintenance_margin": "0",
|
|
1639
|
+
// "last_maintenance_margin": "0",
|
|
1640
|
+
// "sma": "5.92",
|
|
1641
|
+
// "daytrade_count": 0,
|
|
1642
|
+
// "balance_asof": "2024-12-10",
|
|
1643
|
+
// "crypto_tier": 1,
|
|
1644
|
+
// "intraday_adjustments": "0",
|
|
1645
|
+
// "pending_reg_taf_fees": "0"
|
|
1646
|
+
// }
|
|
1647
|
+
//
|
|
1648
|
+
return this.parseBalance(response);
|
|
1649
|
+
}
|
|
1650
|
+
parseBalance(response) {
|
|
1651
|
+
const result = { 'info': response };
|
|
1652
|
+
const account = this.account();
|
|
1653
|
+
const currencyId = this.safeString(response, 'currency');
|
|
1654
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1655
|
+
account['free'] = this.safeString(response, 'cash');
|
|
1656
|
+
account['total'] = this.safeString(response, 'equity');
|
|
1657
|
+
result[code] = account;
|
|
1658
|
+
return this.safeBalance(result);
|
|
1659
|
+
}
|
|
1589
1660
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1590
1661
|
let endpoint = '/' + this.implodeParams(path, params);
|
|
1591
1662
|
let url = this.implodeHostname(this.urls['api'][api[0]]);
|
|
@@ -6813,8 +6813,10 @@ class Exchange {
|
|
|
6813
6813
|
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
6814
6814
|
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
6815
6815
|
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
6816
|
-
if (
|
|
6817
|
-
|
|
6816
|
+
if (symbol in this.ohlcvs) {
|
|
6817
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
6818
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
6819
|
+
}
|
|
6818
6820
|
}
|
|
6819
6821
|
}
|
|
6820
6822
|
}
|
|
@@ -6822,35 +6824,50 @@ class Exchange {
|
|
|
6822
6824
|
for (let i = 0; i < symbols.length; i++) {
|
|
6823
6825
|
const symbol = symbols[i];
|
|
6824
6826
|
if (topic === 'trades') {
|
|
6825
|
-
|
|
6827
|
+
if (symbol in this.trades) {
|
|
6828
|
+
delete this.trades[symbol];
|
|
6829
|
+
}
|
|
6826
6830
|
}
|
|
6827
6831
|
else if (topic === 'orderbook') {
|
|
6828
|
-
|
|
6832
|
+
if (symbol in this.orderbooks) {
|
|
6833
|
+
delete this.orderbooks[symbol];
|
|
6834
|
+
}
|
|
6829
6835
|
}
|
|
6830
6836
|
else if (topic === 'ticker') {
|
|
6831
|
-
|
|
6837
|
+
if (symbol in this.tickers) {
|
|
6838
|
+
delete this.tickers[symbol];
|
|
6839
|
+
}
|
|
6832
6840
|
}
|
|
6833
6841
|
}
|
|
6834
6842
|
}
|
|
6835
6843
|
else {
|
|
6836
6844
|
if (topic === 'myTrades') {
|
|
6837
6845
|
// don't reset this.myTrades directly here
|
|
6838
|
-
// because in c# we need to use a different object
|
|
6846
|
+
// because in c# we need to use a different object (thread-safe dict)
|
|
6839
6847
|
const keys = Object.keys(this.myTrades);
|
|
6840
6848
|
for (let i = 0; i < keys.length; i++) {
|
|
6841
|
-
|
|
6849
|
+
const key = keys[i];
|
|
6850
|
+
if (key in this.myTrades) {
|
|
6851
|
+
delete this.myTrades[key];
|
|
6852
|
+
}
|
|
6842
6853
|
}
|
|
6843
6854
|
}
|
|
6844
6855
|
else if (topic === 'orders') {
|
|
6845
6856
|
const orderSymbols = Object.keys(this.orders);
|
|
6846
6857
|
for (let i = 0; i < orderSymbols.length; i++) {
|
|
6847
|
-
|
|
6858
|
+
const orderSymbol = orderSymbols[i];
|
|
6859
|
+
if (orderSymbol in this.orders) {
|
|
6860
|
+
delete this.orders[orderSymbol];
|
|
6861
|
+
}
|
|
6848
6862
|
}
|
|
6849
6863
|
}
|
|
6850
6864
|
else if (topic === 'ticker') {
|
|
6851
6865
|
const tickerSymbols = Object.keys(this.tickers);
|
|
6852
6866
|
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
6853
|
-
|
|
6867
|
+
const tickerSymbol = tickerSymbols[i];
|
|
6868
|
+
if (tickerSymbol in this.tickers) {
|
|
6869
|
+
delete this.tickers[tickerSymbol];
|
|
6870
|
+
}
|
|
6854
6871
|
}
|
|
6855
6872
|
}
|
|
6856
6873
|
}
|
|
@@ -211,6 +211,7 @@ class digifinex extends digifinex$1 {
|
|
|
211
211
|
'trade/order_info',
|
|
212
212
|
],
|
|
213
213
|
'post': [
|
|
214
|
+
'account/transfer',
|
|
214
215
|
'account/leverage',
|
|
215
216
|
'account/position_mode',
|
|
216
217
|
'account/position_margin',
|
|
@@ -2939,12 +2940,23 @@ class digifinex extends digifinex$1 {
|
|
|
2939
2940
|
}
|
|
2940
2941
|
parseTransfer(transfer, currency = undefined) {
|
|
2941
2942
|
//
|
|
2942
|
-
// transfer
|
|
2943
|
+
// transfer between spot, margin and OTC
|
|
2943
2944
|
//
|
|
2944
2945
|
// {
|
|
2945
2946
|
// "code": 0
|
|
2946
2947
|
// }
|
|
2947
2948
|
//
|
|
2949
|
+
// transfer between spot and swap
|
|
2950
|
+
//
|
|
2951
|
+
// {
|
|
2952
|
+
// "code": 0,
|
|
2953
|
+
// "data": {
|
|
2954
|
+
// "type": 2,
|
|
2955
|
+
// "currency": "USDT",
|
|
2956
|
+
// "transfer_amount": "5"
|
|
2957
|
+
// }
|
|
2958
|
+
// }
|
|
2959
|
+
//
|
|
2948
2960
|
// fetchTransfers
|
|
2949
2961
|
//
|
|
2950
2962
|
// {
|
|
@@ -2957,7 +2969,8 @@ class digifinex extends digifinex$1 {
|
|
|
2957
2969
|
//
|
|
2958
2970
|
let fromAccount = undefined;
|
|
2959
2971
|
let toAccount = undefined;
|
|
2960
|
-
const
|
|
2972
|
+
const data = this.safeDict(transfer, 'data', transfer);
|
|
2973
|
+
const type = this.safeInteger(data, 'type');
|
|
2961
2974
|
if (type === 1) {
|
|
2962
2975
|
fromAccount = 'spot';
|
|
2963
2976
|
toAccount = 'swap';
|
|
@@ -2972,8 +2985,8 @@ class digifinex extends digifinex$1 {
|
|
|
2972
2985
|
'id': this.safeString(transfer, 'transfer_id'),
|
|
2973
2986
|
'timestamp': timestamp,
|
|
2974
2987
|
'datetime': this.iso8601(timestamp),
|
|
2975
|
-
'currency': this.safeCurrencyCode(this.safeString(
|
|
2976
|
-
'amount': this.
|
|
2988
|
+
'currency': this.safeCurrencyCode(this.safeString(data, 'currency'), currency),
|
|
2989
|
+
'amount': this.safeNumber2(data, 'amount', 'transfer_amount'),
|
|
2977
2990
|
'fromAccount': fromAccount,
|
|
2978
2991
|
'toAccount': toAccount,
|
|
2979
2992
|
'status': this.parseTransferStatus(this.safeString(transfer, 'code')),
|
|
@@ -2983,31 +2996,58 @@ class digifinex extends digifinex$1 {
|
|
|
2983
2996
|
* @method
|
|
2984
2997
|
* @name digifinex#transfer
|
|
2985
2998
|
* @description transfer currency internally between wallets on the same account
|
|
2999
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
|
|
3000
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
|
|
2986
3001
|
* @param {string} code unified currency code
|
|
2987
3002
|
* @param {float} amount amount to transfer
|
|
2988
|
-
* @param {string} fromAccount account to transfer from
|
|
2989
|
-
* @param {string} toAccount account to transfer to
|
|
3003
|
+
* @param {string} fromAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer from
|
|
3004
|
+
* @param {string} toAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer to
|
|
2990
3005
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2991
3006
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
2992
3007
|
*/
|
|
2993
3008
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2994
3009
|
await this.loadMarkets();
|
|
2995
3010
|
const currency = this.currency(code);
|
|
3011
|
+
const currencyId = currency['id'];
|
|
2996
3012
|
const accountsByType = this.safeValue(this.options, 'accountsByType', {});
|
|
2997
3013
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
2998
3014
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
2999
|
-
const request = {
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3015
|
+
const request = {};
|
|
3016
|
+
const fromSwap = (fromAccount === 'swap');
|
|
3017
|
+
const toSwap = (toAccount === 'swap');
|
|
3018
|
+
let response = undefined;
|
|
3019
|
+
const amountString = this.currencyToPrecision(code, amount);
|
|
3020
|
+
if (fromSwap || toSwap) {
|
|
3021
|
+
if ((fromId !== '1') && (toId !== '1')) {
|
|
3022
|
+
throw new errors.ExchangeError(this.id + ' transfer() supports transferring between spot and swap, spot and margin, spot and OTC only');
|
|
3023
|
+
}
|
|
3024
|
+
request['type'] = toSwap ? 1 : 2; // 1 = spot to swap, 2 = swap to spot
|
|
3025
|
+
request['currency'] = currencyId;
|
|
3026
|
+
request['transfer_amount'] = amountString;
|
|
3027
|
+
//
|
|
3028
|
+
// {
|
|
3029
|
+
// "code": 0,
|
|
3030
|
+
// "data": {
|
|
3031
|
+
// "type": 2,
|
|
3032
|
+
// "currency": "USDT",
|
|
3033
|
+
// "transfer_amount": "5"
|
|
3034
|
+
// }
|
|
3035
|
+
// }
|
|
3036
|
+
//
|
|
3037
|
+
response = await this.privateSwapPostAccountTransfer(this.extend(request, params));
|
|
3038
|
+
}
|
|
3039
|
+
else {
|
|
3040
|
+
request['currency_mark'] = currencyId;
|
|
3041
|
+
request['num'] = amountString;
|
|
3042
|
+
request['from'] = fromId; // 1 = SPOT, 2 = MARGIN, 3 = OTC
|
|
3043
|
+
request['to'] = toId; // 1 = SPOT, 2 = MARGIN, 3 = OTC
|
|
3044
|
+
//
|
|
3045
|
+
// {
|
|
3046
|
+
// "code": 0
|
|
3047
|
+
// }
|
|
3048
|
+
//
|
|
3049
|
+
response = await this.privateSpotPostTransfer(this.extend(request, params));
|
|
3050
|
+
}
|
|
3011
3051
|
return this.parseTransfer(response, currency);
|
|
3012
3052
|
}
|
|
3013
3053
|
/**
|