ccxt-ir 4.23.2 → 4.24.1
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 +3 -3
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/balinex.js +11 -0
- package/dist/cjs/src/balinex.js +227 -0
- package/dist/cjs/src/bitpin.js +34 -24
- package/dist/cjs/src/nobitex.js +25 -26
- package/dist/cjs/src/wallex.js +105 -18
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/balinex.d.ts +8 -0
- package/js/src/abstract/balinex.js +11 -0
- package/js/src/abstract/wallex.d.ts +2 -0
- package/js/src/balinex.d.ts +20 -0
- package/js/src/balinex.js +226 -0
- package/js/src/bitpin.d.ts +2 -2
- package/js/src/bitpin.js +34 -24
- package/js/src/nobitex.d.ts +2 -2
- package/js/src/nobitex.js +25 -26
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +2 -2
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/wallex.d.ts +2 -2
- package/js/src/wallex.js +105 -18
- package/js/test.js +41 -5
- package/package.json +1 -1
package/js/src/bitpin.js
CHANGED
|
@@ -80,6 +80,7 @@ export default class bitpin extends Exchange {
|
|
|
80
80
|
'fetchTradingFee': false,
|
|
81
81
|
'fetchTradingFees': false,
|
|
82
82
|
'fetchWithdrawals': false,
|
|
83
|
+
'otc': true,
|
|
83
84
|
'setLeverage': false,
|
|
84
85
|
'setMarginMode': false,
|
|
85
86
|
'transfer': false,
|
|
@@ -136,18 +137,23 @@ export default class bitpin extends Exchange {
|
|
|
136
137
|
* @description retrieves data on all markets for bitpin
|
|
137
138
|
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
138
139
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
140
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
139
141
|
* @returns {object[]} an array of objects representing market data
|
|
140
142
|
*/
|
|
141
|
-
const
|
|
143
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
144
|
+
const request = this.omit(params, ['type']);
|
|
145
|
+
const response = await this.publicGetV1MktMarkets(request);
|
|
142
146
|
const markets = this.safeList(response, 'results');
|
|
147
|
+
const tradableKey = (type === 'otc') ? 'otc_tradable' : 'tradable';
|
|
143
148
|
const result = [];
|
|
144
149
|
for (let i = 0; i < markets.length; i++) {
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
if (this.safeBool(markets[i], tradableKey, false)) {
|
|
151
|
+
result.push(this.parseMarket(markets[i], type));
|
|
152
|
+
}
|
|
147
153
|
}
|
|
148
154
|
return result;
|
|
149
155
|
}
|
|
150
|
-
parseMarket(market) {
|
|
156
|
+
parseMarket(market, type = 'spot') {
|
|
151
157
|
const id = this.safeString(market, 'id');
|
|
152
158
|
const baseCurrency = this.safeDict(market, 'currency1');
|
|
153
159
|
const quoteCurrency = this.safeDict(market, 'currency2');
|
|
@@ -157,6 +163,7 @@ export default class bitpin extends Exchange {
|
|
|
157
163
|
const quote = this.safeCurrencyCode(quoteId);
|
|
158
164
|
baseId = baseId.toLowerCase();
|
|
159
165
|
quoteId = quoteId.toLowerCase();
|
|
166
|
+
const tradableKey = (type === 'otc') ? 'otc_tradable' : 'tradable';
|
|
160
167
|
return {
|
|
161
168
|
'id': id,
|
|
162
169
|
'symbol': base + '/' + quote,
|
|
@@ -166,13 +173,13 @@ export default class bitpin extends Exchange {
|
|
|
166
173
|
'baseId': baseId,
|
|
167
174
|
'quoteId': quoteId,
|
|
168
175
|
'settleId': undefined,
|
|
169
|
-
'type':
|
|
170
|
-
'spot':
|
|
176
|
+
'type': type,
|
|
177
|
+
'spot': type === 'spot',
|
|
171
178
|
'margin': false,
|
|
172
179
|
'swap': false,
|
|
173
180
|
'future': false,
|
|
174
181
|
'option': false,
|
|
175
|
-
'active':
|
|
182
|
+
'active': this.safeBool(market, tradableKey, false),
|
|
176
183
|
'contract': false,
|
|
177
184
|
'linear': undefined,
|
|
178
185
|
'inverse': undefined,
|
|
@@ -215,19 +222,20 @@ export default class bitpin extends Exchange {
|
|
|
215
222
|
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
216
223
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
217
224
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
225
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
218
226
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
219
227
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const response = await this.publicGetV1MktMarkets(params);
|
|
228
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
229
|
+
const request = this.omit(params, ['type']);
|
|
230
|
+
await this.loadMarkets(false, { 'type': type });
|
|
231
|
+
const response = await this.publicGetV1MktMarkets(request);
|
|
225
232
|
const markets = this.safeList(response, 'results');
|
|
233
|
+
const tradableKey = (type === 'otc') ? 'otc_tradable' : 'tradable';
|
|
226
234
|
const result = {};
|
|
227
235
|
for (let i = 0; i < markets.length; i++) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const ticker = this.parseTicker(markets[i]);
|
|
236
|
+
if (this.safeBool(markets[i], tradableKey, false)) {
|
|
237
|
+
const market = this.parseMarket(markets[i], type);
|
|
238
|
+
const ticker = this.parseTicker(markets[i], market);
|
|
231
239
|
const symbol = ticker['symbol'];
|
|
232
240
|
result[symbol] = ticker;
|
|
233
241
|
}
|
|
@@ -242,9 +250,10 @@ export default class bitpin extends Exchange {
|
|
|
242
250
|
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
243
251
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
244
252
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
253
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
245
254
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
246
255
|
*/
|
|
247
|
-
const ticker = await this.fetchTickers([symbol]);
|
|
256
|
+
const ticker = await this.fetchTickers([symbol], params);
|
|
248
257
|
return ticker[symbol];
|
|
249
258
|
}
|
|
250
259
|
parseTicker(ticker, market = undefined) {
|
|
@@ -361,16 +370,17 @@ export default class bitpin extends Exchange {
|
|
|
361
370
|
// 'popularity_weight': 0,
|
|
362
371
|
// 'freshness_weight': 0,
|
|
363
372
|
// }
|
|
364
|
-
const marketType = 'spot';
|
|
365
|
-
const
|
|
373
|
+
const marketType = this.safeString(market, 'type', 'spot');
|
|
374
|
+
const priceInfoKey = (marketType === 'otc') ? 'price_info' : 'order_book_info';
|
|
375
|
+
const priceInfo = this.safeDict(ticker, priceInfoKey, {});
|
|
366
376
|
const marketId = this.safeString(ticker, 'id');
|
|
367
377
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
368
|
-
const high = this.safeFloat(priceInfo, 'max'
|
|
369
|
-
const low = this.safeFloat(priceInfo, 'min'
|
|
370
|
-
const last = this.safeFloat(priceInfo, 'price'
|
|
371
|
-
const change = this.safeFloat(priceInfo, 'change'
|
|
372
|
-
const baseVolume = this.safeFloat(priceInfo, 'amount'
|
|
373
|
-
const quoteVolume = this.safeFloat(priceInfo, 'value'
|
|
378
|
+
const high = this.safeFloat(priceInfo, 'max');
|
|
379
|
+
const low = this.safeFloat(priceInfo, 'min');
|
|
380
|
+
const last = this.safeFloat(priceInfo, 'price');
|
|
381
|
+
const change = this.safeFloat(priceInfo, 'change');
|
|
382
|
+
const baseVolume = this.safeFloat(priceInfo, 'amount');
|
|
383
|
+
const quoteVolume = this.safeFloat(priceInfo, 'value');
|
|
374
384
|
return this.safeTicker({
|
|
375
385
|
'symbol': symbol,
|
|
376
386
|
'timestamp': undefined,
|
package/js/src/nobitex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/nobitex.js';
|
|
2
|
-
import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
2
|
+
import { Int, Market, MarketType, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class nobitex
|
|
5
5
|
* @augments Exchange
|
|
@@ -8,7 +8,7 @@ import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/
|
|
|
8
8
|
export default class nobitex extends Exchange {
|
|
9
9
|
describe(): any;
|
|
10
10
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
11
|
-
parseMarket(market: any): Market;
|
|
11
|
+
parseMarket(market: any, type?: MarketType): Market;
|
|
12
12
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
13
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
14
14
|
parseTicker(ticker: any, market?: Market): Ticker;
|
package/js/src/nobitex.js
CHANGED
|
@@ -79,6 +79,7 @@ export default class nobitex extends Exchange {
|
|
|
79
79
|
'fetchTradingFee': false,
|
|
80
80
|
'fetchTradingFees': false,
|
|
81
81
|
'fetchWithdrawals': false,
|
|
82
|
+
'otc': true,
|
|
82
83
|
'setLeverage': false,
|
|
83
84
|
'setMarginMode': false,
|
|
84
85
|
'transfer': false,
|
|
@@ -138,9 +139,12 @@ export default class nobitex extends Exchange {
|
|
|
138
139
|
* @description retrieves data on all markets for nobitex
|
|
139
140
|
* @see https://apidocs.nobitex.ir/#6ae2dae4a2
|
|
140
141
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
142
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; both use market/stats
|
|
141
143
|
* @returns {object[]} an array of objects representing market data
|
|
142
144
|
*/
|
|
143
|
-
const
|
|
145
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
146
|
+
const request = this.omit(params, ['type']);
|
|
147
|
+
const response = await this.publicGetMarketStats(request);
|
|
144
148
|
const markets = this.safeDict(response, 'stats');
|
|
145
149
|
const marketKeys = Object.keys(markets);
|
|
146
150
|
const result = [];
|
|
@@ -149,13 +153,13 @@ export default class nobitex extends Exchange {
|
|
|
149
153
|
if (markets[symbol]['isClosed']) {
|
|
150
154
|
continue;
|
|
151
155
|
}
|
|
152
|
-
markets[symbol]
|
|
153
|
-
const market = this.parseMarket(
|
|
156
|
+
const data = this.extend(markets[symbol], { 'symbol': symbol });
|
|
157
|
+
const market = this.parseMarket(data, type);
|
|
154
158
|
result.push(market);
|
|
155
159
|
}
|
|
156
160
|
return result;
|
|
157
161
|
}
|
|
158
|
-
parseMarket(market) {
|
|
162
|
+
parseMarket(market, type = 'spot') {
|
|
159
163
|
// btc-rls: {
|
|
160
164
|
// isClosed: false,
|
|
161
165
|
// bestSell: "38820000000",
|
|
@@ -186,8 +190,8 @@ export default class nobitex extends Exchange {
|
|
|
186
190
|
'baseId': baseId,
|
|
187
191
|
'quoteId': quoteId,
|
|
188
192
|
'settleId': undefined,
|
|
189
|
-
'type':
|
|
190
|
-
'spot':
|
|
193
|
+
'type': type,
|
|
194
|
+
'spot': type === 'spot',
|
|
191
195
|
'margin': false,
|
|
192
196
|
'swap': false,
|
|
193
197
|
'future': false,
|
|
@@ -235,13 +239,16 @@ export default class nobitex extends Exchange {
|
|
|
235
239
|
* @see https://apidocs.nobitex.ir/#6ae2dae4a2
|
|
236
240
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
237
241
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
242
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; both use market/stats
|
|
238
243
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
239
244
|
*/
|
|
240
|
-
|
|
245
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
246
|
+
const request = this.omit(params, ['type']);
|
|
247
|
+
await this.loadMarkets(false, { 'type': type });
|
|
241
248
|
if (symbols !== undefined) {
|
|
242
249
|
symbols = this.marketSymbols(symbols);
|
|
243
250
|
}
|
|
244
|
-
const response = await this.publicGetMarketStats();
|
|
251
|
+
const response = await this.publicGetMarketStats(request);
|
|
245
252
|
const markets = this.safeDict(response, 'stats');
|
|
246
253
|
const marketKeys = Object.keys(markets);
|
|
247
254
|
const result = {};
|
|
@@ -250,8 +257,9 @@ export default class nobitex extends Exchange {
|
|
|
250
257
|
if (markets[symbol]['isClosed']) {
|
|
251
258
|
continue;
|
|
252
259
|
}
|
|
253
|
-
markets[symbol]
|
|
254
|
-
const
|
|
260
|
+
const data = this.extend(markets[symbol], { 'symbol': symbol });
|
|
261
|
+
const market = this.parseMarket(data, type);
|
|
262
|
+
const ticker = this.parseTicker(data, market);
|
|
255
263
|
symbol = ticker['symbol'];
|
|
256
264
|
result[symbol] = ticker;
|
|
257
265
|
}
|
|
@@ -265,10 +273,12 @@ export default class nobitex extends Exchange {
|
|
|
265
273
|
* @see https://apidocs.nobitex.ir/#6ae2dae4a2
|
|
266
274
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
267
275
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
276
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; both use market/stats
|
|
268
277
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
269
278
|
*/
|
|
270
|
-
const
|
|
271
|
-
|
|
279
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
280
|
+
const values = Object.values(tickers);
|
|
281
|
+
return this.safeValue(values, 0);
|
|
272
282
|
}
|
|
273
283
|
parseTicker(ticker, market = undefined) {
|
|
274
284
|
// {
|
|
@@ -286,19 +296,8 @@ export default class nobitex extends Exchange {
|
|
|
286
296
|
// dayClose: "112800000000",
|
|
287
297
|
// dayChange: "0.01"
|
|
288
298
|
// }
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
const parts = rawSymbol.split('-');
|
|
292
|
-
const baseId = parts[0];
|
|
293
|
-
let quoteId = parts[1];
|
|
294
|
-
if (quoteId === 'rls') {
|
|
295
|
-
quoteId = 'irt';
|
|
296
|
-
}
|
|
297
|
-
const base = this.safeCurrencyCode(baseId.toUpperCase());
|
|
298
|
-
const quote = this.safeCurrencyCode(quoteId.toUpperCase());
|
|
299
|
-
const marketId = base + '/' + quote;
|
|
300
|
-
const marketinfo = this.market(marketId);
|
|
301
|
-
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
299
|
+
market = (market === undefined) ? this.parseMarket(ticker) : market;
|
|
300
|
+
const symbol = market['symbol'];
|
|
302
301
|
let high = this.safeFloat(ticker, 'dayHigh');
|
|
303
302
|
let low = this.safeFloat(ticker, 'dayLow');
|
|
304
303
|
let bid = this.safeFloat(ticker, 'bestBuy');
|
|
@@ -310,7 +309,7 @@ export default class nobitex extends Exchange {
|
|
|
310
309
|
let quoteVolume = this.safeFloat(ticker, 'volumeDst');
|
|
311
310
|
const baseVolume = this.safeFloat(ticker, 'volumeSrc');
|
|
312
311
|
// adjust Nobitex IRT scaling
|
|
313
|
-
if (
|
|
312
|
+
if (market['quote'] === 'IRT') {
|
|
314
313
|
high = high ? high / 10 : 0;
|
|
315
314
|
low = low ? low / 10 : 0;
|
|
316
315
|
bid = bid ? bid / 10 : 0;
|
|
@@ -12,7 +12,7 @@ export declare class Stream {
|
|
|
12
12
|
parseStringUTF(start: number, end: number): string;
|
|
13
13
|
parseStringBMP(start: number, end: number): string;
|
|
14
14
|
parseTime(start: number, end: number, shortYear: boolean): string;
|
|
15
|
-
parseInteger(start: number, end: number): string |
|
|
15
|
+
parseInteger(start: number, end: number): string | 0 | -1;
|
|
16
16
|
parseBitString(start: number, end: number, maxLength: number): string;
|
|
17
17
|
parseOctetString(start: number, end: number, maxLength: number): string;
|
|
18
18
|
parseOID(start: number, end: number, maxLength: number): string;
|
|
@@ -25,7 +25,7 @@ export declare class ASN1 {
|
|
|
25
25
|
private tag;
|
|
26
26
|
sub: ASN1[];
|
|
27
27
|
typeName(): string;
|
|
28
|
-
content(maxLength: number): string |
|
|
28
|
+
content(maxLength: number): string | 0 | -1;
|
|
29
29
|
toString(): string;
|
|
30
30
|
toPrettyString(indent: string): string;
|
|
31
31
|
posStart(): number;
|
|
@@ -15,7 +15,7 @@ export declare class BigInteger {
|
|
|
15
15
|
protected intValue(): number;
|
|
16
16
|
protected byteValue(): number;
|
|
17
17
|
protected shortValue(): number;
|
|
18
|
-
protected signum(): 1 |
|
|
18
|
+
protected signum(): 1 | 0 | -1;
|
|
19
19
|
toByteArray(): number[];
|
|
20
20
|
protected equals(a: BigInteger): boolean;
|
|
21
21
|
protected min(a: BigInteger): BigInteger;
|
package/js/src/wallex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/wallex.js';
|
|
2
|
-
import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
2
|
+
import { Int, Market, MarketType, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class wallex
|
|
5
5
|
* @augments Exchange
|
|
@@ -8,7 +8,7 @@ import { Int, Market, OHLCV, OrderBook, Strings, Ticker, Tickers } from './base/
|
|
|
8
8
|
export default class wallex extends Exchange {
|
|
9
9
|
describe(): any;
|
|
10
10
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
11
|
-
parseMarket(market: any): Market;
|
|
11
|
+
parseMarket(market: any, type?: MarketType): Market;
|
|
12
12
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
13
13
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
14
14
|
parseTicker(ticker: any, market?: Market): Ticker;
|
package/js/src/wallex.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/wallex.js';
|
|
9
|
+
import { BadSymbol, ExchangeError } from './base/errors.js';
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
/**
|
|
11
12
|
* @class wallex
|
|
@@ -80,6 +81,7 @@ export default class wallex extends Exchange {
|
|
|
80
81
|
'fetchTradingFee': false,
|
|
81
82
|
'fetchTradingFees': false,
|
|
82
83
|
'fetchWithdrawals': false,
|
|
84
|
+
'otc': true,
|
|
83
85
|
'setLeverage': false,
|
|
84
86
|
'setMarginMode': false,
|
|
85
87
|
'transfer': false,
|
|
@@ -108,6 +110,8 @@ export default class wallex extends Exchange {
|
|
|
108
110
|
'public': {
|
|
109
111
|
'get': {
|
|
110
112
|
'v1/markets': 1,
|
|
113
|
+
'v1/currencies': 1,
|
|
114
|
+
'v1/otc/price': 1,
|
|
111
115
|
'v1/currencies/stats': 1,
|
|
112
116
|
'v1/depth': 1,
|
|
113
117
|
'v1/udf/history': 1,
|
|
@@ -134,9 +138,39 @@ export default class wallex extends Exchange {
|
|
|
134
138
|
* @description retrieves data on all markets for wallex
|
|
135
139
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
136
140
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
141
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
137
142
|
* @returns {object[]} an array of objects representing market data
|
|
138
143
|
*/
|
|
139
|
-
const
|
|
144
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
145
|
+
const request = this.omit(params, ['type']);
|
|
146
|
+
if (type === 'otc') {
|
|
147
|
+
const otcResponse = await this.publicGetV1Currencies(request);
|
|
148
|
+
const currencies = this.safeDict(otcResponse, 'result', {});
|
|
149
|
+
const baseIds = Object.keys(currencies);
|
|
150
|
+
const quoteIds = ['TMN', 'USDT'];
|
|
151
|
+
const otcMarkets = [];
|
|
152
|
+
for (let i = 0; i < baseIds.length; i++) {
|
|
153
|
+
const baseId = baseIds[i];
|
|
154
|
+
// TMN is a quote currency; the OTC API does not support TMNUSDT.
|
|
155
|
+
if (baseId === 'TMN') {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
for (let j = 0; j < quoteIds.length; j++) {
|
|
159
|
+
const quoteId = quoteIds[j];
|
|
160
|
+
if (baseId === quoteId) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
otcMarkets.push(this.parseMarket({
|
|
164
|
+
'symbol': baseId + quoteId,
|
|
165
|
+
'baseAsset': baseId,
|
|
166
|
+
'quoteAsset': quoteId,
|
|
167
|
+
'info': currencies[baseId],
|
|
168
|
+
}, type));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return otcMarkets;
|
|
172
|
+
}
|
|
173
|
+
const response = await this.publicGetV1Markets(request);
|
|
140
174
|
const markets = this.safeDict(response, 'result');
|
|
141
175
|
const marketList = this.safeDict(markets, 'symbols');
|
|
142
176
|
const marketKeys = Object.keys(marketList);
|
|
@@ -148,7 +182,7 @@ export default class wallex extends Exchange {
|
|
|
148
182
|
}
|
|
149
183
|
return result;
|
|
150
184
|
}
|
|
151
|
-
parseMarket(market) {
|
|
185
|
+
parseMarket(market, type = 'spot') {
|
|
152
186
|
// {
|
|
153
187
|
// symbol: "PEPETMN",
|
|
154
188
|
// baseAsset: "PEPE",
|
|
@@ -212,8 +246,8 @@ export default class wallex extends Exchange {
|
|
|
212
246
|
'baseId': baseId,
|
|
213
247
|
'quoteId': quoteId,
|
|
214
248
|
'settleId': undefined,
|
|
215
|
-
'type':
|
|
216
|
-
'spot':
|
|
249
|
+
'type': type,
|
|
250
|
+
'spot': type === 'spot',
|
|
217
251
|
'margin': false,
|
|
218
252
|
'swap': false,
|
|
219
253
|
'future': false,
|
|
@@ -250,7 +284,7 @@ export default class wallex extends Exchange {
|
|
|
250
284
|
},
|
|
251
285
|
},
|
|
252
286
|
'created': undefined,
|
|
253
|
-
'info': market,
|
|
287
|
+
'info': this.safeDict(market, 'info', market),
|
|
254
288
|
};
|
|
255
289
|
}
|
|
256
290
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -261,8 +295,40 @@ export default class wallex extends Exchange {
|
|
|
261
295
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
262
296
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
263
297
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
298
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'; OTC requests one BUY quote per symbol
|
|
264
299
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
265
300
|
*/
|
|
301
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
302
|
+
params = this.omit(params, ['type']);
|
|
303
|
+
if (type === 'otc') {
|
|
304
|
+
let otcMarkets = await this.fetchMarkets(this.extend(params, { 'type': type }));
|
|
305
|
+
if (symbols !== undefined) {
|
|
306
|
+
const marketsBySymbol = this.indexBy(otcMarkets, 'symbol');
|
|
307
|
+
const marketsById = this.indexBy(otcMarkets, 'id');
|
|
308
|
+
const selectedMarkets = [];
|
|
309
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
310
|
+
const symbol = symbols[i];
|
|
311
|
+
const market = this.safeDict(marketsBySymbol, symbol, this.safeDict(marketsById, symbol));
|
|
312
|
+
if (market === undefined) {
|
|
313
|
+
throw new BadSymbol(this.id + ' does not have OTC market symbol ' + symbol);
|
|
314
|
+
}
|
|
315
|
+
selectedMarkets.push(market);
|
|
316
|
+
}
|
|
317
|
+
otcMarkets = selectedMarkets;
|
|
318
|
+
}
|
|
319
|
+
const otcTickers = {};
|
|
320
|
+
for (let i = 0; i < otcMarkets.length; i++) {
|
|
321
|
+
const market = otcMarkets[i];
|
|
322
|
+
const request = this.extend(params, { 'side': 'BUY', 'symbol': market['id'] });
|
|
323
|
+
const otcResponse = await this.publicGetV1OtcPrice(request);
|
|
324
|
+
const data = this.safeDict(otcResponse, 'result', {});
|
|
325
|
+
if (this.safeString(data, 'price') === undefined) {
|
|
326
|
+
throw new ExchangeError(this.id + ' OTC quote unavailable for ' + market['symbol'] + ': ' + this.json(otcResponse));
|
|
327
|
+
}
|
|
328
|
+
otcTickers[market['symbol']] = this.parseTicker(data, market);
|
|
329
|
+
}
|
|
330
|
+
return otcTickers;
|
|
331
|
+
}
|
|
266
332
|
await this.loadMarkets();
|
|
267
333
|
if (symbols !== undefined) {
|
|
268
334
|
symbols = this.marketSymbols(symbols);
|
|
@@ -274,7 +340,8 @@ export default class wallex extends Exchange {
|
|
|
274
340
|
const result = {};
|
|
275
341
|
for (let i = 0; i < marketKeys.length; i++) {
|
|
276
342
|
const index = marketKeys[i];
|
|
277
|
-
const
|
|
343
|
+
const market = this.parseMarket(marketList[index]);
|
|
344
|
+
const ticker = this.parseTicker(marketList[index], market);
|
|
278
345
|
const symbol = ticker['symbol'];
|
|
279
346
|
result[symbol] = ticker;
|
|
280
347
|
}
|
|
@@ -288,15 +355,12 @@ export default class wallex extends Exchange {
|
|
|
288
355
|
* @see https://api-docs.wallex.ir/#be8d9c51a2
|
|
289
356
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
290
357
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
358
|
+
* @param {string} [params.type] market type, 'spot' (default) or 'otc'
|
|
291
359
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
292
360
|
*/
|
|
293
|
-
await this.
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
const markets = this.safeDict(response, 'result');
|
|
297
|
-
const marketList = this.safeDict(markets, 'symbols');
|
|
298
|
-
const ticker = this.parseTicker(marketList[market['id']]);
|
|
299
|
-
return ticker;
|
|
361
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
362
|
+
const values = Object.values(tickers);
|
|
363
|
+
return this.safeValue(values, 0);
|
|
300
364
|
}
|
|
301
365
|
parseTicker(ticker, market = undefined) {
|
|
302
366
|
// {
|
|
@@ -346,7 +410,33 @@ export default class wallex extends Exchange {
|
|
|
346
410
|
// isNew: false,
|
|
347
411
|
// isZeroFee: false
|
|
348
412
|
// },
|
|
349
|
-
const marketType = 'spot';
|
|
413
|
+
const marketType = this.safeString(market, 'type', 'spot');
|
|
414
|
+
if (marketType === 'otc') {
|
|
415
|
+
const timestamp = this.parse8601(this.safeString(ticker, 'current_time'));
|
|
416
|
+
const price = this.safeNumber(ticker, 'price');
|
|
417
|
+
return this.safeTicker({
|
|
418
|
+
'symbol': market['symbol'],
|
|
419
|
+
'timestamp': timestamp,
|
|
420
|
+
'datetime': this.iso8601(timestamp),
|
|
421
|
+
'high': undefined,
|
|
422
|
+
'low': undefined,
|
|
423
|
+
'bid': undefined,
|
|
424
|
+
'bidVolume': undefined,
|
|
425
|
+
'ask': price,
|
|
426
|
+
'askVolume': undefined,
|
|
427
|
+
'vwap': undefined,
|
|
428
|
+
'open': undefined,
|
|
429
|
+
'close': price,
|
|
430
|
+
'last': price,
|
|
431
|
+
'previousClose': undefined,
|
|
432
|
+
'change': undefined,
|
|
433
|
+
'percentage': undefined,
|
|
434
|
+
'average': undefined,
|
|
435
|
+
'baseVolume': undefined,
|
|
436
|
+
'quoteVolume': undefined,
|
|
437
|
+
'info': ticker,
|
|
438
|
+
}, market);
|
|
439
|
+
}
|
|
350
440
|
const stats = this.safeValue(ticker, 'stats');
|
|
351
441
|
const marketId = this.safeString(ticker, 'symbol');
|
|
352
442
|
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
@@ -455,10 +545,7 @@ export default class wallex extends Exchange {
|
|
|
455
545
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
456
546
|
const query = this.omit(params, this.extractParams(path));
|
|
457
547
|
let url = this.urls['api']['public'] + '/' + path;
|
|
458
|
-
if (
|
|
459
|
-
url = url + '?' + this.urlencode(query);
|
|
460
|
-
}
|
|
461
|
-
if (path === 'v1/depth') {
|
|
548
|
+
if (!this.isEmpty(query)) {
|
|
462
549
|
url = url + '?' + this.urlencode(query);
|
|
463
550
|
}
|
|
464
551
|
headers = { 'Content-Type': 'application/json' };
|
package/js/test.js
CHANGED
|
@@ -5,14 +5,50 @@
|
|
|
5
5
|
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
6
|
|
|
7
7
|
import ccxt from './ccxt.js';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// Change these names, or pass them on the command line.
|
|
9
|
+
const exchangeNames = ['bitpin', 'wallex', 'nobitex'];
|
|
10
|
+
const sampleSize = 5;
|
|
11
|
+
async function testExchange(id) {
|
|
12
|
+
if (!ccxt.exchanges.includes(id)) {
|
|
13
|
+
throw new Error('Unknown exchange: ' + id);
|
|
14
|
+
}
|
|
15
|
+
const exchange = new ccxt[id]({ 'enableRateLimit': true, 'timeout': 20000 });
|
|
10
16
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
17
|
+
const types = ['spot', 'otc'].filter(type => exchange.has[type]);
|
|
18
|
+
if (types.length === 0) {
|
|
19
|
+
types.push('default');
|
|
20
|
+
}
|
|
21
|
+
for (const type of types) {
|
|
22
|
+
// Spot uses the default params; OTC is selected explicitly.
|
|
23
|
+
const params = (type === 'otc') ? { 'type': 'otc' } : {};
|
|
24
|
+
const markets = await exchange.fetchMarkets(params);
|
|
25
|
+
const symbols = markets.slice(0, sampleSize).map(market => market.symbol);
|
|
26
|
+
const tickers = await exchange.fetchTickers(symbols, params);
|
|
27
|
+
console.log('\n' + id + ' ' + type.toUpperCase() + ': ' + markets.length + ' markets');
|
|
28
|
+
console.table(Object.values(tickers).slice(0, sampleSize).map(ticker => ({
|
|
29
|
+
'symbol': ticker.symbol,
|
|
30
|
+
'last': ticker.last,
|
|
31
|
+
'bid': ticker.bid,
|
|
32
|
+
'ask': ticker.ask,
|
|
33
|
+
'high': ticker.high,
|
|
34
|
+
'low': ticker.low,
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
13
37
|
}
|
|
14
38
|
finally {
|
|
15
|
-
exchange.close();
|
|
39
|
+
await exchange.close();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function main() {
|
|
43
|
+
const names = process.argv.length > 2 ? process.argv.slice(2) : exchangeNames;
|
|
44
|
+
for (const id of names) {
|
|
45
|
+
try {
|
|
46
|
+
await testExchange(id);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(id + ' failed:', error);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
}
|
|
16
52
|
}
|
|
17
53
|
}
|
|
18
54
|
main().catch((error) => {
|
package/package.json
CHANGED