ccxt-ir 4.23.2 → 4.24.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 +264 -261
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/abstract/balinex.js +11 -0
- package/dist/cjs/src/balinex.js +227 -0
- package/dist/cjs/src/bitbarg.js +322 -322
- package/dist/cjs/src/swapwallet.js +209 -209
- package/js/ccxt.d.ts +772 -769
- package/js/ccxt.js +557 -555
- package/js/src/abstract/balinex.d.ts +8 -0
- package/js/src/abstract/balinex.js +11 -0
- package/js/src/abstract/swapwallet.js +5 -5
- package/js/src/balinex.d.ts +20 -0
- package/js/src/balinex.js +226 -0
- package/js/src/base/Exchange.d.ts +926 -926
- package/js/src/bitbarg.js +325 -325
- package/js/src/coinbaseexchange.d.ts +334 -334
- package/js/src/protobuf/mexc/compiled.d.cts +8 -2
- package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +2 -2
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -101
- package/js/src/static_dependencies/qs/formats.d.cts +14 -8
- package/js/src/static_dependencies/qs/index.d.cts +10 -4
- package/js/src/static_dependencies/qs/parse.d.cts +8 -2
- package/js/src/static_dependencies/qs/stringify.d.cts +8 -2
- package/js/src/static_dependencies/qs/utils.d.cts +15 -9
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -5
- package/js/src/swapwallet.js +212 -212
- package/js/test.js +62 -15
- package/package.json +1 -1
package/js/src/swapwallet.js
CHANGED
|
@@ -4,215 +4,215 @@
|
|
|
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 './base/Exchange.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* @class swapwallet
|
|
12
|
-
* @augments Exchange
|
|
13
|
-
*/
|
|
14
|
-
export default class swapwallet extends Exchange {
|
|
15
|
-
describe() {
|
|
16
|
-
return this.deepExtend(super.describe(), {
|
|
17
|
-
'id': 'swapwallet',
|
|
18
|
-
'name': 'Swapwallet',
|
|
19
|
-
'countries': ['IR'],
|
|
20
|
-
'rateLimit': 1000,
|
|
21
|
-
'version': 'v2',
|
|
22
|
-
'certified': false,
|
|
23
|
-
'pro': false,
|
|
24
|
-
'has': {
|
|
25
|
-
'CORS': undefined,
|
|
26
|
-
'spot': false,
|
|
27
|
-
'margin': false,
|
|
28
|
-
'swap': false,
|
|
29
|
-
'future': false,
|
|
30
|
-
'option': false,
|
|
31
|
-
'fetchMarkets': true,
|
|
32
|
-
'fetchTicker': true,
|
|
33
|
-
'fetchTickers': true,
|
|
34
|
-
'otc': true,
|
|
35
|
-
},
|
|
36
|
-
'options': {
|
|
37
|
-
'defaultType': 'otc',
|
|
38
|
-
},
|
|
39
|
-
'urls': {
|
|
40
|
-
'api': {
|
|
41
|
-
'public': 'https://swapwallet.app/api/v2',
|
|
42
|
-
},
|
|
43
|
-
'www': 'https://swapwallet.app',
|
|
44
|
-
'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
|
|
45
|
-
},
|
|
46
|
-
'api': {
|
|
47
|
-
'public': {
|
|
48
|
-
'get': {
|
|
49
|
-
'market/crypto/stats': 1,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async fetchMarkets(params = {}) {
|
|
56
|
-
/**
|
|
57
|
-
* @method
|
|
58
|
-
* @name swapwallet#fetchMarkets
|
|
59
|
-
* @description retrieves all OTC markets
|
|
60
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
61
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
62
|
-
* @returns {object[]} an array of market structures
|
|
63
|
-
*/
|
|
64
|
-
const response = await this.publicGetMarketCryptoStats(params);
|
|
65
|
-
const markets = this.safeDict(response, 'result', {});
|
|
66
|
-
const ids = Object.keys(markets);
|
|
67
|
-
const result = [];
|
|
68
|
-
for (let i = 0; i < ids.length; i++) {
|
|
69
|
-
const id = ids[i];
|
|
70
|
-
result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
parseMarket(market) {
|
|
75
|
-
// {
|
|
76
|
-
// "source": "USOON",
|
|
77
|
-
// "destination": "USDT",
|
|
78
|
-
// "marketData": {
|
|
79
|
-
// "bestSell": "165.72",
|
|
80
|
-
// "bestBuy": "162.43",
|
|
81
|
-
// "latestPrice": "164.08",
|
|
82
|
-
// "dayChange": "2.98",
|
|
83
|
-
// "volume24h": "3753.99"
|
|
84
|
-
// }
|
|
85
|
-
// }
|
|
86
|
-
const baseId = this.safeString(market, 'source');
|
|
87
|
-
const quoteId = this.safeString(market, 'destination');
|
|
88
|
-
const base = this.safeCurrencyCode(baseId);
|
|
89
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
90
|
-
const id = this.safeString(market, 'id', baseId + '-' + quoteId);
|
|
91
|
-
return {
|
|
92
|
-
'id': id,
|
|
93
|
-
'symbol': base + '/' + quote,
|
|
94
|
-
'base': base,
|
|
95
|
-
'quote': quote,
|
|
96
|
-
'settle': undefined,
|
|
97
|
-
'baseId': baseId,
|
|
98
|
-
'quoteId': quoteId,
|
|
99
|
-
'settleId': undefined,
|
|
100
|
-
'type': 'otc',
|
|
101
|
-
'spot': false,
|
|
102
|
-
'margin': false,
|
|
103
|
-
'swap': false,
|
|
104
|
-
'future': false,
|
|
105
|
-
'option': false,
|
|
106
|
-
'active': undefined,
|
|
107
|
-
'contract': false,
|
|
108
|
-
'linear': undefined,
|
|
109
|
-
'inverse': undefined,
|
|
110
|
-
'contractSize': undefined,
|
|
111
|
-
'expiry': undefined,
|
|
112
|
-
'expiryDatetime': undefined,
|
|
113
|
-
'strike': undefined,
|
|
114
|
-
'optionType': undefined,
|
|
115
|
-
'precision': {
|
|
116
|
-
'amount': undefined,
|
|
117
|
-
'price': undefined,
|
|
118
|
-
},
|
|
119
|
-
'limits': {
|
|
120
|
-
'leverage': {
|
|
121
|
-
'min': undefined,
|
|
122
|
-
'max': undefined,
|
|
123
|
-
},
|
|
124
|
-
'amount': {
|
|
125
|
-
'min': undefined,
|
|
126
|
-
'max': undefined,
|
|
127
|
-
},
|
|
128
|
-
'price': {
|
|
129
|
-
'min': undefined,
|
|
130
|
-
'max': undefined,
|
|
131
|
-
},
|
|
132
|
-
'cost': {
|
|
133
|
-
'min': undefined,
|
|
134
|
-
'max': undefined,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
'created': undefined,
|
|
138
|
-
'info': market,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
142
|
-
/**
|
|
143
|
-
* @method
|
|
144
|
-
* @name swapwallet#fetchTickers
|
|
145
|
-
* @description fetches 24 hour price statistics for multiple OTC markets
|
|
146
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
147
|
-
* @param {string[]} [symbols] unified symbols, all markets are returned if undefined
|
|
148
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
149
|
-
* @returns {object} a dictionary of ticker structures indexed by symbol
|
|
150
|
-
*/
|
|
151
|
-
await this.loadMarkets();
|
|
152
|
-
symbols = this.marketSymbols(symbols);
|
|
153
|
-
const response = await this.publicGetMarketCryptoStats(params);
|
|
154
|
-
const tickers = this.safeDict(response, 'result', {});
|
|
155
|
-
const ids = Object.keys(tickers);
|
|
156
|
-
const result = {};
|
|
157
|
-
for (let i = 0; i < ids.length; i++) {
|
|
158
|
-
const id = ids[i];
|
|
159
|
-
const ticker = this.parseTicker(tickers[id]);
|
|
160
|
-
result[ticker['symbol']] = ticker;
|
|
161
|
-
}
|
|
162
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
163
|
-
}
|
|
164
|
-
async fetchTicker(symbol, params = {}) {
|
|
165
|
-
/**
|
|
166
|
-
* @method
|
|
167
|
-
* @name swapwallet#fetchTicker
|
|
168
|
-
* @description fetches 24 hour price statistics for a single OTC market
|
|
169
|
-
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
170
|
-
* @param {string} symbol unified market symbol
|
|
171
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
172
|
-
* @returns {object} a ticker structure
|
|
173
|
-
*/
|
|
174
|
-
await this.loadMarkets();
|
|
175
|
-
const market = this.market(symbol);
|
|
176
|
-
const tickers = await this.fetchTickers([market['symbol']], params);
|
|
177
|
-
return tickers[market['symbol']];
|
|
178
|
-
}
|
|
179
|
-
parseTicker(ticker, market = undefined) {
|
|
180
|
-
const baseId = this.safeString(ticker, 'source');
|
|
181
|
-
const quoteId = this.safeString(ticker, 'destination');
|
|
182
|
-
const marketId = baseId + '-' + quoteId;
|
|
183
|
-
const symbol = this.safeSymbol(marketId, market, '-', 'otc');
|
|
184
|
-
const data = this.safeDict(ticker, 'marketData', {});
|
|
185
|
-
const last = this.safeString(data, 'latestPrice');
|
|
186
|
-
return this.safeTicker({
|
|
187
|
-
'symbol': symbol,
|
|
188
|
-
'timestamp': undefined,
|
|
189
|
-
'datetime': undefined,
|
|
190
|
-
'high': undefined,
|
|
191
|
-
'low': undefined,
|
|
192
|
-
'bid': this.safeString(data, 'bestBuy'),
|
|
193
|
-
'bidVolume': undefined,
|
|
194
|
-
'ask': this.safeString(data, 'bestSell'),
|
|
195
|
-
'askVolume': undefined,
|
|
196
|
-
'vwap': undefined,
|
|
197
|
-
'open': undefined,
|
|
198
|
-
'close': last,
|
|
199
|
-
'last': last,
|
|
200
|
-
'previousClose': undefined,
|
|
201
|
-
'change': undefined,
|
|
202
|
-
'percentage': this.safeString(data, 'dayChange'),
|
|
203
|
-
'average': undefined,
|
|
204
|
-
'baseVolume': this.safeString(data, 'volume24h'),
|
|
205
|
-
'quoteVolume': undefined,
|
|
206
|
-
'info': ticker,
|
|
207
|
-
}, market);
|
|
208
|
-
}
|
|
209
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
210
|
-
const query = this.omit(params, this.extractParams(path));
|
|
211
|
-
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
212
|
-
if (Object.keys(query).length) {
|
|
213
|
-
url += '?' + this.urlencode(query);
|
|
214
|
-
}
|
|
215
|
-
headers = { 'Content-Type': 'application/json' };
|
|
216
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
217
|
-
}
|
|
218
|
-
}
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
import Exchange from './base/Exchange.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* @class swapwallet
|
|
12
|
+
* @augments Exchange
|
|
13
|
+
*/
|
|
14
|
+
export default class swapwallet extends Exchange {
|
|
15
|
+
describe() {
|
|
16
|
+
return this.deepExtend(super.describe(), {
|
|
17
|
+
'id': 'swapwallet',
|
|
18
|
+
'name': 'Swapwallet',
|
|
19
|
+
'countries': ['IR'],
|
|
20
|
+
'rateLimit': 1000,
|
|
21
|
+
'version': 'v2',
|
|
22
|
+
'certified': false,
|
|
23
|
+
'pro': false,
|
|
24
|
+
'has': {
|
|
25
|
+
'CORS': undefined,
|
|
26
|
+
'spot': false,
|
|
27
|
+
'margin': false,
|
|
28
|
+
'swap': false,
|
|
29
|
+
'future': false,
|
|
30
|
+
'option': false,
|
|
31
|
+
'fetchMarkets': true,
|
|
32
|
+
'fetchTicker': true,
|
|
33
|
+
'fetchTickers': true,
|
|
34
|
+
'otc': true,
|
|
35
|
+
},
|
|
36
|
+
'options': {
|
|
37
|
+
'defaultType': 'otc',
|
|
38
|
+
},
|
|
39
|
+
'urls': {
|
|
40
|
+
'api': {
|
|
41
|
+
'public': 'https://swapwallet.app/api/v2',
|
|
42
|
+
},
|
|
43
|
+
'www': 'https://swapwallet.app',
|
|
44
|
+
'doc': 'https://swapwallet.app/api/v2/market/crypto/stats',
|
|
45
|
+
},
|
|
46
|
+
'api': {
|
|
47
|
+
'public': {
|
|
48
|
+
'get': {
|
|
49
|
+
'market/crypto/stats': 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async fetchMarkets(params = {}) {
|
|
56
|
+
/**
|
|
57
|
+
* @method
|
|
58
|
+
* @name swapwallet#fetchMarkets
|
|
59
|
+
* @description retrieves all OTC markets
|
|
60
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
61
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
62
|
+
* @returns {object[]} an array of market structures
|
|
63
|
+
*/
|
|
64
|
+
const response = await this.publicGetMarketCryptoStats(params);
|
|
65
|
+
const markets = this.safeDict(response, 'result', {});
|
|
66
|
+
const ids = Object.keys(markets);
|
|
67
|
+
const result = [];
|
|
68
|
+
for (let i = 0; i < ids.length; i++) {
|
|
69
|
+
const id = ids[i];
|
|
70
|
+
result.push(this.parseMarket(this.extend(markets[id], { 'id': id })));
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
parseMarket(market) {
|
|
75
|
+
// {
|
|
76
|
+
// "source": "USOON",
|
|
77
|
+
// "destination": "USDT",
|
|
78
|
+
// "marketData": {
|
|
79
|
+
// "bestSell": "165.72",
|
|
80
|
+
// "bestBuy": "162.43",
|
|
81
|
+
// "latestPrice": "164.08",
|
|
82
|
+
// "dayChange": "2.98",
|
|
83
|
+
// "volume24h": "3753.99"
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
const baseId = this.safeString(market, 'source');
|
|
87
|
+
const quoteId = this.safeString(market, 'destination');
|
|
88
|
+
const base = this.safeCurrencyCode(baseId);
|
|
89
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
90
|
+
const id = this.safeString(market, 'id', baseId + '-' + quoteId);
|
|
91
|
+
return {
|
|
92
|
+
'id': id,
|
|
93
|
+
'symbol': base + '/' + quote,
|
|
94
|
+
'base': base,
|
|
95
|
+
'quote': quote,
|
|
96
|
+
'settle': undefined,
|
|
97
|
+
'baseId': baseId,
|
|
98
|
+
'quoteId': quoteId,
|
|
99
|
+
'settleId': undefined,
|
|
100
|
+
'type': 'otc',
|
|
101
|
+
'spot': false,
|
|
102
|
+
'margin': false,
|
|
103
|
+
'swap': false,
|
|
104
|
+
'future': false,
|
|
105
|
+
'option': false,
|
|
106
|
+
'active': undefined,
|
|
107
|
+
'contract': false,
|
|
108
|
+
'linear': undefined,
|
|
109
|
+
'inverse': undefined,
|
|
110
|
+
'contractSize': undefined,
|
|
111
|
+
'expiry': undefined,
|
|
112
|
+
'expiryDatetime': undefined,
|
|
113
|
+
'strike': undefined,
|
|
114
|
+
'optionType': undefined,
|
|
115
|
+
'precision': {
|
|
116
|
+
'amount': undefined,
|
|
117
|
+
'price': undefined,
|
|
118
|
+
},
|
|
119
|
+
'limits': {
|
|
120
|
+
'leverage': {
|
|
121
|
+
'min': undefined,
|
|
122
|
+
'max': undefined,
|
|
123
|
+
},
|
|
124
|
+
'amount': {
|
|
125
|
+
'min': undefined,
|
|
126
|
+
'max': undefined,
|
|
127
|
+
},
|
|
128
|
+
'price': {
|
|
129
|
+
'min': undefined,
|
|
130
|
+
'max': undefined,
|
|
131
|
+
},
|
|
132
|
+
'cost': {
|
|
133
|
+
'min': undefined,
|
|
134
|
+
'max': undefined,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
'created': undefined,
|
|
138
|
+
'info': market,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
142
|
+
/**
|
|
143
|
+
* @method
|
|
144
|
+
* @name swapwallet#fetchTickers
|
|
145
|
+
* @description fetches 24 hour price statistics for multiple OTC markets
|
|
146
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
147
|
+
* @param {string[]} [symbols] unified symbols, all markets are returned if undefined
|
|
148
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
149
|
+
* @returns {object} a dictionary of ticker structures indexed by symbol
|
|
150
|
+
*/
|
|
151
|
+
await this.loadMarkets();
|
|
152
|
+
symbols = this.marketSymbols(symbols);
|
|
153
|
+
const response = await this.publicGetMarketCryptoStats(params);
|
|
154
|
+
const tickers = this.safeDict(response, 'result', {});
|
|
155
|
+
const ids = Object.keys(tickers);
|
|
156
|
+
const result = {};
|
|
157
|
+
for (let i = 0; i < ids.length; i++) {
|
|
158
|
+
const id = ids[i];
|
|
159
|
+
const ticker = this.parseTicker(tickers[id]);
|
|
160
|
+
result[ticker['symbol']] = ticker;
|
|
161
|
+
}
|
|
162
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
163
|
+
}
|
|
164
|
+
async fetchTicker(symbol, params = {}) {
|
|
165
|
+
/**
|
|
166
|
+
* @method
|
|
167
|
+
* @name swapwallet#fetchTicker
|
|
168
|
+
* @description fetches 24 hour price statistics for a single OTC market
|
|
169
|
+
* @see https://swapwallet.app/api/v2/market/crypto/stats
|
|
170
|
+
* @param {string} symbol unified market symbol
|
|
171
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
172
|
+
* @returns {object} a ticker structure
|
|
173
|
+
*/
|
|
174
|
+
await this.loadMarkets();
|
|
175
|
+
const market = this.market(symbol);
|
|
176
|
+
const tickers = await this.fetchTickers([market['symbol']], params);
|
|
177
|
+
return tickers[market['symbol']];
|
|
178
|
+
}
|
|
179
|
+
parseTicker(ticker, market = undefined) {
|
|
180
|
+
const baseId = this.safeString(ticker, 'source');
|
|
181
|
+
const quoteId = this.safeString(ticker, 'destination');
|
|
182
|
+
const marketId = baseId + '-' + quoteId;
|
|
183
|
+
const symbol = this.safeSymbol(marketId, market, '-', 'otc');
|
|
184
|
+
const data = this.safeDict(ticker, 'marketData', {});
|
|
185
|
+
const last = this.safeString(data, 'latestPrice');
|
|
186
|
+
return this.safeTicker({
|
|
187
|
+
'symbol': symbol,
|
|
188
|
+
'timestamp': undefined,
|
|
189
|
+
'datetime': undefined,
|
|
190
|
+
'high': undefined,
|
|
191
|
+
'low': undefined,
|
|
192
|
+
'bid': this.safeString(data, 'bestBuy'),
|
|
193
|
+
'bidVolume': undefined,
|
|
194
|
+
'ask': this.safeString(data, 'bestSell'),
|
|
195
|
+
'askVolume': undefined,
|
|
196
|
+
'vwap': undefined,
|
|
197
|
+
'open': undefined,
|
|
198
|
+
'close': last,
|
|
199
|
+
'last': last,
|
|
200
|
+
'previousClose': undefined,
|
|
201
|
+
'change': undefined,
|
|
202
|
+
'percentage': this.safeString(data, 'dayChange'),
|
|
203
|
+
'average': undefined,
|
|
204
|
+
'baseVolume': this.safeString(data, 'volume24h'),
|
|
205
|
+
'quoteVolume': undefined,
|
|
206
|
+
'info': ticker,
|
|
207
|
+
}, market);
|
|
208
|
+
}
|
|
209
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
210
|
+
const query = this.omit(params, this.extractParams(path));
|
|
211
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
212
|
+
if (Object.keys(query).length) {
|
|
213
|
+
url += '?' + this.urlencode(query);
|
|
214
|
+
}
|
|
215
|
+
headers = { 'Content-Type': 'application/json' };
|
|
216
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
217
|
+
}
|
|
218
|
+
}
|
package/js/test.js
CHANGED
|
@@ -4,18 +4,65 @@
|
|
|
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
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
7
|
+
import { balinex } from './ccxt.js';
|
|
8
|
+
const exchanges = [
|
|
9
|
+
// { 'id': 'technogold', 'Exchange': technogold },
|
|
10
|
+
// { 'id': 'baazar', 'Exchange': baazar },
|
|
11
|
+
// { 'id': 'hamrahgold', 'Exchange': hamrahgold },
|
|
12
|
+
// { 'id': 'zarniv', 'Exchange': zarniv },
|
|
13
|
+
// { 'id': 'zarminex', 'Exchange': zarminex },
|
|
14
|
+
// { 'id': 'zarafza', 'Exchange': zarafza },
|
|
15
|
+
// { 'id': 'daric', 'Exchange': daric },
|
|
16
|
+
// { 'id': 'digikalagold', 'Exchange': digikalagold },
|
|
17
|
+
// { 'id': 'gerami', 'Exchange': gerami },
|
|
18
|
+
// { 'id': 'goldika', 'Exchange': goldika },
|
|
19
|
+
// { 'id': 'goldis', 'Exchange': goldis },
|
|
20
|
+
{ 'id': 'balinex', 'Exchange': balinex },
|
|
21
|
+
// { 'id': 'milligold', 'Exchange': milligold },
|
|
22
|
+
// { 'id': 'ramzinex', 'Exchange': ramzinex },
|
|
23
|
+
// { 'id': 'wallgold', 'Exchange': wallgold },
|
|
24
|
+
// { 'id': 'talapp', 'Exchange': talapp },
|
|
25
|
+
// { 'id': 'talaavan', 'Exchange': talaavan },
|
|
26
|
+
// { 'id': 'talasea', 'Exchange': talasea },
|
|
27
|
+
// { 'id': 'zarpin', 'Exchange': zarpin },
|
|
28
|
+
];
|
|
29
|
+
async function testExchange(id, ExchangeClass) {
|
|
30
|
+
const exchange = new ExchangeClass({
|
|
31
|
+
'enableRateLimit': true,
|
|
32
|
+
'timeout': 20000,
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
const tickers = await exchange.fetchTickers();
|
|
36
|
+
const symbols = Object.keys(tickers);
|
|
37
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
38
|
+
const symbol = symbols[i];
|
|
39
|
+
const ticker = tickers[symbol];
|
|
40
|
+
const bid = ticker['bid'];
|
|
41
|
+
const ask = ticker['ask'];
|
|
42
|
+
const last = ticker['last'];
|
|
43
|
+
if (bid !== undefined || ask !== undefined) {
|
|
44
|
+
let expectedLast = bid;
|
|
45
|
+
if (ask !== undefined && (expectedLast === undefined || ask > expectedLast)) {
|
|
46
|
+
expectedLast = ask;
|
|
47
|
+
}
|
|
48
|
+
if (last !== expectedLast) {
|
|
49
|
+
throw new Error(symbol + ' last=' + last + ', expected=' + expectedLast);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
console.log(id + ' ' + symbol + ' bid=' + bid + ' ask=' + ask + ' last=' + last + ' high=' + ticker['high'] + ' low=' + ticker['low'] + ' OK');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await exchange.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function main() {
|
|
60
|
+
for (let i = 0; i < exchanges.length; i++) {
|
|
61
|
+
const entry = exchanges[i];
|
|
62
|
+
await testExchange(entry['id'], entry['Exchange']);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
main().catch((error) => {
|
|
66
|
+
console.error('Gold platform price test failed:', error);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
});
|
package/package.json
CHANGED