ccxt 4.5.44 → 4.5.46
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 +9 -12
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -12
- package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
- package/dist/cjs/src/base/Exchange.js +39 -3
- package/dist/cjs/src/base/functions/encode.js +2 -2
- package/dist/cjs/src/base/functions/generic.js +8 -2
- package/dist/cjs/src/binance.js +11 -2
- package/dist/cjs/src/bitget.js +3 -1
- package/dist/cjs/src/bitmart.js +144 -21
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bitteam.js +1 -1
- package/dist/cjs/src/btcbox.js +1 -1
- package/dist/cjs/src/bybit.js +58 -56
- package/dist/cjs/src/bydfi.js +102 -100
- package/dist/cjs/src/cex.js +1 -0
- package/dist/cjs/src/gate.js +264 -170
- package/dist/cjs/src/grvt.js +3 -2
- package/dist/cjs/src/hyperliquid.js +16 -5
- package/dist/cjs/src/kraken.js +4 -2
- package/dist/cjs/src/krakenfutures.js +1 -5
- package/dist/cjs/src/kucoin.js +4733 -972
- package/dist/cjs/src/kucoinfutures.js +14 -3434
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/okx.js +75 -57
- package/dist/cjs/src/paradex.js +2 -6
- package/dist/cjs/src/poloniex.js +1 -1
- package/dist/cjs/src/pro/bydfi.js +19 -19
- package/dist/cjs/src/pro/gate.js +114 -53
- package/dist/cjs/src/pro/grvt.js +5 -3
- package/dist/cjs/src/pro/htx.js +4 -4
- package/dist/cjs/src/pro/kucoin.js +819 -178
- package/dist/cjs/src/pro/kucoinfutures.js +95 -1261
- package/dist/cjs/src/pro/mexc.js +10 -5
- package/dist/cjs/src/pro/okx.js +85 -40
- package/index.d.cts +2 -0
- package/js/ccxt.d.ts +2 -14
- package/js/ccxt.js +2 -10
- package/js/src/abstract/bitmart.d.ts +7 -0
- package/js/src/abstract/bydfi.d.ts +29 -29
- package/js/src/abstract/kraken.d.ts +1 -0
- package/js/src/abstract/kucoin.d.ts +46 -2
- package/js/src/abstract/kucoinfutures.d.ts +27 -11
- package/js/src/base/Exchange.d.ts +13 -1
- package/js/src/base/Exchange.js +39 -3
- package/js/src/base/functions/encode.js +2 -2
- package/js/src/base/functions/generic.js +9 -3
- package/js/src/binance.js +11 -2
- package/js/src/bitget.js +3 -1
- package/js/src/bitmart.d.ts +18 -4
- package/js/src/bitmart.js +144 -21
- package/js/src/bitrue.js +1 -1
- package/js/src/bitteam.js +1 -1
- package/js/src/btcbox.js +1 -1
- package/js/src/bybit.d.ts +1 -0
- package/js/src/bybit.js +58 -56
- package/js/src/bydfi.d.ts +31 -31
- package/js/src/bydfi.js +102 -100
- package/js/src/cex.js +2 -1
- package/js/src/gate.d.ts +125 -119
- package/js/src/gate.js +264 -170
- package/js/src/grvt.js +3 -2
- package/js/src/hyperliquid.d.ts +3 -1
- package/js/src/hyperliquid.js +16 -5
- package/js/src/kraken.js +4 -2
- package/js/src/krakenfutures.js +1 -5
- package/js/src/kucoin.d.ts +696 -100
- package/js/src/kucoin.js +4734 -973
- package/js/src/kucoinfutures.d.ts +4 -522
- package/js/src/kucoinfutures.js +14 -3434
- package/js/src/lbank.js +1 -1
- package/js/src/okx.d.ts +1 -0
- package/js/src/okx.js +75 -57
- package/js/src/paradex.d.ts +0 -1
- package/js/src/paradex.js +2 -6
- package/js/src/poloniex.js +1 -1
- package/js/src/pro/bydfi.d.ts +18 -18
- package/js/src/pro/bydfi.js +19 -19
- package/js/src/pro/gate.d.ts +30 -1
- package/js/src/pro/gate.js +114 -53
- package/js/src/pro/grvt.js +5 -3
- package/js/src/pro/htx.js +4 -4
- package/js/src/pro/kucoin.d.ts +70 -30
- package/js/src/pro/kucoin.js +821 -180
- package/js/src/pro/kucoinfutures.d.ts +17 -195
- package/js/src/pro/kucoinfutures.js +96 -1262
- package/js/src/pro/mexc.js +10 -5
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +85 -40
- package/package.json +2 -2
- package/dist/cjs/src/abstract/alp.js +0 -11
- package/dist/cjs/src/abstract/defx.js +0 -11
- package/dist/cjs/src/abstract/timex.js +0 -11
- package/dist/cjs/src/alp.js +0 -1059
- package/dist/cjs/src/defx.js +0 -2142
- package/dist/cjs/src/pro/defx.js +0 -866
- package/dist/cjs/src/timex.js +0 -1793
- package/js/src/abstract/alp.d.ts +0 -21
- package/js/src/abstract/alp.js +0 -5
- package/js/src/abstract/defx.d.ts +0 -72
- package/js/src/abstract/defx.js +0 -5
- package/js/src/abstract/timex.d.ts +0 -65
- package/js/src/abstract/timex.js +0 -5
- package/js/src/alp.d.ts +0 -209
- package/js/src/alp.js +0 -1052
- package/js/src/defx.d.ts +0 -348
- package/js/src/defx.js +0 -2135
- package/js/src/pro/defx.d.ts +0 -236
- package/js/src/pro/defx.js +0 -859
- package/js/src/timex.d.ts +0 -247
- package/js/src/timex.js +0 -1786
package/dist/cjs/src/alp.js
DELETED
|
@@ -1,1059 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var alp$1 = require('./abstract/alp.js');
|
|
6
|
-
var errors = require('./base/errors.js');
|
|
7
|
-
var Precise = require('./base/Precise.js');
|
|
8
|
-
var number = require('./base/functions/number.js');
|
|
9
|
-
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
10
|
-
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
/**
|
|
14
|
-
* @class alp
|
|
15
|
-
* @augments Exchange
|
|
16
|
-
*/
|
|
17
|
-
class alp extends alp$1["default"] {
|
|
18
|
-
describe() {
|
|
19
|
-
return this.deepExtend(super.describe(), {
|
|
20
|
-
'id': 'alp',
|
|
21
|
-
'name': 'Alp',
|
|
22
|
-
'countries': ['US'],
|
|
23
|
-
'version': 'v1',
|
|
24
|
-
'rateLimit': 10,
|
|
25
|
-
'has': {
|
|
26
|
-
'CORS': undefined,
|
|
27
|
-
'spot': true,
|
|
28
|
-
'margin': false,
|
|
29
|
-
'swap': false,
|
|
30
|
-
'future': false,
|
|
31
|
-
'option': false,
|
|
32
|
-
'addMargin': false,
|
|
33
|
-
'borrowCrossMargin': false,
|
|
34
|
-
'borrowIsolatedMargin': false,
|
|
35
|
-
'borrowMargin': false,
|
|
36
|
-
'cancelOrder': true,
|
|
37
|
-
'closeAllPositions': false,
|
|
38
|
-
'closePosition': false,
|
|
39
|
-
'createDepositAddress': false,
|
|
40
|
-
'createOrder': true,
|
|
41
|
-
'createOrderWithTakeProfitAndStopLoss': false,
|
|
42
|
-
'createOrderWithTakeProfitAndStopLossWs': false,
|
|
43
|
-
'createPostOnlyOrder': false,
|
|
44
|
-
'createReduceOnlyOrder': false,
|
|
45
|
-
'createStopLimitOrder': false,
|
|
46
|
-
'createStopMarketOrder': false,
|
|
47
|
-
'createStopOrder': false,
|
|
48
|
-
'fetchBalance': true,
|
|
49
|
-
'fetchBorrowInterest': false,
|
|
50
|
-
'fetchBorrowRate': false,
|
|
51
|
-
'fetchBorrowRateHistories': false,
|
|
52
|
-
'fetchBorrowRateHistory': false,
|
|
53
|
-
'fetchBorrowRates': false,
|
|
54
|
-
'fetchBorrowRatesPerSymbol': false,
|
|
55
|
-
'fetchClosedOrders': true,
|
|
56
|
-
'fetchCrossBorrowRate': false,
|
|
57
|
-
'fetchCrossBorrowRates': false,
|
|
58
|
-
'fetchCurrencies': false,
|
|
59
|
-
'fetchDeposit': false,
|
|
60
|
-
'fetchDepositAddress': false,
|
|
61
|
-
'fetchDepositAddresses': false,
|
|
62
|
-
'fetchDepositAddressesByNetwork': false,
|
|
63
|
-
'fetchDeposits': true,
|
|
64
|
-
'fetchFundingHistory': false,
|
|
65
|
-
'fetchFundingInterval': false,
|
|
66
|
-
'fetchFundingIntervals': false,
|
|
67
|
-
'fetchFundingRate': false,
|
|
68
|
-
'fetchFundingRateHistory': false,
|
|
69
|
-
'fetchFundingRates': false,
|
|
70
|
-
'fetchGreeks': false,
|
|
71
|
-
'fetchIndexOHLCV': false,
|
|
72
|
-
'fetchIsolatedBorrowRate': false,
|
|
73
|
-
'fetchIsolatedBorrowRates': false,
|
|
74
|
-
'fetchIsolatedPositions': false,
|
|
75
|
-
'fetchL2OrderBook': true,
|
|
76
|
-
'fetchLeverage': false,
|
|
77
|
-
'fetchLeverages': false,
|
|
78
|
-
'fetchLeverageTiers': false,
|
|
79
|
-
'fetchLiquidations': false,
|
|
80
|
-
'fetchLongShortRatio': false,
|
|
81
|
-
'fetchLongShortRatioHistory': false,
|
|
82
|
-
'fetchMarginAdjustmentHistory': false,
|
|
83
|
-
'fetchMarginMode': false,
|
|
84
|
-
'fetchMarginModes': false,
|
|
85
|
-
'fetchMarketLeverageTiers': false,
|
|
86
|
-
'fetchMarkets': true,
|
|
87
|
-
'fetchMarkOHLCV': false,
|
|
88
|
-
'fetchMarkPrices': false,
|
|
89
|
-
'fetchMyLiquidations': false,
|
|
90
|
-
'fetchMySettlementHistory': false,
|
|
91
|
-
'fetchMyTrades': true,
|
|
92
|
-
'fetchOHLCV': true,
|
|
93
|
-
'fetchOpenInterest': false,
|
|
94
|
-
'fetchOpenInterestHistory': false,
|
|
95
|
-
'fetchOpenInterests': false,
|
|
96
|
-
'fetchOpenOrders': true,
|
|
97
|
-
'fetchOption': false,
|
|
98
|
-
'fetchOptionChain': false,
|
|
99
|
-
'fetchOrder': true,
|
|
100
|
-
'fetchOrderBook': true,
|
|
101
|
-
'fetchOrders': true,
|
|
102
|
-
'fetchPosition': false,
|
|
103
|
-
'fetchPositionHistory': false,
|
|
104
|
-
'fetchPositionMode': false,
|
|
105
|
-
'fetchPositions': false,
|
|
106
|
-
'fetchPositionsForSymbol': false,
|
|
107
|
-
'fetchPositionsHistory': false,
|
|
108
|
-
'fetchPositionsRisk': false,
|
|
109
|
-
'fetchPremiumIndexOHLCV': false,
|
|
110
|
-
'fetchSettlementHistory': false,
|
|
111
|
-
'fetchTicker': true,
|
|
112
|
-
'fetchTickers': true,
|
|
113
|
-
'fetchTrades': true,
|
|
114
|
-
'fetchTradingFee': false,
|
|
115
|
-
'fetchTradingFees': false,
|
|
116
|
-
'fetchTransfer': false,
|
|
117
|
-
'fetchTransfers': false,
|
|
118
|
-
'fetchVolatilityHistory': false,
|
|
119
|
-
'fetchWithdrawal': false,
|
|
120
|
-
'fetchWithdrawals': true,
|
|
121
|
-
'reduceMargin': false,
|
|
122
|
-
'repayCrossMargin': false,
|
|
123
|
-
'repayIsolatedMargin': false,
|
|
124
|
-
'repayMargin': false,
|
|
125
|
-
'setLeverage': false,
|
|
126
|
-
'setMargin': false,
|
|
127
|
-
'setMarginMode': false,
|
|
128
|
-
'setPositionMode': false,
|
|
129
|
-
'transfer': false,
|
|
130
|
-
'withdraw': false,
|
|
131
|
-
},
|
|
132
|
-
'timeframes': {
|
|
133
|
-
'5m': '5',
|
|
134
|
-
'15m': '15',
|
|
135
|
-
'30m': '30',
|
|
136
|
-
'1h': '60',
|
|
137
|
-
'4h': '240',
|
|
138
|
-
'1d': 'D',
|
|
139
|
-
},
|
|
140
|
-
'urls': {
|
|
141
|
-
'logo': 'https://github.com/user-attachments/assets/dce49f3a-61e5-4ba0-a2fe-41d192fd0e5d',
|
|
142
|
-
'api': {
|
|
143
|
-
'rest': 'https://alp.com/api',
|
|
144
|
-
},
|
|
145
|
-
'www': 'https://alp.com',
|
|
146
|
-
'doc': 'https://alpcomdev.github.io/alp-api-docs/',
|
|
147
|
-
'fees': 'https://alp.com/fees/',
|
|
148
|
-
'referral': 'https://alp.com/?r=123788',
|
|
149
|
-
},
|
|
150
|
-
'api': {
|
|
151
|
-
'public': {
|
|
152
|
-
'get': {
|
|
153
|
-
'currencies/': 1,
|
|
154
|
-
'pairs/': 1,
|
|
155
|
-
'orderbook/{pair_name}': 1,
|
|
156
|
-
'exchanges/': 1,
|
|
157
|
-
'charts/{pair}/{type}/chart/': 1,
|
|
158
|
-
'ticker/': 1,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
'private': {
|
|
162
|
-
'get': {
|
|
163
|
-
'wallets/': 50,
|
|
164
|
-
'orders/own/': 50,
|
|
165
|
-
'order/{id}/': 50,
|
|
166
|
-
'exchanges/own/': 50,
|
|
167
|
-
'deposits/': 50,
|
|
168
|
-
'withdraws/': 50,
|
|
169
|
-
},
|
|
170
|
-
'post': {
|
|
171
|
-
'order/': 50,
|
|
172
|
-
'order-cancel/': 50,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
'fees': {
|
|
177
|
-
'trading': {
|
|
178
|
-
'maker': this.parseNumber('0.002'),
|
|
179
|
-
'taker': this.parseNumber('0.002'),
|
|
180
|
-
},
|
|
181
|
-
'funding': {
|
|
182
|
-
'withdraw': {},
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
'commonCurrencies': {
|
|
186
|
-
'CBC': 'Cashbery',
|
|
187
|
-
},
|
|
188
|
-
'features': {
|
|
189
|
-
'spot': {
|
|
190
|
-
'sandbox': false,
|
|
191
|
-
'createOrder': {
|
|
192
|
-
'marginMode': false,
|
|
193
|
-
'triggerPrice': false,
|
|
194
|
-
'triggerPriceType': undefined,
|
|
195
|
-
'triggerDirection': false,
|
|
196
|
-
'stopLossPrice': false,
|
|
197
|
-
'takeProfitPrice': false,
|
|
198
|
-
'attachedStopLossTakeProfit': undefined,
|
|
199
|
-
'timeInForce': {
|
|
200
|
-
'IOC': false,
|
|
201
|
-
'FOK': false,
|
|
202
|
-
'PO': false,
|
|
203
|
-
'GTD': false,
|
|
204
|
-
},
|
|
205
|
-
'hedged': false,
|
|
206
|
-
'leverage': false,
|
|
207
|
-
'marketBuyRequiresPrice': false,
|
|
208
|
-
'marketBuyByCost': false,
|
|
209
|
-
'selfTradePrevention': false,
|
|
210
|
-
'trailing': false,
|
|
211
|
-
'iceberg': false,
|
|
212
|
-
},
|
|
213
|
-
'createOrders': undefined,
|
|
214
|
-
'fetchMyTrades': {
|
|
215
|
-
'marginMode': false,
|
|
216
|
-
'limit': 100,
|
|
217
|
-
'daysBack': undefined,
|
|
218
|
-
'untilDays': undefined,
|
|
219
|
-
'symbolRequired': false,
|
|
220
|
-
},
|
|
221
|
-
'fetchOrder': {
|
|
222
|
-
'marginMode': false,
|
|
223
|
-
'trigger': false,
|
|
224
|
-
'trailing': false,
|
|
225
|
-
'symbolRequired': false,
|
|
226
|
-
},
|
|
227
|
-
'fetchOpenOrders': {
|
|
228
|
-
'marginMode': false,
|
|
229
|
-
'limit': 2000,
|
|
230
|
-
'trigger': false,
|
|
231
|
-
'trailing': false,
|
|
232
|
-
'symbolRequired': false,
|
|
233
|
-
},
|
|
234
|
-
'fetchOrders': {
|
|
235
|
-
'marginMode': false,
|
|
236
|
-
'limit': 2000,
|
|
237
|
-
'daysBack': undefined,
|
|
238
|
-
'untilDays': undefined,
|
|
239
|
-
'trigger': false,
|
|
240
|
-
'trailing': false,
|
|
241
|
-
'symbolRequired': false,
|
|
242
|
-
},
|
|
243
|
-
'fetchClosedOrders': {
|
|
244
|
-
'marginMode': false,
|
|
245
|
-
'limit': 2000,
|
|
246
|
-
'daysBack': undefined,
|
|
247
|
-
'daysBackCanceled': undefined,
|
|
248
|
-
'untilDays': undefined,
|
|
249
|
-
'trigger': false,
|
|
250
|
-
'trailing': false,
|
|
251
|
-
'symbolRequired': false,
|
|
252
|
-
},
|
|
253
|
-
'fetchOHLCV': {
|
|
254
|
-
'limit': 720,
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
'swap': {
|
|
258
|
-
'linear': undefined,
|
|
259
|
-
'inverse': undefined,
|
|
260
|
-
},
|
|
261
|
-
'future': {
|
|
262
|
-
'linear': undefined,
|
|
263
|
-
'inverse': undefined,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
'precisionMode': number.TICK_SIZE,
|
|
267
|
-
'exceptions': {
|
|
268
|
-
'exact': {},
|
|
269
|
-
'broad': {
|
|
270
|
-
'Out of balance': errors.InsufficientFunds, // {"date":1570599531.4814300537,"error":"Out of balance -9.99243661 BTC"}
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* @method
|
|
277
|
-
* @name alp#fetchMarkets
|
|
278
|
-
* @description retrieves data on all markets for alp
|
|
279
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-all-currencies
|
|
280
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
281
|
-
* @returns {object[]} an array of objects representing market data
|
|
282
|
-
*/
|
|
283
|
-
async fetchMarkets(params = {}) {
|
|
284
|
-
const response = await this.publicGetPairs(params);
|
|
285
|
-
//
|
|
286
|
-
// [
|
|
287
|
-
// {
|
|
288
|
-
// "name": "1INCH_USDT",
|
|
289
|
-
// "currency1": "1INCH",
|
|
290
|
-
// "currency2": "USDT",
|
|
291
|
-
// "price_precision": 4,
|
|
292
|
-
// "amount_precision": 2,
|
|
293
|
-
// "minimum_order_size": "0.01000000",
|
|
294
|
-
// "maximum_order_size": "900000.00000000",
|
|
295
|
-
// "minimum_order_value": "10.00000000",
|
|
296
|
-
// "liquidity_type": 10
|
|
297
|
-
// },
|
|
298
|
-
// ]
|
|
299
|
-
//
|
|
300
|
-
return this.parseMarkets(response);
|
|
301
|
-
}
|
|
302
|
-
parseMarket(market) {
|
|
303
|
-
const id = this.safeString(market, 'name');
|
|
304
|
-
const baseId = this.safeString(market, 'currency1');
|
|
305
|
-
const quoteId = this.safeString(market, 'currency2');
|
|
306
|
-
const base = this.safeCurrencyCode(baseId);
|
|
307
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
308
|
-
const pricePrecision = this.safeString(market, 'price_precision');
|
|
309
|
-
const priceLimit = this.parsePrecision(pricePrecision);
|
|
310
|
-
const amountLimit = this.safeString(market, 'minimum_order_size');
|
|
311
|
-
return {
|
|
312
|
-
'id': id,
|
|
313
|
-
'symbol': base + '/' + quote,
|
|
314
|
-
'base': base,
|
|
315
|
-
'quote': quote,
|
|
316
|
-
'settle': undefined,
|
|
317
|
-
'baseId': baseId,
|
|
318
|
-
'quoteId': quoteId,
|
|
319
|
-
'settleId': undefined,
|
|
320
|
-
'type': 'spot',
|
|
321
|
-
'spot': true,
|
|
322
|
-
'margin': false,
|
|
323
|
-
'swap': false,
|
|
324
|
-
'future': false,
|
|
325
|
-
'option': false,
|
|
326
|
-
'active': true,
|
|
327
|
-
'contract': false,
|
|
328
|
-
'linear': undefined,
|
|
329
|
-
'inverse': undefined,
|
|
330
|
-
'contractSize': undefined,
|
|
331
|
-
'expiry': undefined,
|
|
332
|
-
'expiryDatetime': undefined,
|
|
333
|
-
'strike': undefined,
|
|
334
|
-
'optionType': undefined,
|
|
335
|
-
'precision': {
|
|
336
|
-
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'amount_precision'))),
|
|
337
|
-
'price': this.parseNumber(this.parsePrecision((pricePrecision))),
|
|
338
|
-
},
|
|
339
|
-
'limits': {
|
|
340
|
-
'leverage': {
|
|
341
|
-
'min': undefined,
|
|
342
|
-
'max': undefined,
|
|
343
|
-
},
|
|
344
|
-
'amount': {
|
|
345
|
-
'min': this.parseNumber(amountLimit),
|
|
346
|
-
'max': this.safeNumber(market, 'maximum_order_size'),
|
|
347
|
-
},
|
|
348
|
-
'price': {
|
|
349
|
-
'min': this.parseNumber(priceLimit),
|
|
350
|
-
'max': undefined,
|
|
351
|
-
},
|
|
352
|
-
'cost': {
|
|
353
|
-
'min': this.parseNumber(Precise["default"].stringMul(priceLimit, amountLimit)),
|
|
354
|
-
'max': undefined,
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
'created': undefined,
|
|
358
|
-
'info': market,
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* @method
|
|
363
|
-
* @name alp#fetchTickers
|
|
364
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#tickers
|
|
365
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
366
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
367
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
368
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
|
|
369
|
-
*/
|
|
370
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
371
|
-
await this.loadMarkets();
|
|
372
|
-
const response = await this.publicGetTicker(params);
|
|
373
|
-
//
|
|
374
|
-
// [
|
|
375
|
-
// {
|
|
376
|
-
// "timestamp": "1674658.445272",
|
|
377
|
-
// "pair": "BTC_USDT",
|
|
378
|
-
// "last": "22476.85",
|
|
379
|
-
// "diff": "458.96",
|
|
380
|
-
// "vol": "6660.847784",
|
|
381
|
-
// "high": "23106.08",
|
|
382
|
-
// "low": "22348.29",
|
|
383
|
-
// "buy": "22508.46",
|
|
384
|
-
// "sell": "22521.11"
|
|
385
|
-
// },
|
|
386
|
-
// ...
|
|
387
|
-
// ]
|
|
388
|
-
//
|
|
389
|
-
return this.parseTickers(response, symbols);
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* @method
|
|
393
|
-
* @name alp#fetchTicker
|
|
394
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#tickers
|
|
395
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
396
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
397
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
398
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
|
|
399
|
-
*/
|
|
400
|
-
async fetchTicker(symbol, params = {}) {
|
|
401
|
-
await this.loadMarkets();
|
|
402
|
-
const market = this.market(symbol);
|
|
403
|
-
const request = {
|
|
404
|
-
'pair': market['id'],
|
|
405
|
-
};
|
|
406
|
-
const response = await this.publicGetTicker(this.extend(request, params));
|
|
407
|
-
//
|
|
408
|
-
// {
|
|
409
|
-
// "timestamp": "1674658.445272",
|
|
410
|
-
// "pair": "BTC_USDT",
|
|
411
|
-
// "last": "22476.85",
|
|
412
|
-
// "diff": "458.96",
|
|
413
|
-
// "vol": "6660.847784",
|
|
414
|
-
// "high": "23106.08",
|
|
415
|
-
// "low": "22348.29",
|
|
416
|
-
// "buy": "22508.46",
|
|
417
|
-
// "sell": "22521.11"
|
|
418
|
-
// }
|
|
419
|
-
//
|
|
420
|
-
return this.parseTicker(response, market);
|
|
421
|
-
}
|
|
422
|
-
parseTicker(ticker, market = undefined) {
|
|
423
|
-
//
|
|
424
|
-
// {
|
|
425
|
-
// "timestamp": "1674658.445272",
|
|
426
|
-
// "pair": "BTC_USDT",
|
|
427
|
-
// "last": "22476.85",
|
|
428
|
-
// "diff": "458.96",
|
|
429
|
-
// "vol": "6660.847784",
|
|
430
|
-
// "high": "23106.08",
|
|
431
|
-
// "low": "22348.29",
|
|
432
|
-
// "buy": "22508.46",
|
|
433
|
-
// "sell": "22521.11"
|
|
434
|
-
// }
|
|
435
|
-
//
|
|
436
|
-
const timestampStr = this.safeString(ticker, 'timestamp');
|
|
437
|
-
const timestamp = parseInt(Precise["default"].stringMul(timestampStr, '1000000'));
|
|
438
|
-
const marketId = this.safeString(ticker, 'pair');
|
|
439
|
-
market = this.safeMarket(marketId, market, '_');
|
|
440
|
-
const last = this.safeString(ticker, 'last');
|
|
441
|
-
return this.safeTicker({
|
|
442
|
-
'info': ticker,
|
|
443
|
-
'symbol': market['symbol'],
|
|
444
|
-
'timestamp': timestamp,
|
|
445
|
-
'datetime': this.iso8601(timestamp),
|
|
446
|
-
'high': this.safeString(ticker, 'high'),
|
|
447
|
-
'low': this.safeString(ticker, 'low'),
|
|
448
|
-
'bid': this.safeString(ticker, 'buy'),
|
|
449
|
-
'bidVolume': undefined,
|
|
450
|
-
'ask': this.safeString(ticker, 'sell'),
|
|
451
|
-
'askVolume': undefined,
|
|
452
|
-
'vwap': undefined,
|
|
453
|
-
'open': undefined,
|
|
454
|
-
'close': last,
|
|
455
|
-
'last': last,
|
|
456
|
-
'previousClose': undefined,
|
|
457
|
-
'change': this.safeString(ticker, 'diff'),
|
|
458
|
-
'percentage': undefined,
|
|
459
|
-
'average': undefined,
|
|
460
|
-
'baseVolume': undefined,
|
|
461
|
-
'quoteVolume': this.safeString(ticker, 'vol'),
|
|
462
|
-
}, market);
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* @method
|
|
466
|
-
* @name alp#fetchOrderBook
|
|
467
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#get-orderbook
|
|
468
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
469
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
470
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
471
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
472
|
-
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
|
|
473
|
-
*/
|
|
474
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
475
|
-
await this.loadMarkets();
|
|
476
|
-
const market = this.market(symbol);
|
|
477
|
-
const request = {
|
|
478
|
-
'pair_name': market['id'],
|
|
479
|
-
};
|
|
480
|
-
if (limit) {
|
|
481
|
-
request['limit_sell'] = limit;
|
|
482
|
-
request['limit_buy'] = limit;
|
|
483
|
-
}
|
|
484
|
-
const response = await this.publicGetOrderbookPairName(this.extend(request, params));
|
|
485
|
-
return this.parseOrderBook(response, market['symbol'], undefined, 'buy', 'sell', 'price', 'amount');
|
|
486
|
-
}
|
|
487
|
-
parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
488
|
-
const result = [];
|
|
489
|
-
for (let i = 0; i < bidasks.length; i++) {
|
|
490
|
-
const bidask = bidasks[i];
|
|
491
|
-
if (bidask) {
|
|
492
|
-
result.push(this.parseBidAsk(bidask, priceKey, amountKey));
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return result;
|
|
496
|
-
}
|
|
497
|
-
parseTrade(trade, market = undefined) {
|
|
498
|
-
//
|
|
499
|
-
// fetchTrades (public)
|
|
500
|
-
//
|
|
501
|
-
// {
|
|
502
|
-
// "id": "202203440",
|
|
503
|
-
// "timestamp": "1637856276.264215",
|
|
504
|
-
// "pair": "AAVE_USDT",
|
|
505
|
-
// "price": "320.79900000",
|
|
506
|
-
// "amount": "0.05000000",
|
|
507
|
-
// "type": "buy"
|
|
508
|
-
// }
|
|
509
|
-
//
|
|
510
|
-
// fetchMyTrades (private)
|
|
511
|
-
//
|
|
512
|
-
// {
|
|
513
|
-
// "id": "202203440",
|
|
514
|
-
// "timestamp": "1637856276.264215",
|
|
515
|
-
// "pair": "AAVE_USDT",
|
|
516
|
-
// "price": "320.79900000",
|
|
517
|
-
// "amount": "0.05000000",
|
|
518
|
-
// "type": "buy",
|
|
519
|
-
// "my_side": "buy"
|
|
520
|
-
// }
|
|
521
|
-
//
|
|
522
|
-
const marketId = this.safeString(trade, 'pair');
|
|
523
|
-
market = this.safeMarket(marketId, market, '_');
|
|
524
|
-
const timestampRaw = this.safeString(trade, 'timestamp');
|
|
525
|
-
const timestamp = this.parseToInt(Precise["default"].stringMul(timestampRaw, '1000000'));
|
|
526
|
-
const priceString = this.safeString(trade, 'price');
|
|
527
|
-
const amountString = this.safeString(trade, 'amount');
|
|
528
|
-
const id = this.safeString(trade, 'id');
|
|
529
|
-
const side = this.safeString2(trade, 'my_side', 'type');
|
|
530
|
-
return this.safeTrade({
|
|
531
|
-
'id': id,
|
|
532
|
-
'info': trade,
|
|
533
|
-
'timestamp': timestamp,
|
|
534
|
-
'datetime': this.iso8601(timestamp),
|
|
535
|
-
'symbol': market['symbol'],
|
|
536
|
-
'order': id,
|
|
537
|
-
'type': 'limit',
|
|
538
|
-
'side': side,
|
|
539
|
-
'takerOrMaker': undefined,
|
|
540
|
-
'price': priceString,
|
|
541
|
-
'amount': amountString,
|
|
542
|
-
'cost': undefined,
|
|
543
|
-
'fee': undefined,
|
|
544
|
-
}, market);
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* @method
|
|
548
|
-
* @name alp#fetchTrades
|
|
549
|
-
* @description get the list of most recent trades for a particular symbol
|
|
550
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-all-exchanges
|
|
551
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
552
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
553
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
554
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
555
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
|
|
556
|
-
*/
|
|
557
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
558
|
-
await this.loadMarkets();
|
|
559
|
-
let market = undefined;
|
|
560
|
-
const request = {};
|
|
561
|
-
if (symbol !== undefined) {
|
|
562
|
-
market = this.market(symbol);
|
|
563
|
-
request['pair'] = market['id'];
|
|
564
|
-
}
|
|
565
|
-
if (limit !== undefined) {
|
|
566
|
-
request['limit'] = limit;
|
|
567
|
-
}
|
|
568
|
-
const trades = await this.publicGetExchanges(this.extend(request, params));
|
|
569
|
-
return this.parseTrades(trades, market, since, limit);
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* @method
|
|
573
|
-
* @name alp#fetchDeposits
|
|
574
|
-
* @description fetch all deposits made to an account
|
|
575
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-deposits
|
|
576
|
-
* @param {string} code unified currency code
|
|
577
|
-
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
578
|
-
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
579
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
580
|
-
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
|
|
581
|
-
*/
|
|
582
|
-
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
583
|
-
await this.loadMarkets();
|
|
584
|
-
let currency = undefined;
|
|
585
|
-
if (code !== undefined) {
|
|
586
|
-
currency = this.currency(code);
|
|
587
|
-
}
|
|
588
|
-
const response = await this.privateGetDeposits(params);
|
|
589
|
-
//
|
|
590
|
-
// [
|
|
591
|
-
// {
|
|
592
|
-
// "timestamp": 1485363039.18359,
|
|
593
|
-
// "id": 317,
|
|
594
|
-
// "currency": "BTC",
|
|
595
|
-
// "amount": 530.00000000
|
|
596
|
-
// }
|
|
597
|
-
// ]
|
|
598
|
-
//
|
|
599
|
-
return this.parseTransactions(response, currency, since, limit, { 'type': 'deposit' });
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* @method
|
|
603
|
-
* @name alp#fetchWithdrawals
|
|
604
|
-
* @description fetch all withdrawals made from an account
|
|
605
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-made-withdraws
|
|
606
|
-
* @param {string} code unified currency code
|
|
607
|
-
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
608
|
-
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
609
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
610
|
-
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
|
|
611
|
-
*/
|
|
612
|
-
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
613
|
-
await this.loadMarkets();
|
|
614
|
-
let currency = undefined;
|
|
615
|
-
const request = {};
|
|
616
|
-
if (code !== undefined) {
|
|
617
|
-
currency = this.currency(code);
|
|
618
|
-
request['currency_id'] = currency['id'];
|
|
619
|
-
}
|
|
620
|
-
const response = await this.privateGetWithdraws(this.extend(request, params));
|
|
621
|
-
//
|
|
622
|
-
// [
|
|
623
|
-
// {
|
|
624
|
-
// "id": 403,
|
|
625
|
-
// "timestamp": 1485363466.868539,
|
|
626
|
-
// "currency": "BTC",
|
|
627
|
-
// "amount": 0.53000000,
|
|
628
|
-
// "status": 20
|
|
629
|
-
// }
|
|
630
|
-
// ]
|
|
631
|
-
//
|
|
632
|
-
return this.parseTransactions(response, currency, since, limit, { 'type': 'withdrawal' });
|
|
633
|
-
}
|
|
634
|
-
parseTransaction(transaction, currency = undefined) {
|
|
635
|
-
//
|
|
636
|
-
// deposit
|
|
637
|
-
// {
|
|
638
|
-
// "timestamp": 1485363039.18359,
|
|
639
|
-
// "id": 317,
|
|
640
|
-
// "currency": "BTC",
|
|
641
|
-
// "amount": 530.00000000
|
|
642
|
-
// }
|
|
643
|
-
//
|
|
644
|
-
// withdrawal
|
|
645
|
-
// {
|
|
646
|
-
// "id": 403,
|
|
647
|
-
// "timestamp": 1485363466.868539,
|
|
648
|
-
// "currency": "BTC",
|
|
649
|
-
// "amount": 0.53000000,
|
|
650
|
-
// "status": 20
|
|
651
|
-
// }
|
|
652
|
-
//
|
|
653
|
-
const timestamp = this.safeTimestamp(transaction, 'timestamp');
|
|
654
|
-
const currencyId = this.safeString(transaction, 'currency');
|
|
655
|
-
const statusId = this.safeString(transaction, 'status');
|
|
656
|
-
return {
|
|
657
|
-
'id': this.safeString(transaction, 'id'),
|
|
658
|
-
'info': transaction,
|
|
659
|
-
'timestamp': timestamp,
|
|
660
|
-
'datetime': this.iso8601(timestamp),
|
|
661
|
-
'network': undefined,
|
|
662
|
-
'address': undefined,
|
|
663
|
-
'addressTo': undefined,
|
|
664
|
-
'addressFrom': undefined,
|
|
665
|
-
'tag': undefined,
|
|
666
|
-
'tagTo': undefined,
|
|
667
|
-
'tagFrom': undefined,
|
|
668
|
-
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
669
|
-
'amount': this.safeNumber(transaction, 'amount'),
|
|
670
|
-
'txid': undefined,
|
|
671
|
-
'type': undefined,
|
|
672
|
-
'status': this.parseTransactionStatus(statusId),
|
|
673
|
-
'comment': undefined,
|
|
674
|
-
'internal': undefined,
|
|
675
|
-
'fee': undefined,
|
|
676
|
-
'updated': undefined,
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
parseTransactionStatus(status) {
|
|
680
|
-
const statuses = {
|
|
681
|
-
'10': 'pending',
|
|
682
|
-
'20': 'pending',
|
|
683
|
-
'30': 'ok',
|
|
684
|
-
'40': 'failed',
|
|
685
|
-
'50': 'canceled', // Cancelled by user
|
|
686
|
-
};
|
|
687
|
-
return this.safeString(statuses, status, status);
|
|
688
|
-
}
|
|
689
|
-
parseOHLCV(ohlcv, market = undefined) {
|
|
690
|
-
//
|
|
691
|
-
// {
|
|
692
|
-
// "time":1591296000,
|
|
693
|
-
// "open":0.024746,
|
|
694
|
-
// "close":0.024728,
|
|
695
|
-
// "low":0.024728,
|
|
696
|
-
// "high":0.024753,
|
|
697
|
-
// "volume":16.624
|
|
698
|
-
// }
|
|
699
|
-
//
|
|
700
|
-
return [
|
|
701
|
-
this.safeTimestamp(ohlcv, 'time'),
|
|
702
|
-
this.safeNumber(ohlcv, 'open'),
|
|
703
|
-
this.safeNumber(ohlcv, 'high'),
|
|
704
|
-
this.safeNumber(ohlcv, 'low'),
|
|
705
|
-
this.safeNumber(ohlcv, 'close'),
|
|
706
|
-
this.safeNumber(ohlcv, 'volume'),
|
|
707
|
-
];
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* @method
|
|
711
|
-
* @name alp#fetchOHLCV
|
|
712
|
-
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
713
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#charts
|
|
714
|
-
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
715
|
-
* @param {string} timeframe the length of time each candle represents
|
|
716
|
-
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
717
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
718
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
719
|
-
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
720
|
-
*/
|
|
721
|
-
async fetchOHLCV(symbol, timeframe = '5m', since = undefined, limit = undefined, params = {}) {
|
|
722
|
-
await this.loadMarkets();
|
|
723
|
-
const market = this.market(symbol);
|
|
724
|
-
const request = {
|
|
725
|
-
'pair': market['id'],
|
|
726
|
-
'type': this.safeString(this.timeframes, timeframe, timeframe),
|
|
727
|
-
};
|
|
728
|
-
if (limit !== undefined) {
|
|
729
|
-
request['limit'] = limit;
|
|
730
|
-
}
|
|
731
|
-
if (since !== undefined) {
|
|
732
|
-
request['since'] = this.parseToInt(since / 1000);
|
|
733
|
-
}
|
|
734
|
-
const response = await this.publicGetChartsPairTypeChart(this.extend(request, params));
|
|
735
|
-
//
|
|
736
|
-
// [
|
|
737
|
-
// {"time":1591296000,"open":0.024746,"close":0.024728,"low":0.024728,"high":0.024753,"volume":16.624},
|
|
738
|
-
// {"time":1591295700,"open":0.024718,"close":0.02475,"low":0.024711,"high":0.02475,"volume":31.645},
|
|
739
|
-
// {"time":1591295400,"open":0.024721,"close":0.024717,"low":0.024711,"high":0.02473,"volume":65.071}
|
|
740
|
-
// ]
|
|
741
|
-
//
|
|
742
|
-
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
743
|
-
}
|
|
744
|
-
parseBalance(response) {
|
|
745
|
-
const result = { 'info': response };
|
|
746
|
-
for (let i = 0; i < response.length; i++) {
|
|
747
|
-
const balance = response[i];
|
|
748
|
-
const currencyId = this.safeString(balance, 'currency');
|
|
749
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
750
|
-
const account = this.account();
|
|
751
|
-
account['used'] = this.safeString(balance, 'reserve');
|
|
752
|
-
account['total'] = this.safeString(balance, 'balance');
|
|
753
|
-
result[code] = account;
|
|
754
|
-
}
|
|
755
|
-
return this.safeBalance(result);
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* @method
|
|
759
|
-
* @name alp#fetchBalance
|
|
760
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
761
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-wallets
|
|
762
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
763
|
-
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
|
|
764
|
-
*/
|
|
765
|
-
async fetchBalance(params = {}) {
|
|
766
|
-
await this.loadMarkets();
|
|
767
|
-
const response = await this.privateGetWallets(params);
|
|
768
|
-
return this.parseBalance(response);
|
|
769
|
-
}
|
|
770
|
-
parseOrderStatus(status) {
|
|
771
|
-
const statuses = {
|
|
772
|
-
'1': 'open',
|
|
773
|
-
'2': 'canceled',
|
|
774
|
-
'3': 'closed',
|
|
775
|
-
};
|
|
776
|
-
return this.safeString(statuses, status, status);
|
|
777
|
-
}
|
|
778
|
-
parseOrder(order, market = undefined) {
|
|
779
|
-
//
|
|
780
|
-
// fetchClosedOrders / fetchOrder
|
|
781
|
-
// {
|
|
782
|
-
// "id": "923763073",
|
|
783
|
-
// "date": "1635451090368",
|
|
784
|
-
// "type": "sell",
|
|
785
|
-
// "pair": "XRP_USDT",
|
|
786
|
-
// "price": "1.00000000",
|
|
787
|
-
// "amount": "0.00000000",
|
|
788
|
-
// "status": "3",
|
|
789
|
-
// "amount_filled": "10.00000000",
|
|
790
|
-
// "amount_original": "10.0"
|
|
791
|
-
// "trades": [],
|
|
792
|
-
// }
|
|
793
|
-
//
|
|
794
|
-
// createOrder
|
|
795
|
-
// {
|
|
796
|
-
// "success": true,
|
|
797
|
-
// "date": "1635451754.497541",
|
|
798
|
-
// "type": "sell",
|
|
799
|
-
// "oid": "923776755",
|
|
800
|
-
// "price": "1.0",
|
|
801
|
-
// "amount": "10.0",
|
|
802
|
-
// "amount_filled": "0.0",
|
|
803
|
-
// "amount_original": "10.0",
|
|
804
|
-
// "trades": []
|
|
805
|
-
// }
|
|
806
|
-
//
|
|
807
|
-
const marketId = this.safeString(order, 'pair');
|
|
808
|
-
market = this.safeMarket(marketId, market, '_');
|
|
809
|
-
const symbol = market['symbol'];
|
|
810
|
-
const success = this.safeBool(order, 'success', false);
|
|
811
|
-
let timestamp = undefined;
|
|
812
|
-
if (success) {
|
|
813
|
-
timestamp = this.safeTimestamp(order, 'date');
|
|
814
|
-
}
|
|
815
|
-
else {
|
|
816
|
-
timestamp = this.safeInteger(order, 'date');
|
|
817
|
-
}
|
|
818
|
-
const price = this.safeString(order, 'price');
|
|
819
|
-
const remaining = this.safeString(order, 'amount');
|
|
820
|
-
const filled = this.safeString(order, 'amount_filled');
|
|
821
|
-
const amount = this.safeString(order, 'amount_original');
|
|
822
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
823
|
-
const id = this.safeStringN(order, ['oid', 'id', 'order']);
|
|
824
|
-
const trades = this.safeValue(order, 'trades');
|
|
825
|
-
const side = this.safeString2(order, 'my_side', 'type');
|
|
826
|
-
return this.safeOrder({
|
|
827
|
-
'id': id,
|
|
828
|
-
'clientOrderId': undefined,
|
|
829
|
-
'datetime': this.iso8601(timestamp),
|
|
830
|
-
'timestamp': timestamp,
|
|
831
|
-
'status': status,
|
|
832
|
-
'symbol': symbol,
|
|
833
|
-
'type': 'limit',
|
|
834
|
-
'timeInForce': undefined,
|
|
835
|
-
'postOnly': undefined,
|
|
836
|
-
'side': side,
|
|
837
|
-
'price': price,
|
|
838
|
-
'triggerPrice': undefined,
|
|
839
|
-
'cost': undefined,
|
|
840
|
-
'amount': amount,
|
|
841
|
-
'filled': filled,
|
|
842
|
-
'remaining': remaining,
|
|
843
|
-
'trades': trades,
|
|
844
|
-
'fee': undefined,
|
|
845
|
-
'info': order,
|
|
846
|
-
'lastTradeTimestamp': undefined,
|
|
847
|
-
'average': undefined,
|
|
848
|
-
}, market);
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* @method
|
|
852
|
-
* @name alp#createOrder
|
|
853
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#create-order
|
|
854
|
-
* @description create a trade order
|
|
855
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
856
|
-
* @param {string} type 'limit'
|
|
857
|
-
* @param {string} side 'buy' or 'sell'
|
|
858
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
859
|
-
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
860
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
861
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
|
|
862
|
-
*/
|
|
863
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
864
|
-
if (type === 'market') {
|
|
865
|
-
throw new errors.InvalidOrder(this.id + ' only limits orders are supported');
|
|
866
|
-
}
|
|
867
|
-
await this.loadMarkets();
|
|
868
|
-
const market = this.market(symbol);
|
|
869
|
-
const request = {
|
|
870
|
-
'pair': market['id'],
|
|
871
|
-
'type': side,
|
|
872
|
-
'amount': amount,
|
|
873
|
-
'price': this.priceToPrecision(symbol, price),
|
|
874
|
-
};
|
|
875
|
-
const response = await this.privatePostOrder(this.extend(request, params));
|
|
876
|
-
if (!response['success']) {
|
|
877
|
-
throw new errors.InvalidOrder(this.id + ' ' + this.json(response));
|
|
878
|
-
}
|
|
879
|
-
const order = this.parseOrder(response, market);
|
|
880
|
-
const orderAmount = order['amount'].toString();
|
|
881
|
-
amount = Precise["default"].stringGt(orderAmount, '0') ? order['amount'] : amount;
|
|
882
|
-
order['amount'] = this.parseNumber(amount);
|
|
883
|
-
return order;
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* @method
|
|
887
|
-
* @name alp#cancelOrder
|
|
888
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#cancel-order
|
|
889
|
-
* @description cancels an open order
|
|
890
|
-
* @param {string} id order id
|
|
891
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
892
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
893
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
|
|
894
|
-
*/
|
|
895
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
896
|
-
const request = {
|
|
897
|
-
'order': id,
|
|
898
|
-
};
|
|
899
|
-
const response = await this.privatePostOrderCancel(this.extend(request, params));
|
|
900
|
-
//
|
|
901
|
-
// {
|
|
902
|
-
// "order": 63568
|
|
903
|
-
// }
|
|
904
|
-
//
|
|
905
|
-
return this.parseOrder(response);
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* @method
|
|
909
|
-
* @name alp#fetchOrder
|
|
910
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#retrieve-single-order
|
|
911
|
-
* @description fetches information on an order made by the user
|
|
912
|
-
* @param {string} id the order id
|
|
913
|
-
* @param {string} symbol not used by alp fetchOrder
|
|
914
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
915
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
|
|
916
|
-
*/
|
|
917
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
918
|
-
await this.loadMarkets();
|
|
919
|
-
const request = {
|
|
920
|
-
'id': id,
|
|
921
|
-
};
|
|
922
|
-
const order = await this.privateGetOrderId(this.extend(request, params));
|
|
923
|
-
return this.parseOrder(order);
|
|
924
|
-
}
|
|
925
|
-
/**
|
|
926
|
-
* @method
|
|
927
|
-
* @name alp#fetchOrders
|
|
928
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-orders
|
|
929
|
-
* @description fetches information on multiple orders made by the user
|
|
930
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
931
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
932
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
933
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
934
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
|
|
935
|
-
*/
|
|
936
|
-
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
937
|
-
await this.loadMarkets();
|
|
938
|
-
const request = {};
|
|
939
|
-
let market = undefined;
|
|
940
|
-
if (symbol !== undefined) {
|
|
941
|
-
market = this.market(symbol);
|
|
942
|
-
request['pair'] = market['id'];
|
|
943
|
-
}
|
|
944
|
-
if (limit !== undefined) {
|
|
945
|
-
request['limit'] = limit;
|
|
946
|
-
}
|
|
947
|
-
const orders = await this.privateGetOrdersOwn(this.extend(request, params));
|
|
948
|
-
return this.parseOrders(orders, market, since, limit);
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* @method
|
|
952
|
-
* @name alp#fetchOpenOrders
|
|
953
|
-
* @description fetch all unfilled currently open orders
|
|
954
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-orders
|
|
955
|
-
* @param {string} symbol unified market symbol
|
|
956
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
957
|
-
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
958
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
959
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
|
|
960
|
-
*/
|
|
961
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
962
|
-
const request = {
|
|
963
|
-
'status': '1',
|
|
964
|
-
};
|
|
965
|
-
return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* @method
|
|
969
|
-
* @name alp#fetchClosedOrders
|
|
970
|
-
* @description fetches information on multiple closed orders made by the user
|
|
971
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-orders
|
|
972
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
973
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
974
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
975
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
976
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
|
|
977
|
-
*/
|
|
978
|
-
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
979
|
-
const request = {
|
|
980
|
-
'status': '3',
|
|
981
|
-
};
|
|
982
|
-
return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
* @method
|
|
986
|
-
* @name alp#fetchMyTrades
|
|
987
|
-
* @description fetch all trades made by the user
|
|
988
|
-
* @see https://alpcomdev.github.io/alp-api-docs/#list-own-exchanges
|
|
989
|
-
* @param {string} symbol unified market symbol
|
|
990
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
991
|
-
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
992
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
993
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
|
|
994
|
-
*/
|
|
995
|
-
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
996
|
-
await this.loadMarkets();
|
|
997
|
-
const request = {};
|
|
998
|
-
if (symbol !== undefined) {
|
|
999
|
-
const market = this.market(symbol);
|
|
1000
|
-
request['pair'] = market['id'];
|
|
1001
|
-
}
|
|
1002
|
-
if (limit !== undefined) {
|
|
1003
|
-
request['limit'] = limit;
|
|
1004
|
-
}
|
|
1005
|
-
const trades = await this.privateGetExchangesOwn(this.extend(request, params));
|
|
1006
|
-
return this.parseTrades(trades, undefined, since, limit);
|
|
1007
|
-
}
|
|
1008
|
-
nonce() {
|
|
1009
|
-
return this.milliseconds();
|
|
1010
|
-
}
|
|
1011
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1012
|
-
const query = this.urlencode(this.keysort(this.omit(params, this.extractParams(path))));
|
|
1013
|
-
let url = this.urls['api']['rest'] + '/';
|
|
1014
|
-
if (path !== 'charts/{pair}/{type}/chart/') {
|
|
1015
|
-
url += 'v1/';
|
|
1016
|
-
}
|
|
1017
|
-
url += this.implodeParams(path, params);
|
|
1018
|
-
headers = { 'Accept': 'application/json' };
|
|
1019
|
-
if (api === 'public') {
|
|
1020
|
-
if (query.length) {
|
|
1021
|
-
url += '?' + query;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
else {
|
|
1025
|
-
this.checkRequiredCredentials();
|
|
1026
|
-
let payload = this.apiKey;
|
|
1027
|
-
if (method === 'POST') {
|
|
1028
|
-
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
1029
|
-
body = query;
|
|
1030
|
-
payload += body;
|
|
1031
|
-
}
|
|
1032
|
-
else if (query.length) {
|
|
1033
|
-
url += '?' + query;
|
|
1034
|
-
}
|
|
1035
|
-
headers['X-KEY'] = this.apiKey;
|
|
1036
|
-
headers['X-SIGN'] = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256);
|
|
1037
|
-
headers['X-NONCE'] = this.nonce().toString();
|
|
1038
|
-
}
|
|
1039
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1040
|
-
}
|
|
1041
|
-
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1042
|
-
if (response === undefined) {
|
|
1043
|
-
return undefined; // fallback to default error handler
|
|
1044
|
-
}
|
|
1045
|
-
//
|
|
1046
|
-
// {"date":1570599531.4814300537,"error":"Out of balance -9.99243661 BTC"}
|
|
1047
|
-
//
|
|
1048
|
-
const error = this.safeString(response, 'error');
|
|
1049
|
-
if (error !== undefined) {
|
|
1050
|
-
const feedback = this.id + ' ' + body;
|
|
1051
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], error, feedback);
|
|
1052
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], error, feedback);
|
|
1053
|
-
throw new errors.ExchangeError(feedback); // unknown error
|
|
1054
|
-
}
|
|
1055
|
-
return undefined;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
exports["default"] = alp;
|