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/js/src/alpaca.js
CHANGED
|
@@ -37,7 +37,7 @@ export default class alpaca extends Exchange {
|
|
|
37
37
|
'test': {
|
|
38
38
|
'broker': 'https://broker-api.sandbox.{hostname}',
|
|
39
39
|
'trader': 'https://paper-api.{hostname}',
|
|
40
|
-
'market': 'https://data.
|
|
40
|
+
'market': 'https://data.{hostname}',
|
|
41
41
|
},
|
|
42
42
|
'doc': 'https://alpaca.markets/docs/',
|
|
43
43
|
'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
|
|
@@ -57,7 +57,7 @@ export default class alpaca extends Exchange {
|
|
|
57
57
|
'createStopOrder': true,
|
|
58
58
|
'createTriggerOrder': true,
|
|
59
59
|
'editOrder': true,
|
|
60
|
-
'fetchBalance':
|
|
60
|
+
'fetchBalance': true,
|
|
61
61
|
'fetchBidsAsks': false,
|
|
62
62
|
'fetchClosedOrders': true,
|
|
63
63
|
'fetchCurrencies': false,
|
|
@@ -1589,6 +1589,77 @@ export default class alpaca extends Exchange {
|
|
|
1589
1589
|
};
|
|
1590
1590
|
return this.safeString(types, type, type);
|
|
1591
1591
|
}
|
|
1592
|
+
/**
|
|
1593
|
+
* @method
|
|
1594
|
+
* @name alpaca#fetchBalance
|
|
1595
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1596
|
+
* @see https://docs.alpaca.markets/reference/getaccount-1
|
|
1597
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1598
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1599
|
+
*/
|
|
1600
|
+
async fetchBalance(params = {}) {
|
|
1601
|
+
await this.loadMarkets();
|
|
1602
|
+
const response = await this.traderPrivateGetV2Account(params);
|
|
1603
|
+
//
|
|
1604
|
+
// {
|
|
1605
|
+
// "id": "43a01bde-4eb1-64fssc26adb5",
|
|
1606
|
+
// "admin_configurations": {
|
|
1607
|
+
// "allow_instant_ach": true,
|
|
1608
|
+
// "max_margin_multiplier": "4"
|
|
1609
|
+
// },
|
|
1610
|
+
// "user_configurations": {
|
|
1611
|
+
// "fractional_trading": true,
|
|
1612
|
+
// "max_margin_multiplier": "4"
|
|
1613
|
+
// },
|
|
1614
|
+
// "account_number": "744873727",
|
|
1615
|
+
// "status": "ACTIVE",
|
|
1616
|
+
// "crypto_status": "ACTIVE",
|
|
1617
|
+
// "currency": "USD",
|
|
1618
|
+
// "buying_power": "5.92",
|
|
1619
|
+
// "regt_buying_power": "5.92",
|
|
1620
|
+
// "daytrading_buying_power": "0",
|
|
1621
|
+
// "effective_buying_power": "5.92",
|
|
1622
|
+
// "non_marginable_buying_power": "5.92",
|
|
1623
|
+
// "bod_dtbp": "0",
|
|
1624
|
+
// "cash": "5.92",
|
|
1625
|
+
// "accrued_fees": "0",
|
|
1626
|
+
// "portfolio_value": "48.6",
|
|
1627
|
+
// "pattern_day_trader": false,
|
|
1628
|
+
// "trading_blocked": false,
|
|
1629
|
+
// "transfers_blocked": false,
|
|
1630
|
+
// "account_blocked": false,
|
|
1631
|
+
// "created_at": "2022-06-13T14:59:18.318096Z",
|
|
1632
|
+
// "trade_suspended_by_user": false,
|
|
1633
|
+
// "multiplier": "1",
|
|
1634
|
+
// "shorting_enabled": false,
|
|
1635
|
+
// "equity": "48.6",
|
|
1636
|
+
// "last_equity": "48.8014266",
|
|
1637
|
+
// "long_market_value": "42.68",
|
|
1638
|
+
// "short_market_value": "0",
|
|
1639
|
+
// "position_market_value": "42.68",
|
|
1640
|
+
// "initial_margin": "0",
|
|
1641
|
+
// "maintenance_margin": "0",
|
|
1642
|
+
// "last_maintenance_margin": "0",
|
|
1643
|
+
// "sma": "5.92",
|
|
1644
|
+
// "daytrade_count": 0,
|
|
1645
|
+
// "balance_asof": "2024-12-10",
|
|
1646
|
+
// "crypto_tier": 1,
|
|
1647
|
+
// "intraday_adjustments": "0",
|
|
1648
|
+
// "pending_reg_taf_fees": "0"
|
|
1649
|
+
// }
|
|
1650
|
+
//
|
|
1651
|
+
return this.parseBalance(response);
|
|
1652
|
+
}
|
|
1653
|
+
parseBalance(response) {
|
|
1654
|
+
const result = { 'info': response };
|
|
1655
|
+
const account = this.account();
|
|
1656
|
+
const currencyId = this.safeString(response, 'currency');
|
|
1657
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1658
|
+
account['free'] = this.safeString(response, 'cash');
|
|
1659
|
+
account['total'] = this.safeString(response, 'equity');
|
|
1660
|
+
result[code] = account;
|
|
1661
|
+
return this.safeBalance(result);
|
|
1662
|
+
}
|
|
1592
1663
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1593
1664
|
let endpoint = '/' + this.implodeParams(path, params);
|
|
1594
1665
|
let url = this.implodeHostname(this.urls['api'][api[0]]);
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -6796,8 +6796,10 @@ export default class Exchange {
|
|
|
6796
6796
|
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
6797
6797
|
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
6798
6798
|
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
6799
|
-
if (
|
|
6800
|
-
|
|
6799
|
+
if (symbol in this.ohlcvs) {
|
|
6800
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
6801
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
6802
|
+
}
|
|
6801
6803
|
}
|
|
6802
6804
|
}
|
|
6803
6805
|
}
|
|
@@ -6805,35 +6807,50 @@ export default class Exchange {
|
|
|
6805
6807
|
for (let i = 0; i < symbols.length; i++) {
|
|
6806
6808
|
const symbol = symbols[i];
|
|
6807
6809
|
if (topic === 'trades') {
|
|
6808
|
-
|
|
6810
|
+
if (symbol in this.trades) {
|
|
6811
|
+
delete this.trades[symbol];
|
|
6812
|
+
}
|
|
6809
6813
|
}
|
|
6810
6814
|
else if (topic === 'orderbook') {
|
|
6811
|
-
|
|
6815
|
+
if (symbol in this.orderbooks) {
|
|
6816
|
+
delete this.orderbooks[symbol];
|
|
6817
|
+
}
|
|
6812
6818
|
}
|
|
6813
6819
|
else if (topic === 'ticker') {
|
|
6814
|
-
|
|
6820
|
+
if (symbol in this.tickers) {
|
|
6821
|
+
delete this.tickers[symbol];
|
|
6822
|
+
}
|
|
6815
6823
|
}
|
|
6816
6824
|
}
|
|
6817
6825
|
}
|
|
6818
6826
|
else {
|
|
6819
6827
|
if (topic === 'myTrades') {
|
|
6820
6828
|
// don't reset this.myTrades directly here
|
|
6821
|
-
// because in c# we need to use a different object
|
|
6829
|
+
// because in c# we need to use a different object (thread-safe dict)
|
|
6822
6830
|
const keys = Object.keys(this.myTrades);
|
|
6823
6831
|
for (let i = 0; i < keys.length; i++) {
|
|
6824
|
-
|
|
6832
|
+
const key = keys[i];
|
|
6833
|
+
if (key in this.myTrades) {
|
|
6834
|
+
delete this.myTrades[key];
|
|
6835
|
+
}
|
|
6825
6836
|
}
|
|
6826
6837
|
}
|
|
6827
6838
|
else if (topic === 'orders') {
|
|
6828
6839
|
const orderSymbols = Object.keys(this.orders);
|
|
6829
6840
|
for (let i = 0; i < orderSymbols.length; i++) {
|
|
6830
|
-
|
|
6841
|
+
const orderSymbol = orderSymbols[i];
|
|
6842
|
+
if (orderSymbol in this.orders) {
|
|
6843
|
+
delete this.orders[orderSymbol];
|
|
6844
|
+
}
|
|
6831
6845
|
}
|
|
6832
6846
|
}
|
|
6833
6847
|
else if (topic === 'ticker') {
|
|
6834
6848
|
const tickerSymbols = Object.keys(this.tickers);
|
|
6835
6849
|
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
6836
|
-
|
|
6850
|
+
const tickerSymbol = tickerSymbols[i];
|
|
6851
|
+
if (tickerSymbol in this.tickers) {
|
|
6852
|
+
delete this.tickers[tickerSymbol];
|
|
6853
|
+
}
|
|
6837
6854
|
}
|
|
6838
6855
|
}
|
|
6839
6856
|
}
|
package/js/src/digifinex.d.ts
CHANGED
|
@@ -297,10 +297,12 @@ export default class digifinex extends Exchange {
|
|
|
297
297
|
* @method
|
|
298
298
|
* @name digifinex#transfer
|
|
299
299
|
* @description transfer currency internally between wallets on the same account
|
|
300
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
|
|
301
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
|
|
300
302
|
* @param {string} code unified currency code
|
|
301
303
|
* @param {float} amount amount to transfer
|
|
302
|
-
* @param {string} fromAccount account to transfer from
|
|
303
|
-
* @param {string} toAccount account to transfer to
|
|
304
|
+
* @param {string} fromAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer from
|
|
305
|
+
* @param {string} toAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer to
|
|
304
306
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
305
307
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
306
308
|
*/
|
package/js/src/digifinex.js
CHANGED
|
@@ -214,6 +214,7 @@ export default class digifinex extends Exchange {
|
|
|
214
214
|
'trade/order_info',
|
|
215
215
|
],
|
|
216
216
|
'post': [
|
|
217
|
+
'account/transfer',
|
|
217
218
|
'account/leverage',
|
|
218
219
|
'account/position_mode',
|
|
219
220
|
'account/position_margin',
|
|
@@ -2942,12 +2943,23 @@ export default class digifinex extends Exchange {
|
|
|
2942
2943
|
}
|
|
2943
2944
|
parseTransfer(transfer, currency = undefined) {
|
|
2944
2945
|
//
|
|
2945
|
-
// transfer
|
|
2946
|
+
// transfer between spot, margin and OTC
|
|
2946
2947
|
//
|
|
2947
2948
|
// {
|
|
2948
2949
|
// "code": 0
|
|
2949
2950
|
// }
|
|
2950
2951
|
//
|
|
2952
|
+
// transfer between spot and swap
|
|
2953
|
+
//
|
|
2954
|
+
// {
|
|
2955
|
+
// "code": 0,
|
|
2956
|
+
// "data": {
|
|
2957
|
+
// "type": 2,
|
|
2958
|
+
// "currency": "USDT",
|
|
2959
|
+
// "transfer_amount": "5"
|
|
2960
|
+
// }
|
|
2961
|
+
// }
|
|
2962
|
+
//
|
|
2951
2963
|
// fetchTransfers
|
|
2952
2964
|
//
|
|
2953
2965
|
// {
|
|
@@ -2960,7 +2972,8 @@ export default class digifinex extends Exchange {
|
|
|
2960
2972
|
//
|
|
2961
2973
|
let fromAccount = undefined;
|
|
2962
2974
|
let toAccount = undefined;
|
|
2963
|
-
const
|
|
2975
|
+
const data = this.safeDict(transfer, 'data', transfer);
|
|
2976
|
+
const type = this.safeInteger(data, 'type');
|
|
2964
2977
|
if (type === 1) {
|
|
2965
2978
|
fromAccount = 'spot';
|
|
2966
2979
|
toAccount = 'swap';
|
|
@@ -2975,8 +2988,8 @@ export default class digifinex extends Exchange {
|
|
|
2975
2988
|
'id': this.safeString(transfer, 'transfer_id'),
|
|
2976
2989
|
'timestamp': timestamp,
|
|
2977
2990
|
'datetime': this.iso8601(timestamp),
|
|
2978
|
-
'currency': this.safeCurrencyCode(this.safeString(
|
|
2979
|
-
'amount': this.
|
|
2991
|
+
'currency': this.safeCurrencyCode(this.safeString(data, 'currency'), currency),
|
|
2992
|
+
'amount': this.safeNumber2(data, 'amount', 'transfer_amount'),
|
|
2980
2993
|
'fromAccount': fromAccount,
|
|
2981
2994
|
'toAccount': toAccount,
|
|
2982
2995
|
'status': this.parseTransferStatus(this.safeString(transfer, 'code')),
|
|
@@ -2986,31 +2999,58 @@ export default class digifinex extends Exchange {
|
|
|
2986
2999
|
* @method
|
|
2987
3000
|
* @name digifinex#transfer
|
|
2988
3001
|
* @description transfer currency internally between wallets on the same account
|
|
3002
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
|
|
3003
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
|
|
2989
3004
|
* @param {string} code unified currency code
|
|
2990
3005
|
* @param {float} amount amount to transfer
|
|
2991
|
-
* @param {string} fromAccount account to transfer from
|
|
2992
|
-
* @param {string} toAccount account to transfer to
|
|
3006
|
+
* @param {string} fromAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer from
|
|
3007
|
+
* @param {string} toAccount 'spot', 'swap', 'margin', 'OTC' - account to transfer to
|
|
2993
3008
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2994
3009
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
2995
3010
|
*/
|
|
2996
3011
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2997
3012
|
await this.loadMarkets();
|
|
2998
3013
|
const currency = this.currency(code);
|
|
3014
|
+
const currencyId = currency['id'];
|
|
2999
3015
|
const accountsByType = this.safeValue(this.options, 'accountsByType', {});
|
|
3000
3016
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
3001
3017
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
3002
|
-
const request = {
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3018
|
+
const request = {};
|
|
3019
|
+
const fromSwap = (fromAccount === 'swap');
|
|
3020
|
+
const toSwap = (toAccount === 'swap');
|
|
3021
|
+
let response = undefined;
|
|
3022
|
+
const amountString = this.currencyToPrecision(code, amount);
|
|
3023
|
+
if (fromSwap || toSwap) {
|
|
3024
|
+
if ((fromId !== '1') && (toId !== '1')) {
|
|
3025
|
+
throw new ExchangeError(this.id + ' transfer() supports transferring between spot and swap, spot and margin, spot and OTC only');
|
|
3026
|
+
}
|
|
3027
|
+
request['type'] = toSwap ? 1 : 2; // 1 = spot to swap, 2 = swap to spot
|
|
3028
|
+
request['currency'] = currencyId;
|
|
3029
|
+
request['transfer_amount'] = amountString;
|
|
3030
|
+
//
|
|
3031
|
+
// {
|
|
3032
|
+
// "code": 0,
|
|
3033
|
+
// "data": {
|
|
3034
|
+
// "type": 2,
|
|
3035
|
+
// "currency": "USDT",
|
|
3036
|
+
// "transfer_amount": "5"
|
|
3037
|
+
// }
|
|
3038
|
+
// }
|
|
3039
|
+
//
|
|
3040
|
+
response = await this.privateSwapPostAccountTransfer(this.extend(request, params));
|
|
3041
|
+
}
|
|
3042
|
+
else {
|
|
3043
|
+
request['currency_mark'] = currencyId;
|
|
3044
|
+
request['num'] = amountString;
|
|
3045
|
+
request['from'] = fromId; // 1 = SPOT, 2 = MARGIN, 3 = OTC
|
|
3046
|
+
request['to'] = toId; // 1 = SPOT, 2 = MARGIN, 3 = OTC
|
|
3047
|
+
//
|
|
3048
|
+
// {
|
|
3049
|
+
// "code": 0
|
|
3050
|
+
// }
|
|
3051
|
+
//
|
|
3052
|
+
response = await this.privateSpotPostTransfer(this.extend(request, params));
|
|
3053
|
+
}
|
|
3014
3054
|
return this.parseTransfer(response, currency);
|
|
3015
3055
|
}
|
|
3016
3056
|
/**
|
package/js/src/htx.d.ts
CHANGED
|
@@ -332,7 +332,7 @@ export default class htx extends Exchange {
|
|
|
332
332
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
333
333
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
334
334
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
335
|
-
* @param {bool} [params.
|
|
335
|
+
* @param {bool} [params.trigger] *contract only* if the orders are trigger trigger orders or not
|
|
336
336
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
337
337
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
338
338
|
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
@@ -369,7 +369,7 @@ export default class htx extends Exchange {
|
|
|
369
369
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
370
370
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
371
371
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
372
|
-
* @param {bool} [params.
|
|
372
|
+
* @param {bool} [params.trigger] *contract only* if the orders are trigger trigger orders or not
|
|
373
373
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
374
374
|
* @param {boolean} [params.trailing] *contract only* set to true if you want to fetch trailing stop orders
|
|
375
375
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -478,7 +478,7 @@ export default class htx extends Exchange {
|
|
|
478
478
|
* @param {string} id order id
|
|
479
479
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
480
480
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
481
|
-
* @param {boolean} [params.
|
|
481
|
+
* @param {boolean} [params.trigger] *contract only* if the order is a trigger trigger order or not
|
|
482
482
|
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the order is a stop-loss or take-profit order
|
|
483
483
|
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel a trailing order
|
|
484
484
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -491,7 +491,7 @@ export default class htx extends Exchange {
|
|
|
491
491
|
* @param {string[]} ids order ids
|
|
492
492
|
* @param {string} symbol unified market symbol, default is undefined
|
|
493
493
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
494
|
-
* @param {bool} [params.
|
|
494
|
+
* @param {bool} [params.trigger] *contract only* if the orders are trigger trigger orders or not
|
|
495
495
|
* @param {bool} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
496
496
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
497
497
|
*/
|
|
@@ -503,7 +503,7 @@ export default class htx extends Exchange {
|
|
|
503
503
|
* @description cancel all open orders
|
|
504
504
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
505
505
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
506
|
-
* @param {boolean} [params.
|
|
506
|
+
* @param {boolean} [params.trigger] *contract only* if the orders are trigger trigger orders or not
|
|
507
507
|
* @param {boolean} [params.stopLossTakeProfit] *contract only* if the orders are stop-loss or take-profit orders
|
|
508
508
|
* @param {boolean} [params.trailing] *contract only* set to true if you want to cancel all trailing orders
|
|
509
509
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|