ccxt-ir 4.9.29 → 4.9.32

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/js/src/raastin.js CHANGED
@@ -4,363 +4,363 @@
4
4
  // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
- // ---------------------------------------------------------------------------
8
- import Exchange from './abstract/raastin.js';
9
- // ---------------------------------------------------------------------------
10
- /**
11
- * @class raastin
12
- * @augments Exchange
13
- * @description Set rateLimit to 1000 if fully verified
14
- */
15
- export default class raastin extends Exchange {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'raastin',
19
- 'name': 'Raastin',
20
- 'countries': ['IR'],
21
- 'rateLimit': 1000,
22
- 'version': '1',
23
- 'certified': false,
24
- 'pro': false,
25
- 'has': {
26
- 'CORS': undefined,
27
- 'spot': true,
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': true,
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
- 'setLeverage': false,
84
- 'setMarginMode': false,
85
- 'transfer': false,
86
- 'withdraw': false,
87
- },
88
- 'comment': 'This comment is optional',
89
- 'urls': {
90
- 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/raastin/64x64.png',
91
- 'api': {
92
- 'public': 'https://api.raastin.com',
93
- },
94
- 'www': 'https://raastin.com',
95
- 'doc': [
96
- 'https://api.raastin.com/docs',
97
- ],
98
- },
99
- 'api': {
100
- 'public': {
101
- 'get': {
102
- 'api/v1/market/symbols': 1,
103
- 'api/v1/market/symbols/{symbol}/': 1,
104
- 'api/v1/market/depth/{symbol}': 1,
105
- },
106
- },
107
- },
108
- 'fees': {
109
- 'trading': {
110
- 'tierBased': false,
111
- 'percentage': true,
112
- 'maker': this.parseNumber('0'),
113
- 'taker': this.parseNumber('0.002'),
114
- },
115
- },
116
- });
117
- }
118
- async fetchMarkets(params = {}) {
119
- /**
120
- * @method
121
- * @name raastin#fetchMarkets
122
- * @description retrieves data on all markets for raastin
123
- * @param {object} [params] extra parameters specific to the exchange API endpoint
124
- * @returns {object[]} an array of objects representing market data
125
- */
126
- const response = await this.publicGetApiV1MarketSymbols(params);
127
- // Response is a flat array, not nested in 'result'
128
- const markets = response;
129
- const result = [];
130
- for (let i = 0; i < markets.length; i++) {
131
- const market = this.parseMarket(markets[i]);
132
- result.push(market);
133
- }
134
- return result;
135
- }
136
- parseMarket(market) {
137
- // {
138
- // "id": 1,
139
- // "name": "USDTIRT",
140
- // "asset": {
141
- // "id": 4,
142
- // "symbol": "USDT",
143
- // "precision": 8,
144
- // "step_size": 8,
145
- // "name": "tether",
146
- // "name_fa": "تتر",
147
- // "logo": "https://cdn.raastin.com/core-media-public/coins/logo/USDT.png",
148
- // "original_symbol": "USDT",
149
- // "original_name_fa": "تتر",
150
- // "trading_view_symbol": "BINANCE:USDTUSDT.P",
151
- // "otc_status": "active",
152
- // "price_page": true
153
- // },
154
- // "base_asset": {
155
- // "id": 1,
156
- // "symbol": "IRT",
157
- // "precision": 0,
158
- // "step_size": 8,
159
- // "name": "toman",
160
- // "name_fa": "تومان",
161
- // "logo": "https://cdn.raastin.com/core-media-public/coins/logo/IRT.png",
162
- // "original_symbol": "IRT",
163
- // "original_name_fa": "تومان",
164
- // "trading_view_symbol": "",
165
- // "otc_status": "active",
166
- // "price_page": true
167
- // },
168
- // "taker_fee": "0.002",
169
- // "maker_fee": "0",
170
- // "tick_size": 0,
171
- // "step_size": 2,
172
- // "min_trade_quantity": "0",
173
- // "max_trade_quantity": "1000000000000000000",
174
- // "enable": true,
175
- // "bookmark": false,
176
- // "margin_enable": true,
177
- // "strategy_enable": true
178
- // }
179
- const id = this.safeString(market, 'name');
180
- const asset = this.safeDict(market, 'asset', {});
181
- const baseAsset = this.safeDict(market, 'base_asset', {});
182
- let baseId = this.safeString(asset, 'symbol');
183
- let quoteId = this.safeString(baseAsset, 'symbol');
184
- const base = this.safeCurrencyCode(baseId);
185
- const quote = this.safeCurrencyCode(quoteId);
186
- baseId = baseId.toLowerCase();
187
- quoteId = quoteId.toLowerCase();
188
- const basePrecision = this.safeInteger(asset, 'precision');
189
- const quotePrecision = this.safeInteger(baseAsset, 'precision');
190
- const minAmount = this.safeString(market, 'min_trade_quantity');
191
- const maxAmount = this.safeString(market, 'max_trade_quantity');
192
- const enabled = this.safeBool(market, 'enable', true);
193
- const marginEnabled = this.safeBool(market, 'margin_enable', false);
194
- return {
195
- 'id': id,
196
- 'symbol': base + '/' + quote,
197
- 'base': base,
198
- 'quote': quote,
199
- 'settle': undefined,
200
- 'baseId': baseId,
201
- 'quoteId': quoteId,
202
- 'settleId': undefined,
203
- 'type': 'spot',
204
- 'spot': true,
205
- 'margin': marginEnabled,
206
- 'swap': false,
207
- 'future': false,
208
- 'option': false,
209
- 'active': enabled,
210
- 'contract': false,
211
- 'linear': undefined,
212
- 'inverse': undefined,
213
- 'contractSize': undefined,
214
- 'expiry': undefined,
215
- 'expiryDatetime': undefined,
216
- 'strike': undefined,
217
- 'optionType': undefined,
218
- 'precision': {
219
- 'amount': basePrecision,
220
- 'price': quotePrecision,
221
- },
222
- 'limits': {
223
- 'leverage': {
224
- 'min': undefined,
225
- 'max': undefined,
226
- },
227
- 'amount': {
228
- 'min': this.parseNumber(minAmount),
229
- 'max': this.parseNumber(maxAmount),
230
- },
231
- 'price': {
232
- 'min': undefined,
233
- 'max': undefined,
234
- },
235
- 'cost': {
236
- 'min': undefined,
237
- 'max': undefined,
238
- },
239
- },
240
- 'created': undefined,
241
- 'info': market,
242
- };
243
- }
244
- async fetchTickers(symbols = undefined, params = {}) {
245
- /**
246
- * @method
247
- * @name raastin#fetchTickers
248
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
249
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
250
- * @param {object} [params] extra parameters specific to the exchange API endpoint
251
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
252
- */
253
- await this.loadMarkets();
254
- if (symbols !== undefined) {
255
- symbols = this.marketSymbols(symbols);
256
- }
257
- const response = await this.publicGetApiV1MarketSymbols(params);
258
- const markets = this.safeList(response, response);
259
- const result = {};
260
- for (let i = 0; i < markets.length; i++) {
261
- const marketData = markets[i];
262
- const ticker = this.parseTicker(marketData);
263
- const symbol = ticker['symbol'];
264
- result[symbol] = ticker;
265
- }
266
- return this.filterByArrayTickers(result, 'symbol', symbols);
267
- }
268
- async fetchTicker(symbol, params = {}) {
269
- /**
270
- * @method
271
- * @name raastin#fetchTicker
272
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
273
- * @param {string} symbol unified symbol of the market to fetch the ticker for
274
- * @param {object} [params] extra parameters specific to the exchange API endpoint
275
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
276
- */
277
- await this.loadMarkets();
278
- const market = this.market(symbol);
279
- const request = {
280
- 'symbol': market['id'],
281
- };
282
- const response = await this.publicGetApiV1MarketSymbolsSymbol(request);
283
- return this.parseTicker(response, market);
284
- }
285
- parseTicker(ticker, market = undefined) {
286
- // Raastin ticker response has the same structure as market data
287
- // We extract available price/volume information
288
- const marketType = 'spot';
289
- const marketId = this.safeString(ticker, 'name');
290
- const symbol = this.safeSymbol(marketId, market, undefined, marketType);
291
- // Since the exact ticker fields are not provided in the user's example,
292
- // we'll set up the basic structure. These may need adjustment based on actual API response.
293
- const last = this.safeFloat(ticker, 'last_price', 0);
294
- const high = this.safeFloat(ticker, '24h_high', 0);
295
- const low = this.safeFloat(ticker, '24h_low', 0);
296
- const baseVolume = this.safeFloat(ticker, '24h_volume', 0);
297
- const quoteVolume = this.safeFloat(ticker, '24h_quote_volume', 0);
298
- const bid = this.safeFloat(ticker, 'bid_price', 0);
299
- const ask = this.safeFloat(ticker, 'ask_price', 0);
300
- return this.safeTicker({
301
- 'symbol': symbol,
302
- 'timestamp': undefined,
303
- 'datetime': undefined,
304
- 'high': high,
305
- 'low': low,
306
- 'bid': bid,
307
- 'bidVolume': undefined,
308
- 'ask': ask,
309
- 'askVolume': undefined,
310
- 'vwap': undefined,
311
- 'open': undefined,
312
- 'close': last,
313
- 'last': last,
314
- 'previousClose': undefined,
315
- 'change': undefined,
316
- 'percentage': undefined,
317
- 'average': undefined,
318
- 'baseVolume': baseVolume,
319
- 'quoteVolume': quoteVolume,
320
- 'info': ticker,
321
- }, market);
322
- }
323
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
324
- /**
325
- * @method
326
- * @name raastin#fetchOrderBook
327
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
328
- * @param {string} symbol unified symbol of the market to fetch the order book for
329
- * @param {int} [limit] max number of entries per orderbook to return
330
- * @param {object} [params] extra parameters specific to the exchange API endpoint
331
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
332
- */
333
- await this.loadMarkets();
334
- const market = this.market(symbol);
335
- const request = {
336
- 'symbol': market['id'],
337
- };
338
- const response = await this.publicGetApiV1MarketDepthSymbol(request);
339
- // Response structure:
340
- // {
341
- // "last_trade": { "amount": "0.31", "price": "164311", "total": "50936" },
342
- // "bids": [{ "price": "164003", "amount": "19.99", "depth": "1", "total": "3278419" }],
343
- // "asks": [{ "price": "166000", "amount": "47.79", "depth": "2", "total": "7933140" }]
344
- // }
345
- const timestamp = Date.now();
346
- return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
347
- }
348
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
349
- let url = this.urls['api']['public'] + '/' + path;
350
- // Handle path parameters like {symbol}
351
- if (path.indexOf('{symbol}') >= 0) {
352
- const symbol = this.safeString(params, 'symbol');
353
- if (symbol !== undefined) {
354
- url = url.replace('{symbol}', symbol);
355
- params = this.omit(params, 'symbol');
356
- }
357
- }
358
- const query = this.omit(params, this.extractParams(path));
359
- // Add query parameters if any remain
360
- if (Object.keys(query).length) {
361
- url = url + '?' + this.urlencode(query);
362
- }
363
- headers = { 'Content-Type': 'application/json' };
364
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
365
- }
366
- }
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/raastin.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class raastin
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class raastin extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'raastin',
19
+ 'name': 'Raastin',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': true,
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': true,
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
+ 'setLeverage': false,
84
+ 'setMarginMode': false,
85
+ 'transfer': false,
86
+ 'withdraw': false,
87
+ },
88
+ 'comment': 'This comment is optional',
89
+ 'urls': {
90
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/raastin/64x64.png',
91
+ 'api': {
92
+ 'public': 'https://api.raastin.com',
93
+ },
94
+ 'www': 'https://raastin.com',
95
+ 'doc': [
96
+ 'https://api.raastin.com/docs',
97
+ ],
98
+ },
99
+ 'api': {
100
+ 'public': {
101
+ 'get': {
102
+ 'api/v1/market/symbols': 1,
103
+ 'api/v1/market/symbols/{symbol}/': 1,
104
+ 'api/v1/market/depth/{symbol}': 1,
105
+ },
106
+ },
107
+ },
108
+ 'fees': {
109
+ 'trading': {
110
+ 'tierBased': false,
111
+ 'percentage': true,
112
+ 'maker': this.parseNumber('0'),
113
+ 'taker': this.parseNumber('0.002'),
114
+ },
115
+ },
116
+ });
117
+ }
118
+ async fetchMarkets(params = {}) {
119
+ /**
120
+ * @method
121
+ * @name raastin#fetchMarkets
122
+ * @description retrieves data on all markets for raastin
123
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
124
+ * @returns {object[]} an array of objects representing market data
125
+ */
126
+ const response = await this.publicGetApiV1MarketSymbols(params);
127
+ // Response is a flat array, not nested in 'result'
128
+ const markets = response;
129
+ const result = [];
130
+ for (let i = 0; i < markets.length; i++) {
131
+ const market = this.parseMarket(markets[i]);
132
+ result.push(market);
133
+ }
134
+ return result;
135
+ }
136
+ parseMarket(market) {
137
+ // {
138
+ // "id": 1,
139
+ // "name": "USDTIRT",
140
+ // "asset": {
141
+ // "id": 4,
142
+ // "symbol": "USDT",
143
+ // "precision": 8,
144
+ // "step_size": 8,
145
+ // "name": "tether",
146
+ // "name_fa": "تتر",
147
+ // "logo": "https://cdn.raastin.com/core-media-public/coins/logo/USDT.png",
148
+ // "original_symbol": "USDT",
149
+ // "original_name_fa": "تتر",
150
+ // "trading_view_symbol": "BINANCE:USDTUSDT.P",
151
+ // "otc_status": "active",
152
+ // "price_page": true
153
+ // },
154
+ // "base_asset": {
155
+ // "id": 1,
156
+ // "symbol": "IRT",
157
+ // "precision": 0,
158
+ // "step_size": 8,
159
+ // "name": "toman",
160
+ // "name_fa": "تومان",
161
+ // "logo": "https://cdn.raastin.com/core-media-public/coins/logo/IRT.png",
162
+ // "original_symbol": "IRT",
163
+ // "original_name_fa": "تومان",
164
+ // "trading_view_symbol": "",
165
+ // "otc_status": "active",
166
+ // "price_page": true
167
+ // },
168
+ // "taker_fee": "0.002",
169
+ // "maker_fee": "0",
170
+ // "tick_size": 0,
171
+ // "step_size": 2,
172
+ // "min_trade_quantity": "0",
173
+ // "max_trade_quantity": "1000000000000000000",
174
+ // "enable": true,
175
+ // "bookmark": false,
176
+ // "margin_enable": true,
177
+ // "strategy_enable": true
178
+ // }
179
+ const id = this.safeString(market, 'name');
180
+ const asset = this.safeDict(market, 'asset', {});
181
+ const baseAsset = this.safeDict(market, 'base_asset', {});
182
+ let baseId = this.safeString(asset, 'symbol');
183
+ let quoteId = this.safeString(baseAsset, 'symbol');
184
+ const base = this.safeCurrencyCode(baseId);
185
+ const quote = this.safeCurrencyCode(quoteId);
186
+ baseId = baseId.toLowerCase();
187
+ quoteId = quoteId.toLowerCase();
188
+ const basePrecision = this.safeInteger(asset, 'precision');
189
+ const quotePrecision = this.safeInteger(baseAsset, 'precision');
190
+ const minAmount = this.safeString(market, 'min_trade_quantity');
191
+ const maxAmount = this.safeString(market, 'max_trade_quantity');
192
+ const enabled = this.safeBool(market, 'enable', true);
193
+ const marginEnabled = this.safeBool(market, 'margin_enable', false);
194
+ return {
195
+ 'id': id,
196
+ 'symbol': base + '/' + quote,
197
+ 'base': base,
198
+ 'quote': quote,
199
+ 'settle': undefined,
200
+ 'baseId': baseId,
201
+ 'quoteId': quoteId,
202
+ 'settleId': undefined,
203
+ 'type': 'spot',
204
+ 'spot': true,
205
+ 'margin': marginEnabled,
206
+ 'swap': false,
207
+ 'future': false,
208
+ 'option': false,
209
+ 'active': enabled,
210
+ 'contract': false,
211
+ 'linear': undefined,
212
+ 'inverse': undefined,
213
+ 'contractSize': undefined,
214
+ 'expiry': undefined,
215
+ 'expiryDatetime': undefined,
216
+ 'strike': undefined,
217
+ 'optionType': undefined,
218
+ 'precision': {
219
+ 'amount': basePrecision,
220
+ 'price': quotePrecision,
221
+ },
222
+ 'limits': {
223
+ 'leverage': {
224
+ 'min': undefined,
225
+ 'max': undefined,
226
+ },
227
+ 'amount': {
228
+ 'min': this.parseNumber(minAmount),
229
+ 'max': this.parseNumber(maxAmount),
230
+ },
231
+ 'price': {
232
+ 'min': undefined,
233
+ 'max': undefined,
234
+ },
235
+ 'cost': {
236
+ 'min': undefined,
237
+ 'max': undefined,
238
+ },
239
+ },
240
+ 'created': undefined,
241
+ 'info': market,
242
+ };
243
+ }
244
+ async fetchTickers(symbols = undefined, params = {}) {
245
+ /**
246
+ * @method
247
+ * @name raastin#fetchTickers
248
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
249
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
250
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
251
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
252
+ */
253
+ await this.loadMarkets();
254
+ if (symbols !== undefined) {
255
+ symbols = this.marketSymbols(symbols);
256
+ }
257
+ const response = await this.publicGetApiV1MarketSymbols(params);
258
+ const markets = this.safeList(response, response);
259
+ const result = {};
260
+ for (let i = 0; i < markets.length; i++) {
261
+ const marketData = markets[i];
262
+ const ticker = this.parseTicker(marketData);
263
+ const symbol = ticker['symbol'];
264
+ result[symbol] = ticker;
265
+ }
266
+ return this.filterByArrayTickers(result, 'symbol', symbols);
267
+ }
268
+ async fetchTicker(symbol, params = {}) {
269
+ /**
270
+ * @method
271
+ * @name raastin#fetchTicker
272
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
273
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
274
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
275
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
276
+ */
277
+ await this.loadMarkets();
278
+ const market = this.market(symbol);
279
+ const request = {
280
+ 'symbol': market['id'],
281
+ };
282
+ const response = await this.publicGetApiV1MarketSymbolsSymbol(request);
283
+ return this.parseTicker(response, market);
284
+ }
285
+ parseTicker(ticker, market = undefined) {
286
+ // Raastin ticker response has the same structure as market data
287
+ // We extract available price/volume information
288
+ const marketType = 'spot';
289
+ const marketId = this.safeString(ticker, 'name');
290
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
291
+ // Since the exact ticker fields are not provided in the user's example,
292
+ // we'll set up the basic structure. These may need adjustment based on actual API response.
293
+ const last = this.safeFloat(ticker, 'last_price', 0);
294
+ const high = this.safeFloat(ticker, '24h_high', 0);
295
+ const low = this.safeFloat(ticker, '24h_low', 0);
296
+ const baseVolume = this.safeFloat(ticker, '24h_volume', 0);
297
+ const quoteVolume = this.safeFloat(ticker, '24h_quote_volume', 0);
298
+ const bid = this.safeFloat(ticker, 'bid_price', 0);
299
+ const ask = this.safeFloat(ticker, 'ask_price', 0);
300
+ return this.safeTicker({
301
+ 'symbol': symbol,
302
+ 'timestamp': undefined,
303
+ 'datetime': undefined,
304
+ 'high': high,
305
+ 'low': low,
306
+ 'bid': bid,
307
+ 'bidVolume': undefined,
308
+ 'ask': ask,
309
+ 'askVolume': undefined,
310
+ 'vwap': undefined,
311
+ 'open': undefined,
312
+ 'close': last,
313
+ 'last': last,
314
+ 'previousClose': undefined,
315
+ 'change': undefined,
316
+ 'percentage': undefined,
317
+ 'average': undefined,
318
+ 'baseVolume': baseVolume,
319
+ 'quoteVolume': quoteVolume,
320
+ 'info': ticker,
321
+ }, market);
322
+ }
323
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
324
+ /**
325
+ * @method
326
+ * @name raastin#fetchOrderBook
327
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
328
+ * @param {string} symbol unified symbol of the market to fetch the order book for
329
+ * @param {int} [limit] max number of entries per orderbook to return
330
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
331
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
332
+ */
333
+ await this.loadMarkets();
334
+ const market = this.market(symbol);
335
+ const request = {
336
+ 'symbol': market['id'],
337
+ };
338
+ const response = await this.publicGetApiV1MarketDepthSymbol(request);
339
+ // Response structure:
340
+ // {
341
+ // "last_trade": { "amount": "0.31", "price": "164311", "total": "50936" },
342
+ // "bids": [{ "price": "164003", "amount": "19.99", "depth": "1", "total": "3278419" }],
343
+ // "asks": [{ "price": "166000", "amount": "47.79", "depth": "2", "total": "7933140" }]
344
+ // }
345
+ const timestamp = Date.now();
346
+ return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
347
+ }
348
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
349
+ let url = this.urls['api']['public'] + '/' + path;
350
+ // Handle path parameters like {symbol}
351
+ if (path.indexOf('{symbol}') >= 0) {
352
+ const symbol = this.safeString(params, 'symbol');
353
+ if (symbol !== undefined) {
354
+ url = url.replace('{symbol}', symbol);
355
+ params = this.omit(params, 'symbol');
356
+ }
357
+ }
358
+ const query = this.omit(params, this.extractParams(path));
359
+ // Add query parameters if any remain
360
+ if (Object.keys(query).length) {
361
+ url = url + '?' + this.urlencode(query);
362
+ }
363
+ headers = { 'Content-Type': 'application/json' };
364
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
365
+ }
366
+ }