ccxt-ir 4.13.0 → 4.14.0
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 +4 -4
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/changefa.js +1 -1
- package/dist/cjs/src/hamtapay.js +48 -59
- package/dist/cjs/src/kifpoolme.js +2 -2
- package/dist/cjs/src/saraf.js +310 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/hamtapay.d.ts +0 -1
- package/js/src/abstract/saraf.d.ts +8 -0
- package/js/src/abstract/saraf.js +11 -0
- package/js/src/changefa.js +1 -1
- package/js/src/hamtapay.js +48 -59
- package/js/src/kifpoolme.js +2 -2
- package/js/src/saraf.d.ts +21 -0
- package/js/src/saraf.js +309 -0
- package/js/test.js +67 -71
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { implicitReturnType } from '../base/types.js';
|
|
|
2
2
|
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
3
3
|
interface Exchange {
|
|
4
4
|
publicGetFinancialApiMarket(params?: {}): Promise<implicitReturnType>;
|
|
5
|
-
publicGetFinancialApiVitrinPrices(params?: {}): Promise<implicitReturnType>;
|
|
6
5
|
}
|
|
7
6
|
declare abstract class Exchange extends _Exchange {
|
|
8
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { implicitReturnType } from '../base/types.js';
|
|
2
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
3
|
+
interface Exchange {
|
|
4
|
+
publicGetV3PricesCrypto(params?: {}): Promise<implicitReturnType>;
|
|
5
|
+
}
|
|
6
|
+
declare abstract class Exchange extends _Exchange {
|
|
7
|
+
}
|
|
8
|
+
export default Exchange;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// -------------------------------------------------------------------------------
|
|
8
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
9
|
+
class Exchange extends _Exchange {
|
|
10
|
+
}
|
|
11
|
+
export default Exchange;
|
package/js/src/changefa.js
CHANGED
|
@@ -227,7 +227,7 @@ export default class changefa extends Exchange {
|
|
|
227
227
|
const buyPrice = this.safeNumber(ticker, 'buyPrice');
|
|
228
228
|
const sellPrice = this.safeNumber(ticker, 'sellPrice');
|
|
229
229
|
if ((buyPrice !== undefined) && (sellPrice !== undefined)) {
|
|
230
|
-
last =
|
|
230
|
+
last = sellPrice;
|
|
231
231
|
}
|
|
232
232
|
const weeklyPriceLog = this.safeList(ticker, 'weeklyPriceLog', []);
|
|
233
233
|
let high = undefined;
|
package/js/src/hamtapay.js
CHANGED
|
@@ -89,7 +89,7 @@ export default class hamtapay extends Exchange {
|
|
|
89
89
|
'urls': {
|
|
90
90
|
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/hamtapay/64x64.png',
|
|
91
91
|
'api': {
|
|
92
|
-
'public': 'https://
|
|
92
|
+
'public': 'https://oapi.hamtapay.org',
|
|
93
93
|
},
|
|
94
94
|
'www': 'https://hamtapay.net/',
|
|
95
95
|
'doc': [
|
|
@@ -100,7 +100,6 @@ export default class hamtapay extends Exchange {
|
|
|
100
100
|
'public': {
|
|
101
101
|
'get': {
|
|
102
102
|
'/financial/api/market': 1,
|
|
103
|
-
'/financial/api/vitrin/prices': 1,
|
|
104
103
|
},
|
|
105
104
|
},
|
|
106
105
|
},
|
|
@@ -119,7 +118,7 @@ export default class hamtapay extends Exchange {
|
|
|
119
118
|
* @method
|
|
120
119
|
* @name hamtapay#fetchMarkets
|
|
121
120
|
* @description retrieves data on all markets for hamtapay
|
|
122
|
-
* @see https://
|
|
121
|
+
* @see https://oapi.hamtapay.org/financial/api/market
|
|
123
122
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
124
123
|
* @returns {object[]} an array of objects representing market data
|
|
125
124
|
*/
|
|
@@ -156,8 +155,8 @@ export default class hamtapay extends Exchange {
|
|
|
156
155
|
'baseId': baseId,
|
|
157
156
|
'quoteId': quoteId,
|
|
158
157
|
'settleId': undefined,
|
|
159
|
-
'type': '
|
|
160
|
-
'spot':
|
|
158
|
+
'type': 'spot',
|
|
159
|
+
'spot': true,
|
|
161
160
|
'margin': false,
|
|
162
161
|
'swap': false,
|
|
163
162
|
'future': false,
|
|
@@ -172,8 +171,8 @@ export default class hamtapay extends Exchange {
|
|
|
172
171
|
'strike': undefined,
|
|
173
172
|
'optionType': undefined,
|
|
174
173
|
'precision': {
|
|
175
|
-
'amount':
|
|
176
|
-
'price':
|
|
174
|
+
'amount': this.safeInteger(market, 'amount_decimals'),
|
|
175
|
+
'price': this.safeInteger(market, 'price_decimals'),
|
|
177
176
|
},
|
|
178
177
|
'limits': {
|
|
179
178
|
'leverage': {
|
|
@@ -202,7 +201,7 @@ export default class hamtapay extends Exchange {
|
|
|
202
201
|
* @method
|
|
203
202
|
* @name hamtapay#fetchTickers
|
|
204
203
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
205
|
-
* @see https://
|
|
204
|
+
* @see https://oapi.hamtapay.org/financial/api/market
|
|
206
205
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
207
206
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
208
207
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -211,23 +210,12 @@ export default class hamtapay extends Exchange {
|
|
|
211
210
|
if (symbols !== undefined) {
|
|
212
211
|
symbols = this.marketSymbols(symbols);
|
|
213
212
|
}
|
|
214
|
-
const response = await this.
|
|
215
|
-
const data = this.
|
|
213
|
+
const response = await this.publicGetFinancialApiMarket(params);
|
|
214
|
+
const data = this.safeList(response, 'data', []);
|
|
216
215
|
const result = {};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const corresponding_data = this.safeDict(data, current_qoute, {});
|
|
221
|
-
const baseSymbols = Object.keys(corresponding_data);
|
|
222
|
-
for (let j = 0; j < baseSymbols.length; j++) {
|
|
223
|
-
const current_base = baseSymbols[j];
|
|
224
|
-
const current_ticker = corresponding_data[current_base];
|
|
225
|
-
current_ticker['base'] = current_base;
|
|
226
|
-
current_ticker['quote'] = current_qoute;
|
|
227
|
-
current_ticker['symbol'] = current_base + '/' + current_qoute;
|
|
228
|
-
current_ticker['id'] = current_base + '-' + current_qoute;
|
|
229
|
-
result[current_ticker['symbol']] = this.parseTicker(current_ticker);
|
|
230
|
-
}
|
|
216
|
+
for (let i = 0; i < data.length; i++) {
|
|
217
|
+
const ticker = this.parseTicker(data[i]);
|
|
218
|
+
result[ticker['symbol']] = ticker;
|
|
231
219
|
}
|
|
232
220
|
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
233
221
|
}
|
|
@@ -236,48 +224,41 @@ export default class hamtapay extends Exchange {
|
|
|
236
224
|
* @method
|
|
237
225
|
* @name hamtapay#fetchTicker
|
|
238
226
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
239
|
-
* @see https://hamtapay.
|
|
227
|
+
* @see https://oapi.hamtapay.org/financial/api/market
|
|
240
228
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
241
229
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
242
230
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
243
231
|
*/
|
|
244
|
-
const
|
|
245
|
-
return
|
|
232
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
233
|
+
return tickers[symbol];
|
|
246
234
|
}
|
|
247
235
|
parseTicker(ticker, market = undefined) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
266
|
-
const last = this.safeFloat(ticker, 'buy_price', 0);
|
|
267
|
-
const change = this.safeFloat(ticker, 'change_rate_24h', 0);
|
|
268
|
-
const ask = this.safeFloat(ticker, 'buy_price', 0);
|
|
269
|
-
const bid = this.safeFloat(ticker, 'sell_price', 0);
|
|
270
|
-
const high = this.safeFloat(ticker, 'max_price_24h', 0);
|
|
271
|
-
const low = this.safeFloat(ticker, 'min_price_24h', 0);
|
|
236
|
+
const marketType = 'spot';
|
|
237
|
+
const marketId = this.safeString2(ticker, 'id', 'symbol');
|
|
238
|
+
const baseId = this.safeString(ticker, 'base');
|
|
239
|
+
const quoteId = this.safeString(ticker, 'quote');
|
|
240
|
+
const base = this.safeCurrencyCode(baseId);
|
|
241
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
242
|
+
let symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
243
|
+
if ((baseId !== undefined) && (quoteId !== undefined)) {
|
|
244
|
+
symbol = base + '/' + quote;
|
|
245
|
+
}
|
|
246
|
+
const last = this.safeFloat(ticker, 'last_price');
|
|
247
|
+
const baseVolume = this.safeFloat(ticker, 'volume_24h');
|
|
248
|
+
const percentage = this.safeFloat(ticker, 'percent_change_24h');
|
|
249
|
+
let quoteVolume = undefined;
|
|
250
|
+
if ((baseVolume !== undefined) && (last !== undefined)) {
|
|
251
|
+
quoteVolume = baseVolume * last;
|
|
252
|
+
}
|
|
272
253
|
return this.safeTicker({
|
|
273
254
|
'symbol': symbol,
|
|
274
255
|
'timestamp': undefined,
|
|
275
256
|
'datetime': undefined,
|
|
276
|
-
'high':
|
|
277
|
-
'low':
|
|
278
|
-
'bid':
|
|
257
|
+
'high': undefined,
|
|
258
|
+
'low': undefined,
|
|
259
|
+
'bid': undefined,
|
|
279
260
|
'bidVolume': undefined,
|
|
280
|
-
'ask':
|
|
261
|
+
'ask': undefined,
|
|
281
262
|
'askVolume': undefined,
|
|
282
263
|
'vwap': undefined,
|
|
283
264
|
'open': undefined,
|
|
@@ -285,15 +266,23 @@ export default class hamtapay extends Exchange {
|
|
|
285
266
|
'last': last,
|
|
286
267
|
'previousClose': undefined,
|
|
287
268
|
'change': undefined,
|
|
288
|
-
'percentage':
|
|
269
|
+
'percentage': percentage,
|
|
289
270
|
'average': undefined,
|
|
290
|
-
'baseVolume':
|
|
291
|
-
'quoteVolume':
|
|
271
|
+
'baseVolume': baseVolume,
|
|
272
|
+
'quoteVolume': quoteVolume,
|
|
292
273
|
'info': ticker,
|
|
293
274
|
}, market);
|
|
294
275
|
}
|
|
295
276
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
296
|
-
const
|
|
277
|
+
const query = this.omit(params, this.extractParams(path));
|
|
278
|
+
let normalizedPath = path;
|
|
279
|
+
while (normalizedPath.length && normalizedPath[0] === '/') {
|
|
280
|
+
normalizedPath = normalizedPath.slice(1);
|
|
281
|
+
}
|
|
282
|
+
let url = this.urls['api']['public'] + '/' + this.implodeParams(normalizedPath, params);
|
|
283
|
+
if (Object.keys(query).length) {
|
|
284
|
+
url += '?' + this.urlencode(query);
|
|
285
|
+
}
|
|
297
286
|
headers = {
|
|
298
287
|
'Content-Type': 'application/json',
|
|
299
288
|
'Origin': 'https://hamtapay.net',
|
package/js/src/kifpoolme.js
CHANGED
|
@@ -310,8 +310,8 @@ export default class kifpoolme extends Exchange {
|
|
|
310
310
|
let ask = undefined;
|
|
311
311
|
if (quoteId === 'IRT') {
|
|
312
312
|
// For IRT: priceSellIRT is the sell price (bid), priceBuyIRT is the buy price (ask)
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
ask = this.safeNumber(ticker, 'priceSellIRT');
|
|
314
|
+
bid = this.safeNumber(ticker, 'priceBuyIRT');
|
|
315
315
|
last = ask;
|
|
316
316
|
}
|
|
317
317
|
else {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Exchange from './base/Exchange.js';
|
|
2
|
+
import { Market, Strings, Ticker, Tickers } from './base/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @class saraf
|
|
5
|
+
* @augments Exchange
|
|
6
|
+
* @description Set rateLimit to 1000 if fully verified
|
|
7
|
+
*/
|
|
8
|
+
export default class saraf extends Exchange {
|
|
9
|
+
describe(): any;
|
|
10
|
+
parseMarket(market: any): Market;
|
|
11
|
+
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
12
|
+
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
|
+
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
14
|
+
parseTicker(ticker: any, market?: Market): Ticker;
|
|
15
|
+
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
16
|
+
url: string;
|
|
17
|
+
method: string;
|
|
18
|
+
body: any;
|
|
19
|
+
headers: any;
|
|
20
|
+
};
|
|
21
|
+
}
|
package/js/src/saraf.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
import Exchange from './base/Exchange.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* @class saraf
|
|
12
|
+
* @augments Exchange
|
|
13
|
+
* @description Set rateLimit to 1000 if fully verified
|
|
14
|
+
*/
|
|
15
|
+
export default class saraf extends Exchange {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'saraf',
|
|
19
|
+
'name': 'Saraf',
|
|
20
|
+
'countries': ['IR'],
|
|
21
|
+
'rateLimit': 1000,
|
|
22
|
+
'version': '3',
|
|
23
|
+
'certified': false,
|
|
24
|
+
'pro': false,
|
|
25
|
+
'has': {
|
|
26
|
+
'CORS': undefined,
|
|
27
|
+
'spot': false,
|
|
28
|
+
'margin': false,
|
|
29
|
+
'swap': false,
|
|
30
|
+
'future': false,
|
|
31
|
+
'option': false,
|
|
32
|
+
'addMargin': false,
|
|
33
|
+
'cancelAllOrders': false,
|
|
34
|
+
'cancelOrder': false,
|
|
35
|
+
'cancelOrders': false,
|
|
36
|
+
'createDepositAddress': false,
|
|
37
|
+
'createOrder': false,
|
|
38
|
+
'createStopLimitOrder': false,
|
|
39
|
+
'createStopMarketOrder': false,
|
|
40
|
+
'createStopOrder': false,
|
|
41
|
+
'editOrder': false,
|
|
42
|
+
'fetchBalance': false,
|
|
43
|
+
'fetchBorrowInterest': false,
|
|
44
|
+
'fetchBorrowRateHistories': false,
|
|
45
|
+
'fetchBorrowRateHistory': false,
|
|
46
|
+
'fetchClosedOrders': false,
|
|
47
|
+
'fetchCrossBorrowRate': false,
|
|
48
|
+
'fetchCrossBorrowRates': false,
|
|
49
|
+
'fetchCurrencies': false,
|
|
50
|
+
'fetchDepositAddress': false,
|
|
51
|
+
'fetchDeposits': false,
|
|
52
|
+
'fetchFundingHistory': false,
|
|
53
|
+
'fetchFundingRate': false,
|
|
54
|
+
'fetchFundingRateHistory': false,
|
|
55
|
+
'fetchFundingRates': false,
|
|
56
|
+
'fetchIndexOHLCV': false,
|
|
57
|
+
'fetchIsolatedBorrowRate': false,
|
|
58
|
+
'fetchIsolatedBorrowRates': false,
|
|
59
|
+
'fetchL2OrderBook': false,
|
|
60
|
+
'fetchL3OrderBook': false,
|
|
61
|
+
'fetchLedger': false,
|
|
62
|
+
'fetchLedgerEntry': false,
|
|
63
|
+
'fetchLeverageTiers': false,
|
|
64
|
+
'fetchMarkets': true,
|
|
65
|
+
'fetchMarkOHLCV': false,
|
|
66
|
+
'fetchMyTrades': false,
|
|
67
|
+
'fetchOHLCV': false,
|
|
68
|
+
'fetchOpenInterestHistory': false,
|
|
69
|
+
'fetchOpenOrders': false,
|
|
70
|
+
'fetchOrder': false,
|
|
71
|
+
'fetchOrderBook': false,
|
|
72
|
+
'fetchOrders': false,
|
|
73
|
+
'fetchOrderTrades': 'emulated',
|
|
74
|
+
'fetchPositions': false,
|
|
75
|
+
'fetchPremiumIndexOHLCV': false,
|
|
76
|
+
'fetchTicker': true,
|
|
77
|
+
'fetchTickers': true,
|
|
78
|
+
'fetchTime': false,
|
|
79
|
+
'fetchTrades': false,
|
|
80
|
+
'fetchTradingFee': false,
|
|
81
|
+
'fetchTradingFees': false,
|
|
82
|
+
'fetchWithdrawals': false,
|
|
83
|
+
'otc': true,
|
|
84
|
+
'setLeverage': false,
|
|
85
|
+
'setMarginMode': false,
|
|
86
|
+
'transfer': false,
|
|
87
|
+
'withdraw': false,
|
|
88
|
+
},
|
|
89
|
+
'options': {
|
|
90
|
+
'defaultType': 'otc',
|
|
91
|
+
},
|
|
92
|
+
'urls': {
|
|
93
|
+
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/saraf/64x64.png',
|
|
94
|
+
'api': {
|
|
95
|
+
'public': 'https://api.saraf.app',
|
|
96
|
+
},
|
|
97
|
+
'www': 'https://saraf.app',
|
|
98
|
+
'doc': [
|
|
99
|
+
'https://saraf.app',
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
'api': {
|
|
103
|
+
'public': {
|
|
104
|
+
'get': {
|
|
105
|
+
'v3/prices/crypto': 1,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
'fees': {
|
|
110
|
+
'trading': {
|
|
111
|
+
'tierBased': false,
|
|
112
|
+
'percentage': true,
|
|
113
|
+
'maker': this.parseNumber('0'),
|
|
114
|
+
'taker': this.parseNumber('0'),
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
parseMarket(market) {
|
|
120
|
+
const baseId = this.safeString(market, 's');
|
|
121
|
+
const quoteId = 'IRT';
|
|
122
|
+
const base = this.safeCurrencyCode(baseId);
|
|
123
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
124
|
+
return {
|
|
125
|
+
'id': baseId,
|
|
126
|
+
'symbol': base + '/' + quote,
|
|
127
|
+
'base': base,
|
|
128
|
+
'quote': quote,
|
|
129
|
+
'settle': undefined,
|
|
130
|
+
'baseId': baseId,
|
|
131
|
+
'quoteId': quoteId,
|
|
132
|
+
'settleId': undefined,
|
|
133
|
+
'type': 'otc',
|
|
134
|
+
'spot': false,
|
|
135
|
+
'margin': false,
|
|
136
|
+
'swap': false,
|
|
137
|
+
'future': false,
|
|
138
|
+
'option': false,
|
|
139
|
+
'active': this.safeBool(market, 'ct', true),
|
|
140
|
+
'contract': false,
|
|
141
|
+
'linear': undefined,
|
|
142
|
+
'inverse': undefined,
|
|
143
|
+
'contractSize': undefined,
|
|
144
|
+
'expiry': undefined,
|
|
145
|
+
'expiryDatetime': undefined,
|
|
146
|
+
'strike': undefined,
|
|
147
|
+
'optionType': undefined,
|
|
148
|
+
'precision': {
|
|
149
|
+
'amount': undefined,
|
|
150
|
+
'price': this.safeInteger(market, 'r'),
|
|
151
|
+
},
|
|
152
|
+
'limits': {
|
|
153
|
+
'leverage': {
|
|
154
|
+
'min': undefined,
|
|
155
|
+
'max': undefined,
|
|
156
|
+
},
|
|
157
|
+
'amount': {
|
|
158
|
+
'min': undefined,
|
|
159
|
+
'max': undefined,
|
|
160
|
+
},
|
|
161
|
+
'price': {
|
|
162
|
+
'min': undefined,
|
|
163
|
+
'max': undefined,
|
|
164
|
+
},
|
|
165
|
+
'cost': {
|
|
166
|
+
'min': undefined,
|
|
167
|
+
'max': undefined,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
'created': undefined,
|
|
171
|
+
'info': market,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async fetchMarkets(params = {}) {
|
|
175
|
+
/**
|
|
176
|
+
* @method
|
|
177
|
+
* @name saraf#fetchMarkets
|
|
178
|
+
* @description retrieves data on all markets for saraf
|
|
179
|
+
* @see https://api.saraf.app/v3/prices/crypto
|
|
180
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
181
|
+
* @returns {object[]} an array of objects representing market data
|
|
182
|
+
*/
|
|
183
|
+
const response = await this.publicGetV3PricesCrypto(params);
|
|
184
|
+
const price = this.safeDict(response, 'price', {});
|
|
185
|
+
const items = this.safeDict(price, 'Items', {});
|
|
186
|
+
const lastUpdateTime = this.safeInteger(price, 'lastUpdateTime');
|
|
187
|
+
const itemKeys = Object.keys(items);
|
|
188
|
+
const result = [];
|
|
189
|
+
for (let i = 0; i < itemKeys.length; i++) {
|
|
190
|
+
const item = this.safeDict(items, itemKeys[i], {});
|
|
191
|
+
item['lastUpdateTime'] = lastUpdateTime;
|
|
192
|
+
const baseId = this.safeString(item, 's');
|
|
193
|
+
if ((baseId === undefined) || (baseId === 'IRT')) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
result.push(this.parseMarket(item));
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
201
|
+
/**
|
|
202
|
+
* @method
|
|
203
|
+
* @name saraf#fetchTickers
|
|
204
|
+
* @description fetches price tickers for multiple markets
|
|
205
|
+
* @see https://api.saraf.app/v3/prices/crypto
|
|
206
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
207
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
208
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
209
|
+
*/
|
|
210
|
+
await this.loadMarkets();
|
|
211
|
+
if (symbols !== undefined) {
|
|
212
|
+
symbols = this.marketSymbols(symbols);
|
|
213
|
+
}
|
|
214
|
+
const response = await this.publicGetV3PricesCrypto(params);
|
|
215
|
+
const price = this.safeDict(response, 'price', {});
|
|
216
|
+
const items = this.safeDict(price, 'Items', {});
|
|
217
|
+
const lastUpdateTime = this.safeInteger(price, 'lastUpdateTime');
|
|
218
|
+
const itemKeys = Object.keys(items);
|
|
219
|
+
const result = {};
|
|
220
|
+
for (let i = 0; i < itemKeys.length; i++) {
|
|
221
|
+
const item = this.safeDict(items, itemKeys[i], {});
|
|
222
|
+
item['lastUpdateTime'] = lastUpdateTime;
|
|
223
|
+
const baseId = this.safeString(item, 's');
|
|
224
|
+
if ((baseId === undefined) || (baseId === 'IRT') || (baseId === 'FIXED')) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const ticker = this.parseTicker(item);
|
|
228
|
+
result[ticker['symbol']] = ticker;
|
|
229
|
+
}
|
|
230
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
231
|
+
}
|
|
232
|
+
async fetchTicker(symbol, params = {}) {
|
|
233
|
+
/**
|
|
234
|
+
* @method
|
|
235
|
+
* @name saraf#fetchTicker
|
|
236
|
+
* @description fetches a price ticker, a statistical calculation for a specific market
|
|
237
|
+
* @see https://api.saraf.app/v3/prices/crypto
|
|
238
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
239
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
240
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
241
|
+
*/
|
|
242
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
243
|
+
return tickers[symbol];
|
|
244
|
+
}
|
|
245
|
+
parseTicker(ticker, market = undefined) {
|
|
246
|
+
const baseId = this.safeString(ticker, 's');
|
|
247
|
+
const quoteId = 'IRT';
|
|
248
|
+
const base = this.safeCurrencyCode(baseId);
|
|
249
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
250
|
+
const symbol = base + '/' + quote;
|
|
251
|
+
const history = this.safeList(ticker, 'h', []);
|
|
252
|
+
let high = undefined;
|
|
253
|
+
let low = undefined;
|
|
254
|
+
let open = undefined;
|
|
255
|
+
if (history.length > 0) {
|
|
256
|
+
high = this.safeNumber(history, 0);
|
|
257
|
+
low = this.safeNumber(history, 0);
|
|
258
|
+
open = this.safeNumber(history, history.length - 1);
|
|
259
|
+
for (let i = 1; i < history.length; i++) {
|
|
260
|
+
const price = this.safeNumber(history, i);
|
|
261
|
+
high = Math.max(high, price);
|
|
262
|
+
low = Math.min(low, price);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const last = this.safeNumber(ticker, 'p');
|
|
266
|
+
const percentage = this.safeNumber(ticker, 'c');
|
|
267
|
+
const timestamp = this.safeInteger2(ticker, 'ut', 'lastUpdateTime');
|
|
268
|
+
let change = undefined;
|
|
269
|
+
if ((last !== undefined) && (open !== undefined)) {
|
|
270
|
+
change = last - open;
|
|
271
|
+
}
|
|
272
|
+
if (market === undefined) {
|
|
273
|
+
market = this.safeMarketStructure(this.parseMarket(ticker));
|
|
274
|
+
}
|
|
275
|
+
return this.safeTicker({
|
|
276
|
+
'symbol': symbol,
|
|
277
|
+
'timestamp': timestamp,
|
|
278
|
+
'datetime': this.iso8601(timestamp),
|
|
279
|
+
'high': high,
|
|
280
|
+
'low': low,
|
|
281
|
+
'bid': undefined,
|
|
282
|
+
'bidVolume': undefined,
|
|
283
|
+
'ask': undefined,
|
|
284
|
+
'askVolume': undefined,
|
|
285
|
+
'vwap': undefined,
|
|
286
|
+
'open': open,
|
|
287
|
+
'close': last,
|
|
288
|
+
'last': last,
|
|
289
|
+
'previousClose': undefined,
|
|
290
|
+
'change': change,
|
|
291
|
+
'percentage': percentage,
|
|
292
|
+
'average': undefined,
|
|
293
|
+
'baseVolume': undefined,
|
|
294
|
+
'quoteVolume': undefined,
|
|
295
|
+
'info': ticker,
|
|
296
|
+
}, market);
|
|
297
|
+
}
|
|
298
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
299
|
+
const query = this.omit(params, this.extractParams(path));
|
|
300
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
301
|
+
if (Object.keys(query).length) {
|
|
302
|
+
url += '?' + this.urlencode(query);
|
|
303
|
+
}
|
|
304
|
+
headers = {
|
|
305
|
+
'Content-Type': 'application/json',
|
|
306
|
+
};
|
|
307
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
308
|
+
}
|
|
309
|
+
}
|