ccxt 4.4.25 → 4.4.27
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 +133 -132
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -1
- package/dist/cjs/src/alpaca.js +451 -16
- package/dist/cjs/src/ascendex.js +1 -1
- package/dist/cjs/src/base/Exchange.js +32 -1
- package/dist/cjs/src/bequant.js +1 -1
- package/dist/cjs/src/bigone.js +1 -1
- package/dist/cjs/src/binance.js +3 -4
- package/dist/cjs/src/binancecoinm.js +1 -1
- package/dist/cjs/src/binanceus.js +1 -1
- package/dist/cjs/src/binanceusdm.js +1 -1
- package/dist/cjs/src/bingx.js +32 -37
- package/dist/cjs/src/bit2c.js +1 -1
- package/dist/cjs/src/bitbank.js +1 -1
- package/dist/cjs/src/bitbns.js +1 -1
- package/dist/cjs/src/bitfinex.js +1 -1
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/bitflyer.js +1 -1
- package/dist/cjs/src/bitget.js +3 -3
- package/dist/cjs/src/bithumb.js +1 -1
- package/dist/cjs/src/bitmart.js +4 -4
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/bitopro.js +1 -1
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bitso.js +1 -1
- package/dist/cjs/src/bitstamp.js +1 -1
- package/dist/cjs/src/bitteam.js +1 -1
- package/dist/cjs/src/bitvavo.js +1 -1
- package/dist/cjs/src/bl3p.js +1 -1
- package/dist/cjs/src/blockchaincom.js +1 -1
- package/dist/cjs/src/blofin.js +1 -1
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/btcbox.js +1 -1
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/btcturk.js +1 -1
- package/dist/cjs/src/bybit.js +8 -15
- package/dist/cjs/src/cex.js +40 -0
- package/dist/cjs/src/coinbase.js +97 -11
- package/dist/cjs/src/coinex.js +3 -5
- package/dist/cjs/src/digifinex.js +2 -2
- package/dist/cjs/src/exmo.js +1 -0
- package/dist/cjs/src/gate.js +25 -19
- package/dist/cjs/src/htx.js +2 -3
- package/dist/cjs/src/hyperliquid.js +35 -5
- package/dist/cjs/src/kucoin.js +2 -2
- package/dist/cjs/src/lbank.js +100 -1
- package/dist/cjs/src/okx.js +3 -2
- package/dist/cjs/src/phemex.js +4 -2
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/exmo.js +216 -3
- package/dist/cjs/src/pro/lbank.js +9 -4
- package/dist/cjs/src/wavesexchange.js +13 -2
- package/dist/cjs/src/whitebit.js +2 -2
- package/dist/cjs/src/xt.js +39 -27
- package/examples/js/cli.js +23 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/alpaca.d.ts +3 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/phemex.d.ts +1 -0
- package/js/src/ace.js +1 -1
- package/js/src/alpaca.d.ts +14 -1
- package/js/src/alpaca.js +452 -17
- package/js/src/ascendex.js +1 -1
- package/js/src/base/Exchange.d.ts +13 -6
- package/js/src/base/Exchange.js +32 -1
- package/js/src/base/types.d.ts +3 -3
- package/js/src/bequant.js +1 -1
- package/js/src/bigone.js +1 -1
- package/js/src/binance.d.ts +3 -14
- package/js/src/binance.js +3 -4
- package/js/src/binancecoinm.js +1 -1
- package/js/src/binanceus.js +1 -1
- package/js/src/binanceusdm.js +1 -1
- package/js/src/bingx.js +32 -37
- package/js/src/bit2c.js +1 -1
- package/js/src/bitbank.js +1 -1
- package/js/src/bitbns.js +1 -1
- package/js/src/bitfinex.js +1 -1
- package/js/src/bitfinex2.js +1 -1
- package/js/src/bitflyer.js +1 -1
- package/js/src/bitget.d.ts +3 -13
- package/js/src/bitget.js +3 -3
- package/js/src/bithumb.js +1 -1
- package/js/src/bitmart.d.ts +3 -13
- package/js/src/bitmart.js +4 -4
- package/js/src/bitmex.js +1 -1
- package/js/src/bitopro.js +1 -1
- package/js/src/bitrue.js +1 -1
- package/js/src/bitso.js +1 -1
- package/js/src/bitstamp.js +1 -1
- package/js/src/bitteam.js +1 -1
- package/js/src/bitvavo.js +1 -1
- package/js/src/bl3p.js +1 -1
- package/js/src/blockchaincom.js +1 -1
- package/js/src/blofin.js +1 -1
- package/js/src/btcalpha.js +1 -1
- package/js/src/btcbox.js +1 -1
- package/js/src/btcmarkets.js +1 -1
- package/js/src/btcturk.js +1 -1
- package/js/src/bybit.d.ts +3 -14
- package/js/src/bybit.js +8 -15
- package/js/src/cex.d.ts +2 -0
- package/js/src/cex.js +40 -0
- package/js/src/coinbase.d.ts +1 -0
- package/js/src/coinbase.js +97 -11
- package/js/src/coinex.d.ts +3 -15
- package/js/src/coinex.js +3 -5
- package/js/src/digifinex.d.ts +3 -13
- package/js/src/digifinex.js +2 -2
- package/js/src/exmo.js +1 -0
- package/js/src/gate.d.ts +3 -13
- package/js/src/gate.js +25 -19
- package/js/src/htx.d.ts +3 -14
- package/js/src/htx.js +2 -3
- package/js/src/hyperliquid.d.ts +1 -0
- package/js/src/hyperliquid.js +35 -5
- package/js/src/kucoin.d.ts +3 -13
- package/js/src/kucoin.js +2 -2
- package/js/src/lbank.d.ts +4 -1
- package/js/src/lbank.js +100 -1
- package/js/src/okx.d.ts +3 -13
- package/js/src/okx.js +3 -2
- package/js/src/phemex.js +4 -2
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/exmo.d.ts +5 -1
- package/js/src/pro/exmo.js +216 -3
- package/js/src/pro/lbank.js +9 -4
- package/js/src/wavesexchange.js +13 -2
- package/js/src/whitebit.d.ts +3 -13
- package/js/src/whitebit.js +2 -2
- package/js/src/woo.d.ts +1 -1
- package/js/src/xt.js +39 -27
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -197,7 +197,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
197
197
|
|
|
198
198
|
//-----------------------------------------------------------------------------
|
|
199
199
|
// this is updated by vss.js when building
|
|
200
|
-
const version = '4.4.
|
|
200
|
+
const version = '4.4.27';
|
|
201
201
|
Exchange["default"].ccxtVersion = version;
|
|
202
202
|
const exchanges = {
|
|
203
203
|
'ace': ace,
|
package/dist/cjs/src/ace.js
CHANGED
|
@@ -103,7 +103,7 @@ class ace extends ace$1 {
|
|
|
103
103
|
'1M': 31,
|
|
104
104
|
},
|
|
105
105
|
'urls': {
|
|
106
|
-
'logo': 'https://
|
|
106
|
+
'logo': 'https://github.com/user-attachments/assets/115f1e4a-0fd0-4b76-85d5-a49ebf64d1c8',
|
|
107
107
|
'api': {
|
|
108
108
|
'public': 'https://ace.io/polarisex',
|
|
109
109
|
'private': 'https://ace.io/polarisex/open',
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -23,7 +23,7 @@ class alpaca extends alpaca$1 {
|
|
|
23
23
|
'hostname': 'alpaca.markets',
|
|
24
24
|
'pro': true,
|
|
25
25
|
'urls': {
|
|
26
|
-
'logo': 'https://
|
|
26
|
+
'logo': 'https://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1b',
|
|
27
27
|
'www': 'https://alpaca.markets',
|
|
28
28
|
'api': {
|
|
29
29
|
'broker': 'https://broker-api.{hostname}',
|
|
@@ -54,10 +54,10 @@ class alpaca extends alpaca$1 {
|
|
|
54
54
|
'fetchBidsAsks': false,
|
|
55
55
|
'fetchClosedOrders': true,
|
|
56
56
|
'fetchCurrencies': false,
|
|
57
|
-
'fetchDepositAddress':
|
|
57
|
+
'fetchDepositAddress': true,
|
|
58
58
|
'fetchDepositAddressesByNetwork': false,
|
|
59
|
-
'fetchDeposits':
|
|
60
|
-
'fetchDepositsWithdrawals':
|
|
59
|
+
'fetchDeposits': true,
|
|
60
|
+
'fetchDepositsWithdrawals': true,
|
|
61
61
|
'fetchFundingHistory': false,
|
|
62
62
|
'fetchFundingRate': false,
|
|
63
63
|
'fetchFundingRateHistory': false,
|
|
@@ -65,7 +65,7 @@ class alpaca extends alpaca$1 {
|
|
|
65
65
|
'fetchL1OrderBook': true,
|
|
66
66
|
'fetchL2OrderBook': false,
|
|
67
67
|
'fetchMarkets': true,
|
|
68
|
-
'fetchMyTrades':
|
|
68
|
+
'fetchMyTrades': true,
|
|
69
69
|
'fetchOHLCV': true,
|
|
70
70
|
'fetchOpenOrder': false,
|
|
71
71
|
'fetchOpenOrders': true,
|
|
@@ -80,8 +80,8 @@ class alpaca extends alpaca$1 {
|
|
|
80
80
|
'fetchPositionsHistory': false,
|
|
81
81
|
'fetchPositionsRisk': false,
|
|
82
82
|
'fetchStatus': false,
|
|
83
|
-
'fetchTicker':
|
|
84
|
-
'fetchTickers':
|
|
83
|
+
'fetchTicker': true,
|
|
84
|
+
'fetchTickers': true,
|
|
85
85
|
'fetchTime': true,
|
|
86
86
|
'fetchTrades': true,
|
|
87
87
|
'fetchTradingFee': false,
|
|
@@ -89,12 +89,12 @@ class alpaca extends alpaca$1 {
|
|
|
89
89
|
'fetchTransactionFees': false,
|
|
90
90
|
'fetchTransactions': false,
|
|
91
91
|
'fetchTransfers': false,
|
|
92
|
-
'fetchWithdrawals':
|
|
92
|
+
'fetchWithdrawals': true,
|
|
93
93
|
'sandbox': true,
|
|
94
94
|
'setLeverage': false,
|
|
95
95
|
'setMarginMode': false,
|
|
96
96
|
'transfer': false,
|
|
97
|
-
'withdraw':
|
|
97
|
+
'withdraw': true,
|
|
98
98
|
},
|
|
99
99
|
'api': {
|
|
100
100
|
'broker': {},
|
|
@@ -119,12 +119,15 @@ class alpaca extends alpaca$1 {
|
|
|
119
119
|
'v2/assets/{symbol_or_asset_id}',
|
|
120
120
|
'v2/corporate_actions/announcements/{id}',
|
|
121
121
|
'v2/corporate_actions/announcements',
|
|
122
|
+
'v2/wallets',
|
|
123
|
+
'v2/wallets/transfers',
|
|
122
124
|
],
|
|
123
125
|
'post': [
|
|
124
126
|
'v2/orders',
|
|
125
127
|
'v2/watchlists',
|
|
126
128
|
'v2/watchlists/{watchlist_id}',
|
|
127
129
|
'v2/watchlists:by_name',
|
|
130
|
+
'v2/wallets/transfers',
|
|
128
131
|
],
|
|
129
132
|
'put': [
|
|
130
133
|
'v2/watchlists/{watchlist_id}',
|
|
@@ -682,6 +685,136 @@ class alpaca extends alpaca$1 {
|
|
|
682
685
|
this.safeNumber(ohlcv, 'v'), // volume
|
|
683
686
|
];
|
|
684
687
|
}
|
|
688
|
+
async fetchTicker(symbol, params = {}) {
|
|
689
|
+
/**
|
|
690
|
+
* @method
|
|
691
|
+
* @name alpaca#fetchTicker
|
|
692
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
693
|
+
* @see https://docs.alpaca.markets/reference/cryptosnapshots-1
|
|
694
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
695
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
696
|
+
* @param {string} [params.loc] crypto location, default: us
|
|
697
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
698
|
+
*/
|
|
699
|
+
await this.loadMarkets();
|
|
700
|
+
symbol = this.symbol(symbol);
|
|
701
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
702
|
+
return this.safeDict(tickers, symbol);
|
|
703
|
+
}
|
|
704
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
705
|
+
/**
|
|
706
|
+
* @method
|
|
707
|
+
* @name alpaca#fetchTickers
|
|
708
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
709
|
+
* @see https://docs.alpaca.markets/reference/cryptosnapshots-1
|
|
710
|
+
* @param {string[]} symbols unified symbols of the markets to fetch tickers for
|
|
711
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
712
|
+
* @param {string} [params.loc] crypto location, default: us
|
|
713
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
714
|
+
*/
|
|
715
|
+
if (symbols === undefined) {
|
|
716
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchTickers() requires a symbols argument');
|
|
717
|
+
}
|
|
718
|
+
await this.loadMarkets();
|
|
719
|
+
symbols = this.marketSymbols(symbols);
|
|
720
|
+
const loc = this.safeString(params, 'loc', 'us');
|
|
721
|
+
const ids = this.marketIds(symbols);
|
|
722
|
+
const request = {
|
|
723
|
+
'symbols': ids.join(','),
|
|
724
|
+
'loc': loc,
|
|
725
|
+
};
|
|
726
|
+
params = this.omit(params, 'loc');
|
|
727
|
+
const response = await this.marketPublicGetV1beta3CryptoLocSnapshots(this.extend(request, params));
|
|
728
|
+
//
|
|
729
|
+
// {
|
|
730
|
+
// "snapshots": {
|
|
731
|
+
// "BTC/USD": {
|
|
732
|
+
// "dailyBar": {
|
|
733
|
+
// "c": 69403.554,
|
|
734
|
+
// "h": 69609.6515,
|
|
735
|
+
// "l": 69013.26,
|
|
736
|
+
// "n": 9,
|
|
737
|
+
// "o": 69536.7,
|
|
738
|
+
// "t": "2024-11-01T05:00:00Z",
|
|
739
|
+
// "v": 0.210809181,
|
|
740
|
+
// "vw": 69327.655393908
|
|
741
|
+
// },
|
|
742
|
+
// "latestQuote": {
|
|
743
|
+
// "ap": 69424.19,
|
|
744
|
+
// "as": 0.68149,
|
|
745
|
+
// "bp": 69366.086,
|
|
746
|
+
// "bs": 0.68312,
|
|
747
|
+
// "t": "2024-11-01T08:31:41.880246926Z"
|
|
748
|
+
// },
|
|
749
|
+
// "latestTrade": {
|
|
750
|
+
// "i": 5272941104897543146,
|
|
751
|
+
// "p": 69416.9,
|
|
752
|
+
// "s": 0.014017324,
|
|
753
|
+
// "t": "2024-11-01T08:14:28.245088803Z",
|
|
754
|
+
// "tks": "B"
|
|
755
|
+
// },
|
|
756
|
+
// "minuteBar": {
|
|
757
|
+
// "c": 69403.554,
|
|
758
|
+
// "h": 69403.554,
|
|
759
|
+
// "l": 69399.125,
|
|
760
|
+
// "n": 0,
|
|
761
|
+
// "o": 69399.125,
|
|
762
|
+
// "t": "2024-11-01T08:30:00Z",
|
|
763
|
+
// "v": 0,
|
|
764
|
+
// "vw": 0
|
|
765
|
+
// },
|
|
766
|
+
// "prevDailyBar": {
|
|
767
|
+
// "c": 69515.1415,
|
|
768
|
+
// "h": 72668.837,
|
|
769
|
+
// "l": 68796.85,
|
|
770
|
+
// "n": 129,
|
|
771
|
+
// "o": 72258.9,
|
|
772
|
+
// "t": "2024-10-31T05:00:00Z",
|
|
773
|
+
// "v": 2.217683307,
|
|
774
|
+
// "vw": 70782.6811608144
|
|
775
|
+
// }
|
|
776
|
+
// },
|
|
777
|
+
// }
|
|
778
|
+
// }
|
|
779
|
+
//
|
|
780
|
+
const results = [];
|
|
781
|
+
const snapshots = this.safeDict(response, 'snapshots', {});
|
|
782
|
+
const marketIds = Object.keys(snapshots);
|
|
783
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
784
|
+
const marketId = marketIds[i];
|
|
785
|
+
const market = this.safeMarket(marketId);
|
|
786
|
+
const entry = this.safeDict(snapshots, marketId);
|
|
787
|
+
const dailyBar = this.safeDict(entry, 'dailyBar', {});
|
|
788
|
+
const prevDailyBar = this.safeDict(entry, 'prevDailyBar', {});
|
|
789
|
+
const latestQuote = this.safeDict(entry, 'latestQuote', {});
|
|
790
|
+
const latestTrade = this.safeDict(entry, 'latestTrade', {});
|
|
791
|
+
const datetime = this.safeString(latestQuote, 't');
|
|
792
|
+
const ticker = this.safeTicker({
|
|
793
|
+
'info': entry,
|
|
794
|
+
'symbol': market['symbol'],
|
|
795
|
+
'timestamp': this.parse8601(datetime),
|
|
796
|
+
'datetime': datetime,
|
|
797
|
+
'high': this.safeString(dailyBar, 'h'),
|
|
798
|
+
'low': this.safeString(dailyBar, 'l'),
|
|
799
|
+
'bid': this.safeString(latestQuote, 'bp'),
|
|
800
|
+
'bidVolume': this.safeString(latestQuote, 'bs'),
|
|
801
|
+
'ask': this.safeString(latestQuote, 'ap'),
|
|
802
|
+
'askVolume': this.safeString(latestQuote, 'as'),
|
|
803
|
+
'vwap': this.safeString(dailyBar, 'vw'),
|
|
804
|
+
'open': this.safeString(dailyBar, 'o'),
|
|
805
|
+
'close': this.safeString(dailyBar, 'c'),
|
|
806
|
+
'last': this.safeString(latestTrade, 'p'),
|
|
807
|
+
'previousClose': this.safeString(prevDailyBar, 'c'),
|
|
808
|
+
'change': undefined,
|
|
809
|
+
'percentage': undefined,
|
|
810
|
+
'average': undefined,
|
|
811
|
+
'baseVolume': this.safeString(dailyBar, 'v'),
|
|
812
|
+
'quoteVolume': this.safeString(dailyBar, 'n'),
|
|
813
|
+
}, market);
|
|
814
|
+
results.push(ticker);
|
|
815
|
+
}
|
|
816
|
+
return this.filterByArray(results, 'symbol', symbols);
|
|
817
|
+
}
|
|
685
818
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
686
819
|
/**
|
|
687
820
|
* @method
|
|
@@ -1052,7 +1185,59 @@ class alpaca extends alpaca$1 {
|
|
|
1052
1185
|
};
|
|
1053
1186
|
return this.safeString(timeInForces, timeInForce, timeInForce);
|
|
1054
1187
|
}
|
|
1188
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1189
|
+
/**
|
|
1190
|
+
* @method
|
|
1191
|
+
* @name alpaca#fetchMyTrades
|
|
1192
|
+
* @description fetch all trades made by the user
|
|
1193
|
+
* @see https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1
|
|
1194
|
+
* @param {string} [symbol] unified market symbol
|
|
1195
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1196
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
1197
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1198
|
+
* @param {int} [params.until] the latest time in ms to fetch trades for
|
|
1199
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1200
|
+
*/
|
|
1201
|
+
await this.loadMarkets();
|
|
1202
|
+
let market = undefined;
|
|
1203
|
+
let request = {
|
|
1204
|
+
'activity_type': 'FILL',
|
|
1205
|
+
};
|
|
1206
|
+
if (symbol !== undefined) {
|
|
1207
|
+
market = this.market(symbol);
|
|
1208
|
+
}
|
|
1209
|
+
if (since !== undefined) {
|
|
1210
|
+
request['after'] = since;
|
|
1211
|
+
}
|
|
1212
|
+
if (limit !== undefined) {
|
|
1213
|
+
request['page_size'] = limit;
|
|
1214
|
+
}
|
|
1215
|
+
[request, params] = this.handleUntilOption('until', request, params);
|
|
1216
|
+
const response = await this.traderPrivateGetV2AccountActivitiesActivityType(this.extend(request, params));
|
|
1217
|
+
//
|
|
1218
|
+
// [
|
|
1219
|
+
// {
|
|
1220
|
+
// "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
|
1221
|
+
// "activity_type": "FILL",
|
|
1222
|
+
// "transaction_time": "2022-12-28T12:19:29.579352Z",
|
|
1223
|
+
// "type": "fill",
|
|
1224
|
+
// "price": "67.31",
|
|
1225
|
+
// "qty": "0.07",
|
|
1226
|
+
// "side": "sell",
|
|
1227
|
+
// "symbol": "LTC/USD",
|
|
1228
|
+
// "leaves_qty": "0",
|
|
1229
|
+
// "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
|
1230
|
+
// "cum_qty": "0.07",
|
|
1231
|
+
// "order_status": "filled",
|
|
1232
|
+
// "swap_rate": "1"
|
|
1233
|
+
// },
|
|
1234
|
+
// ]
|
|
1235
|
+
//
|
|
1236
|
+
return this.parseTrades(response, market, since, limit);
|
|
1237
|
+
}
|
|
1055
1238
|
parseTrade(trade, market = undefined) {
|
|
1239
|
+
//
|
|
1240
|
+
// fetchTrades
|
|
1056
1241
|
//
|
|
1057
1242
|
// {
|
|
1058
1243
|
// "t":"2022-06-14T05:00:00.027869Z",
|
|
@@ -1063,27 +1248,45 @@ class alpaca extends alpaca$1 {
|
|
|
1063
1248
|
// "i":"355681339"
|
|
1064
1249
|
// }
|
|
1065
1250
|
//
|
|
1066
|
-
|
|
1251
|
+
// fetchMyTrades
|
|
1252
|
+
//
|
|
1253
|
+
// {
|
|
1254
|
+
// "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
|
1255
|
+
// "activity_type": "FILL",
|
|
1256
|
+
// "transaction_time": "2022-12-28T12:19:29.579352Z",
|
|
1257
|
+
// "type": "fill",
|
|
1258
|
+
// "price": "67.31",
|
|
1259
|
+
// "qty": "0.07",
|
|
1260
|
+
// "side": "sell",
|
|
1261
|
+
// "symbol": "LTC/USD",
|
|
1262
|
+
// "leaves_qty": "0",
|
|
1263
|
+
// "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
|
1264
|
+
// "cum_qty": "0.07",
|
|
1265
|
+
// "order_status": "filled",
|
|
1266
|
+
// "swap_rate": "1"
|
|
1267
|
+
// },
|
|
1268
|
+
//
|
|
1269
|
+
const marketId = this.safeString2(trade, 'S', 'symbol');
|
|
1067
1270
|
const symbol = this.safeSymbol(marketId, market);
|
|
1068
|
-
const datetime = this.
|
|
1271
|
+
const datetime = this.safeString2(trade, 't', 'transaction_time');
|
|
1069
1272
|
const timestamp = this.parse8601(datetime);
|
|
1070
1273
|
const alpacaSide = this.safeString(trade, 'tks');
|
|
1071
|
-
let side;
|
|
1274
|
+
let side = this.safeString(trade, 'side');
|
|
1072
1275
|
if (alpacaSide === 'B') {
|
|
1073
1276
|
side = 'buy';
|
|
1074
1277
|
}
|
|
1075
1278
|
else if (alpacaSide === 'S') {
|
|
1076
1279
|
side = 'sell';
|
|
1077
1280
|
}
|
|
1078
|
-
const priceString = this.
|
|
1079
|
-
const amountString = this.
|
|
1281
|
+
const priceString = this.safeString2(trade, 'p', 'price');
|
|
1282
|
+
const amountString = this.safeString2(trade, 's', 'qty');
|
|
1080
1283
|
return this.safeTrade({
|
|
1081
1284
|
'info': trade,
|
|
1082
|
-
'id': this.
|
|
1285
|
+
'id': this.safeString2(trade, 'i', 'id'),
|
|
1083
1286
|
'timestamp': timestamp,
|
|
1084
1287
|
'datetime': this.iso8601(timestamp),
|
|
1085
1288
|
'symbol': symbol,
|
|
1086
|
-
'order':
|
|
1289
|
+
'order': this.safeString(trade, 'order_id'),
|
|
1087
1290
|
'type': undefined,
|
|
1088
1291
|
'side': side,
|
|
1089
1292
|
'takerOrMaker': 'taker',
|
|
@@ -1093,6 +1296,238 @@ class alpaca extends alpaca$1 {
|
|
|
1093
1296
|
'fee': undefined,
|
|
1094
1297
|
}, market);
|
|
1095
1298
|
}
|
|
1299
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1300
|
+
/**
|
|
1301
|
+
* @method
|
|
1302
|
+
* @name alpaca#fetchDepositAddress
|
|
1303
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1304
|
+
* @see https://docs.alpaca.markets/reference/listcryptofundingwallets
|
|
1305
|
+
* @param {string} code unified currency code
|
|
1306
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1307
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1308
|
+
*/
|
|
1309
|
+
await this.loadMarkets();
|
|
1310
|
+
const currency = this.currency(code);
|
|
1311
|
+
const request = {
|
|
1312
|
+
'asset': currency['id'],
|
|
1313
|
+
};
|
|
1314
|
+
const response = await this.traderPrivateGetV2Wallets(this.extend(request, params));
|
|
1315
|
+
//
|
|
1316
|
+
// {
|
|
1317
|
+
// "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
|
1318
|
+
// "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
|
1319
|
+
// "created_at": "2024-11-03T07:30:05.609976344Z"
|
|
1320
|
+
// }
|
|
1321
|
+
//
|
|
1322
|
+
return this.parseDepositAddress(response, currency);
|
|
1323
|
+
}
|
|
1324
|
+
parseDepositAddress(depositAddress, currency = undefined) {
|
|
1325
|
+
//
|
|
1326
|
+
// {
|
|
1327
|
+
// "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
|
1328
|
+
// "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
|
1329
|
+
// "created_at": "2024-11-03T07:30:05.609976344Z"
|
|
1330
|
+
// }
|
|
1331
|
+
//
|
|
1332
|
+
let parsedCurrency = undefined;
|
|
1333
|
+
if (currency !== undefined) {
|
|
1334
|
+
parsedCurrency = currency['id'];
|
|
1335
|
+
}
|
|
1336
|
+
return {
|
|
1337
|
+
'info': depositAddress,
|
|
1338
|
+
'currency': parsedCurrency,
|
|
1339
|
+
'network': undefined,
|
|
1340
|
+
'address': this.safeString(depositAddress, 'address'),
|
|
1341
|
+
'tag': undefined,
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1345
|
+
/**
|
|
1346
|
+
* @method
|
|
1347
|
+
* @name alpaca#withdraw
|
|
1348
|
+
* @description make a withdrawal
|
|
1349
|
+
* @see https://docs.alpaca.markets/reference/createcryptotransferforaccount
|
|
1350
|
+
* @param {string} code unified currency code
|
|
1351
|
+
* @param {float} amount the amount to withdraw
|
|
1352
|
+
* @param {string} address the address to withdraw to
|
|
1353
|
+
* @param {string} tag a memo for the transaction
|
|
1354
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1355
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1356
|
+
*/
|
|
1357
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
1358
|
+
this.checkAddress(address);
|
|
1359
|
+
await this.loadMarkets();
|
|
1360
|
+
const currency = this.currency(code);
|
|
1361
|
+
if (tag) {
|
|
1362
|
+
address = address + ':' + tag;
|
|
1363
|
+
}
|
|
1364
|
+
const request = {
|
|
1365
|
+
'asset': currency['id'],
|
|
1366
|
+
'address': address,
|
|
1367
|
+
'amount': this.numberToString(amount),
|
|
1368
|
+
};
|
|
1369
|
+
const response = await this.traderPrivatePostV2WalletsTransfers(this.extend(request, params));
|
|
1370
|
+
//
|
|
1371
|
+
// {
|
|
1372
|
+
// "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
|
1373
|
+
// "tx_hash": "string",
|
|
1374
|
+
// "direction": "INCOMING",
|
|
1375
|
+
// "status": "PROCESSING",
|
|
1376
|
+
// "amount": "string",
|
|
1377
|
+
// "usd_value": "string",
|
|
1378
|
+
// "network_fee": "string",
|
|
1379
|
+
// "fees": "string",
|
|
1380
|
+
// "chain": "string",
|
|
1381
|
+
// "asset": "string",
|
|
1382
|
+
// "from_address": "string",
|
|
1383
|
+
// "to_address": "string",
|
|
1384
|
+
// "created_at": "2024-11-02T07:42:48.402Z"
|
|
1385
|
+
// }
|
|
1386
|
+
//
|
|
1387
|
+
return this.parseTransaction(response, currency);
|
|
1388
|
+
}
|
|
1389
|
+
async fetchTransactionsHelper(type, code, since, limit, params) {
|
|
1390
|
+
await this.loadMarkets();
|
|
1391
|
+
let currency = undefined;
|
|
1392
|
+
if (code !== undefined) {
|
|
1393
|
+
currency = this.currency(code);
|
|
1394
|
+
}
|
|
1395
|
+
const response = await this.traderPrivateGetV2WalletsTransfers(params);
|
|
1396
|
+
//
|
|
1397
|
+
// {
|
|
1398
|
+
// "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
|
1399
|
+
// "tx_hash": "string",
|
|
1400
|
+
// "direction": "INCOMING",
|
|
1401
|
+
// "status": "PROCESSING",
|
|
1402
|
+
// "amount": "string",
|
|
1403
|
+
// "usd_value": "string",
|
|
1404
|
+
// "network_fee": "string",
|
|
1405
|
+
// "fees": "string",
|
|
1406
|
+
// "chain": "string",
|
|
1407
|
+
// "asset": "string",
|
|
1408
|
+
// "from_address": "string",
|
|
1409
|
+
// "to_address": "string",
|
|
1410
|
+
// "created_at": "2024-11-02T07:42:48.402Z"
|
|
1411
|
+
// }
|
|
1412
|
+
//
|
|
1413
|
+
const results = [];
|
|
1414
|
+
for (let i = 0; i < response.length; i++) {
|
|
1415
|
+
const entry = response[i];
|
|
1416
|
+
const direction = this.safeString(entry, 'direction');
|
|
1417
|
+
if (direction === type) {
|
|
1418
|
+
results.push(entry);
|
|
1419
|
+
}
|
|
1420
|
+
else if (direction === 'BOTH') {
|
|
1421
|
+
results.push(entry);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return this.parseTransactions(results, currency, since, limit, params);
|
|
1425
|
+
}
|
|
1426
|
+
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1427
|
+
/**
|
|
1428
|
+
* @method
|
|
1429
|
+
* @name alpaca#fetchDepositsWithdrawals
|
|
1430
|
+
* @description fetch history of deposits and withdrawals
|
|
1431
|
+
* @see https://docs.alpaca.markets/reference/listcryptofundingtransfers
|
|
1432
|
+
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
|
|
1433
|
+
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
1434
|
+
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
1435
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1436
|
+
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1437
|
+
*/
|
|
1438
|
+
return await this.fetchTransactionsHelper('BOTH', code, since, limit, params);
|
|
1439
|
+
}
|
|
1440
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1441
|
+
/**
|
|
1442
|
+
* @method
|
|
1443
|
+
* @name alpaca#fetchDeposits
|
|
1444
|
+
* @description fetch all deposits made to an account
|
|
1445
|
+
* @see https://docs.alpaca.markets/reference/listcryptofundingtransfers
|
|
1446
|
+
* @param {string} [code] unified currency code
|
|
1447
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1448
|
+
* @param {int} [limit] the maximum number of deposit structures to retrieve
|
|
1449
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1450
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1451
|
+
*/
|
|
1452
|
+
return await this.fetchTransactionsHelper('INCOMING', code, since, limit, params);
|
|
1453
|
+
}
|
|
1454
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1455
|
+
/**
|
|
1456
|
+
* @method
|
|
1457
|
+
* @name alpaca#fetchWithdrawals
|
|
1458
|
+
* @description fetch all withdrawals made from an account
|
|
1459
|
+
* @see https://docs.alpaca.markets/reference/listcryptofundingtransfers
|
|
1460
|
+
* @param {string} [code] unified currency code
|
|
1461
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
1462
|
+
* @param {int} [limit] the maximum number of withdrawal structures to retrieve
|
|
1463
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1464
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1465
|
+
*/
|
|
1466
|
+
return await this.fetchTransactionsHelper('OUTGOING', code, since, limit, params);
|
|
1467
|
+
}
|
|
1468
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1469
|
+
//
|
|
1470
|
+
// {
|
|
1471
|
+
// "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
|
1472
|
+
// "tx_hash": "string",
|
|
1473
|
+
// "direction": "INCOMING",
|
|
1474
|
+
// "status": "PROCESSING",
|
|
1475
|
+
// "amount": "string",
|
|
1476
|
+
// "usd_value": "string",
|
|
1477
|
+
// "network_fee": "string",
|
|
1478
|
+
// "fees": "string",
|
|
1479
|
+
// "chain": "string",
|
|
1480
|
+
// "asset": "string",
|
|
1481
|
+
// "from_address": "string",
|
|
1482
|
+
// "to_address": "string",
|
|
1483
|
+
// "created_at": "2024-11-02T07:42:48.402Z"
|
|
1484
|
+
// }
|
|
1485
|
+
//
|
|
1486
|
+
const datetime = this.safeString(transaction, 'created_at');
|
|
1487
|
+
const currencyId = this.safeString(transaction, 'asset');
|
|
1488
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
1489
|
+
const fee = {
|
|
1490
|
+
'cost': this.safeNumber(transaction, 'fees'),
|
|
1491
|
+
'currency': code,
|
|
1492
|
+
};
|
|
1493
|
+
return {
|
|
1494
|
+
'info': transaction,
|
|
1495
|
+
'id': this.safeString(transaction, 'id'),
|
|
1496
|
+
'txid': this.safeString(transaction, 'tx_hash'),
|
|
1497
|
+
'timestamp': this.parse8601(datetime),
|
|
1498
|
+
'datetime': datetime,
|
|
1499
|
+
'network': this.safeString(transaction, 'chain'),
|
|
1500
|
+
'address': this.safeString(transaction, 'to_address'),
|
|
1501
|
+
'addressTo': this.safeString(transaction, 'to_address'),
|
|
1502
|
+
'addressFrom': this.safeString(transaction, 'from_address'),
|
|
1503
|
+
'tag': undefined,
|
|
1504
|
+
'tagTo': undefined,
|
|
1505
|
+
'tagFrom': undefined,
|
|
1506
|
+
'type': this.parseTransactionType(this.safeString(transaction, 'direction')),
|
|
1507
|
+
'amount': this.safeNumber(transaction, 'amount'),
|
|
1508
|
+
'currency': code,
|
|
1509
|
+
'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
|
|
1510
|
+
'updated': undefined,
|
|
1511
|
+
'fee': fee,
|
|
1512
|
+
'comment': undefined,
|
|
1513
|
+
'internal': undefined,
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
parseTransactionStatus(status) {
|
|
1517
|
+
const statuses = {
|
|
1518
|
+
'PROCESSING': 'pending',
|
|
1519
|
+
// 'FAILED': 'failed',
|
|
1520
|
+
// 'SUCCESS': 'ok',
|
|
1521
|
+
};
|
|
1522
|
+
return this.safeString(statuses, status, status);
|
|
1523
|
+
}
|
|
1524
|
+
parseTransactionType(type) {
|
|
1525
|
+
const types = {
|
|
1526
|
+
'INCOMING': 'deposit',
|
|
1527
|
+
'OUTGOING': 'withdrawal',
|
|
1528
|
+
};
|
|
1529
|
+
return this.safeString(types, type, type);
|
|
1530
|
+
}
|
|
1096
1531
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1097
1532
|
let endpoint = '/' + this.implodeParams(path, params);
|
|
1098
1533
|
let url = this.implodeHostname(this.urls['api'][api[0]]);
|
package/dist/cjs/src/ascendex.js
CHANGED
|
@@ -113,7 +113,7 @@ class ascendex extends ascendex$1 {
|
|
|
113
113
|
},
|
|
114
114
|
'version': 'v2',
|
|
115
115
|
'urls': {
|
|
116
|
-
'logo': 'https://
|
|
116
|
+
'logo': 'https://github.com/user-attachments/assets/55bab6b9-d4ca-42a8-a0e6-fac81ae557f1',
|
|
117
117
|
'api': {
|
|
118
118
|
'rest': 'https://ascendex.com',
|
|
119
119
|
},
|