ccxt-ir 4.16.3 → 4.18.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/373.ccxt.browser.js +1 -1
- package/dist/373.ccxt.browser.min.js +1 -1
- package/dist/ccxt.browser.min.js +15 -15
- package/dist/cjs/ccxt.js +46 -1
- package/dist/cjs/src/asacoine.js +359 -359
- package/dist/cjs/src/baazar.js +160 -0
- package/dist/cjs/src/base/Exchange.js +7364 -7360
- package/dist/cjs/src/bitpin.js +478 -478
- package/dist/cjs/src/daric.js +181 -0
- package/dist/cjs/src/digikalagold.js +178 -0
- package/dist/cjs/src/goldcore.js +155 -0
- package/dist/cjs/src/goldika.js +163 -0
- package/dist/cjs/src/goldis.js +157 -0
- package/dist/cjs/src/hamrahgold.js +171 -0
- package/dist/cjs/src/iranexchange.js +390 -390
- package/dist/cjs/src/melligold.js +221 -0
- package/dist/cjs/src/milligold.js +156 -0
- package/dist/cjs/src/talapp.js +156 -0
- package/dist/cjs/src/technogold.js +153 -0
- package/dist/cjs/src/wallgold.js +164 -0
- package/dist/cjs/src/zarafza.js +159 -0
- package/dist/cjs/src/zarminex.js +162 -0
- package/dist/cjs/src/zarniv.js +178 -0
- package/js/ccxt.d.ts +47 -2
- package/js/ccxt.js +32 -2
- package/js/src/abstract/baazar.d.ts +8 -0
- package/js/src/abstract/baazar.js +11 -0
- package/js/src/abstract/daric.d.ts +8 -0
- package/js/src/abstract/daric.js +11 -0
- package/js/src/abstract/digikalagold.d.ts +8 -0
- package/js/src/abstract/digikalagold.js +11 -0
- package/js/src/abstract/goldcore.d.ts +8 -0
- package/js/src/abstract/goldcore.js +11 -0
- package/js/src/abstract/goldika.d.ts +8 -0
- package/js/src/abstract/goldika.js +11 -0
- package/js/src/abstract/goldis.d.ts +8 -0
- package/js/src/abstract/goldis.js +11 -0
- package/js/src/abstract/hamrahgold.d.ts +8 -0
- package/js/src/abstract/hamrahgold.js +11 -0
- package/js/src/abstract/melligold.d.ts +8 -0
- package/js/src/abstract/melligold.js +11 -0
- package/js/src/abstract/milligold.d.ts +8 -0
- package/js/src/abstract/milligold.js +11 -0
- package/js/src/abstract/talapp.d.ts +8 -0
- package/js/src/abstract/talapp.js +11 -0
- package/js/src/abstract/technogold.d.ts +8 -0
- package/js/src/abstract/technogold.js +11 -0
- package/js/src/abstract/wallgold.d.ts +8 -0
- package/js/src/abstract/wallgold.js +11 -0
- package/js/src/abstract/zarafza.d.ts +8 -0
- package/js/src/abstract/zarafza.js +11 -0
- package/js/src/abstract/zarminex.d.ts +8 -0
- package/js/src/abstract/zarminex.js +11 -0
- package/js/src/abstract/zarniv.d.ts +9 -0
- package/js/src/abstract/zarniv.js +11 -0
- package/js/src/asacoine.d.ts +23 -23
- package/js/src/asacoine.js +363 -363
- package/js/src/baazar.d.ts +20 -0
- package/js/src/baazar.js +159 -0
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/base/Exchange.js +7397 -7393
- package/js/src/bitpin.js +481 -481
- package/js/src/coinbaseexchange.d.ts +1 -1
- package/js/src/daric.d.ts +22 -0
- package/js/src/daric.js +180 -0
- package/js/src/digikalagold.d.ts +21 -0
- package/js/src/digikalagold.js +177 -0
- package/js/src/goldcore.d.ts +20 -0
- package/js/src/goldcore.js +154 -0
- package/js/src/goldika.d.ts +20 -0
- package/js/src/goldika.js +162 -0
- package/js/src/goldis.d.ts +21 -0
- package/js/src/goldis.js +156 -0
- package/js/src/hamrahgold.d.ts +21 -0
- package/js/src/hamrahgold.js +170 -0
- package/js/src/iranexchange.js +393 -393
- package/js/src/melligold.d.ts +21 -0
- package/js/src/melligold.js +220 -0
- package/js/src/milligold.d.ts +20 -0
- package/js/src/milligold.js +155 -0
- package/js/src/protobuf/mexc/compiled.d.cts +0 -6
- package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/static_dependencies/qs/formats.d.cts +0 -6
- package/js/src/static_dependencies/qs/index.d.cts +0 -6
- package/js/src/static_dependencies/qs/parse.d.cts +0 -6
- package/js/src/static_dependencies/qs/stringify.d.cts +0 -6
- package/js/src/static_dependencies/qs/utils.d.cts +0 -6
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
- package/js/src/talapp.d.ts +20 -0
- package/js/src/talapp.js +155 -0
- package/js/src/technogold.d.ts +20 -0
- package/js/src/technogold.js +152 -0
- package/js/src/wallgold.d.ts +21 -0
- package/js/src/wallgold.js +163 -0
- package/js/src/zarafza.d.ts +20 -0
- package/js/src/zarafza.js +158 -0
- package/js/src/zarminex.d.ts +20 -0
- package/js/src/zarminex.js +161 -0
- package/js/src/zarniv.d.ts +21 -0
- package/js/src/zarniv.js +177 -0
- package/js/test.js +60 -71
- package/package.json +1 -1
package/dist/cjs/src/asacoine.js
CHANGED
|
@@ -6,365 +6,365 @@ var Exchange = require('./base/Exchange.js');
|
|
|
6
6
|
var Precise = require('./base/Precise.js');
|
|
7
7
|
|
|
8
8
|
// ----------------------------------------------------------------------------
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* @class asacoine
|
|
12
|
-
* @augments Exchange
|
|
13
|
-
*/
|
|
14
|
-
class asacoine extends Exchange["default"] {
|
|
15
|
-
describe() {
|
|
16
|
-
return this.deepExtend(super.describe(), {
|
|
17
|
-
'id': 'asacoine',
|
|
18
|
-
'name': 'Asacoine',
|
|
19
|
-
'countries': ['IR'],
|
|
20
|
-
'rateLimit': 1000,
|
|
21
|
-
'version': 'v1',
|
|
22
|
-
'certified': false,
|
|
23
|
-
'pro': false,
|
|
24
|
-
'has': {
|
|
25
|
-
'CORS': undefined,
|
|
26
|
-
'spot': true,
|
|
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
|
-
'urls': {
|
|
37
|
-
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/asacoine/64x64.png',
|
|
38
|
-
'api': {
|
|
39
|
-
'public': 'https://api.asacoine.com/api',
|
|
40
|
-
},
|
|
41
|
-
'www': 'https://asacoine.com',
|
|
42
|
-
'doc': 'https://api.asacoine.com/api/v1/market/pairs/pricing',
|
|
43
|
-
},
|
|
44
|
-
'api': {
|
|
45
|
-
'public': {
|
|
46
|
-
'get': {
|
|
47
|
-
'v1/market/pairs/pricing': 1,
|
|
48
|
-
'v1/market/pairs/cumulative': 1,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
'commonCurrencies': {
|
|
53
|
-
'TMN': 'IRT',
|
|
54
|
-
},
|
|
55
|
-
'fees': {
|
|
56
|
-
'trading': {
|
|
57
|
-
'tierBased': false,
|
|
58
|
-
'percentage': true,
|
|
59
|
-
'maker': this.parseNumber('0'),
|
|
60
|
-
'taker': this.parseNumber('0'),
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
parseMarket(market) {
|
|
66
|
-
const baseId = this.safeString(market, 'baseId');
|
|
67
|
-
const quoteId = this.safeString(market, 'quoteId');
|
|
68
|
-
const base = this.safeCurrencyCode(baseId);
|
|
69
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
70
|
-
return {
|
|
71
|
-
'id': baseId + '/' + quoteId,
|
|
72
|
-
'symbol': base + '/' + quote,
|
|
73
|
-
'base': base,
|
|
74
|
-
'quote': quote,
|
|
75
|
-
'settle': undefined,
|
|
76
|
-
'baseId': baseId,
|
|
77
|
-
'quoteId': quoteId,
|
|
78
|
-
'settleId': undefined,
|
|
79
|
-
'type': 'spot',
|
|
80
|
-
'spot': true,
|
|
81
|
-
'margin': false,
|
|
82
|
-
'swap': false,
|
|
83
|
-
'future': false,
|
|
84
|
-
'option': false,
|
|
85
|
-
'active': true,
|
|
86
|
-
'contract': false,
|
|
87
|
-
'linear': undefined,
|
|
88
|
-
'inverse': undefined,
|
|
89
|
-
'contractSize': undefined,
|
|
90
|
-
'expiry': undefined,
|
|
91
|
-
'expiryDatetime': undefined,
|
|
92
|
-
'strike': undefined,
|
|
93
|
-
'optionType': undefined,
|
|
94
|
-
'precision': {
|
|
95
|
-
'amount': undefined,
|
|
96
|
-
'price': undefined,
|
|
97
|
-
},
|
|
98
|
-
'limits': {
|
|
99
|
-
'leverage': {
|
|
100
|
-
'min': undefined,
|
|
101
|
-
'max': undefined,
|
|
102
|
-
},
|
|
103
|
-
'amount': {
|
|
104
|
-
'min': undefined,
|
|
105
|
-
'max': undefined,
|
|
106
|
-
},
|
|
107
|
-
'price': {
|
|
108
|
-
'min': undefined,
|
|
109
|
-
'max': undefined,
|
|
110
|
-
},
|
|
111
|
-
'cost': {
|
|
112
|
-
'min': undefined,
|
|
113
|
-
'max': undefined,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
'created': undefined,
|
|
117
|
-
'info': this.safeValue(market, 'info', market),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
parseOtcMarket(market) {
|
|
121
|
-
const baseId = this.safeString(market, 'baseId');
|
|
122
|
-
const quoteId = this.safeString(market, 'quoteId');
|
|
123
|
-
const base = this.safeCurrencyCode(baseId);
|
|
124
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
125
|
-
return {
|
|
126
|
-
'id': baseId + '/' + quoteId,
|
|
127
|
-
'symbol': base + '/' + quote,
|
|
128
|
-
'base': base,
|
|
129
|
-
'quote': quote,
|
|
130
|
-
'settle': undefined,
|
|
131
|
-
'baseId': baseId,
|
|
132
|
-
'quoteId': quoteId,
|
|
133
|
-
'settleId': undefined,
|
|
134
|
-
'type': 'otc',
|
|
135
|
-
'spot': false,
|
|
136
|
-
'margin': false,
|
|
137
|
-
'swap': false,
|
|
138
|
-
'future': false,
|
|
139
|
-
'option': false,
|
|
140
|
-
'active': true,
|
|
141
|
-
'contract': false,
|
|
142
|
-
'linear': undefined,
|
|
143
|
-
'inverse': undefined,
|
|
144
|
-
'contractSize': undefined,
|
|
145
|
-
'expiry': undefined,
|
|
146
|
-
'expiryDatetime': undefined,
|
|
147
|
-
'strike': undefined,
|
|
148
|
-
'optionType': undefined,
|
|
149
|
-
'precision': {
|
|
150
|
-
'amount': undefined,
|
|
151
|
-
'price': undefined,
|
|
152
|
-
},
|
|
153
|
-
'limits': {
|
|
154
|
-
'leverage': {
|
|
155
|
-
'min': undefined,
|
|
156
|
-
'max': undefined,
|
|
157
|
-
},
|
|
158
|
-
'amount': {
|
|
159
|
-
'min': undefined,
|
|
160
|
-
'max': undefined,
|
|
161
|
-
},
|
|
162
|
-
'price': {
|
|
163
|
-
'min': undefined,
|
|
164
|
-
'max': undefined,
|
|
165
|
-
},
|
|
166
|
-
'cost': {
|
|
167
|
-
'min': undefined,
|
|
168
|
-
'max': undefined,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
'created': undefined,
|
|
172
|
-
'info': this.safeValue(market, 'info', market),
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
parseMarkets(response) {
|
|
176
|
-
const data = this.safeDict(response, 'data', {});
|
|
177
|
-
const baseIds = Object.keys(data);
|
|
178
|
-
const result = [];
|
|
179
|
-
for (let i = 0; i < baseIds.length; i++) {
|
|
180
|
-
const baseId = baseIds[i];
|
|
181
|
-
const quotes = this.safeDict(data, baseId, {});
|
|
182
|
-
const quoteIds = Object.keys(quotes);
|
|
183
|
-
for (let j = 0; j < quoteIds.length; j++) {
|
|
184
|
-
const quoteId = quoteIds[j];
|
|
185
|
-
const ticker = this.safeDict(quotes, quoteId, {});
|
|
186
|
-
result.push(this.parseMarket({ 'baseId': baseId, 'quoteId': quoteId, 'info': ticker }));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
parseCumulativeMarkets(response) {
|
|
192
|
-
const data = this.safeDict(response, 'data', {});
|
|
193
|
-
const keys = this.safeList(data, 'keys', []);
|
|
194
|
-
const values = this.safeList(data, 'values', []);
|
|
195
|
-
const result = [];
|
|
196
|
-
for (let i = 0; i < values.length; i++) {
|
|
197
|
-
const row = values[i];
|
|
198
|
-
const market = {};
|
|
199
|
-
for (let j = 0; j < keys.length; j++) {
|
|
200
|
-
market[keys[j]] = row[j];
|
|
201
|
-
}
|
|
202
|
-
const marketTypes = this.safeList(market, 'marketTypes', []);
|
|
203
|
-
if (!this.inArray('otc', marketTypes)) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
const name = this.safeString(market, 'name');
|
|
207
|
-
const [baseId, quoteId] = name.split('-');
|
|
208
|
-
market['baseId'] = baseId;
|
|
209
|
-
market['quoteId'] = quoteId;
|
|
210
|
-
result.push(this.parseOtcMarket(market));
|
|
211
|
-
}
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
async fetchMarkets(params = {}) {
|
|
215
|
-
/**
|
|
216
|
-
* @method
|
|
217
|
-
* @name asacoine#fetchMarkets
|
|
218
|
-
* @description retrieves data on all markets for asacoine
|
|
219
|
-
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
220
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
221
|
-
* @returns {object[]} an array of objects representing market data
|
|
222
|
-
*/
|
|
223
|
-
const type = this.safeString(params, 'type', 'spot');
|
|
224
|
-
const request = this.omit(params, ['type']);
|
|
225
|
-
if (type === 'otc') {
|
|
226
|
-
const cumulativeResponse = await this.publicGetV1MarketPairsCumulative(request);
|
|
227
|
-
return this.parseCumulativeMarkets(cumulativeResponse);
|
|
228
|
-
}
|
|
229
|
-
const response = await this.publicGetV1MarketPairsPricing(request);
|
|
230
|
-
return this.parseMarkets(response);
|
|
231
|
-
}
|
|
232
|
-
parseTicker(ticker, market = undefined) {
|
|
233
|
-
const bid = this.safeList(ticker, 'bid', []);
|
|
234
|
-
const ask = this.safeList(ticker, 'ask', []);
|
|
235
|
-
const nestedOrderBook = this.safeDict(ticker, 'orderBook');
|
|
236
|
-
let cumulativeOrderBook = nestedOrderBook;
|
|
237
|
-
if ((nestedOrderBook === undefined) && (this.safeString(ticker, 'bestBid') !== undefined)) {
|
|
238
|
-
cumulativeOrderBook = ticker;
|
|
239
|
-
}
|
|
240
|
-
let orderBook = cumulativeOrderBook;
|
|
241
|
-
if (orderBook === undefined) {
|
|
242
|
-
orderBook = {};
|
|
243
|
-
}
|
|
244
|
-
let bidPriceString = this.safeString(orderBook, 'bestBid');
|
|
245
|
-
let askPriceString = this.safeString(orderBook, 'bestAsk');
|
|
246
|
-
let bidVolume = this.safeNumber(orderBook, 'bidSize');
|
|
247
|
-
let askVolume = this.safeNumber(orderBook, 'askSize');
|
|
248
|
-
if (cumulativeOrderBook === undefined) {
|
|
249
|
-
bidPriceString = this.safeString(bid, 0);
|
|
250
|
-
askPriceString = this.safeString(ask, 0);
|
|
251
|
-
bidVolume = this.safeNumber(bid, 1);
|
|
252
|
-
askVolume = this.safeNumber(ask, 1);
|
|
253
|
-
}
|
|
254
|
-
const bidPrice = this.parseNumber(bidPriceString);
|
|
255
|
-
const askPrice = this.parseNumber(askPriceString);
|
|
256
|
-
let last = undefined;
|
|
257
|
-
if ((bidPriceString !== undefined) && (askPriceString !== undefined)) {
|
|
258
|
-
last = this.parseNumber(Precise["default"].stringDiv(Precise["default"].stringAdd(bidPriceString, askPriceString), '2'));
|
|
259
|
-
}
|
|
260
|
-
return this.safeTicker({
|
|
261
|
-
'symbol': this.safeString(market, 'symbol'),
|
|
262
|
-
'timestamp': undefined,
|
|
263
|
-
'datetime': undefined,
|
|
264
|
-
'high': undefined,
|
|
265
|
-
'low': undefined,
|
|
266
|
-
'bid': bidPrice,
|
|
267
|
-
'bidVolume': bidVolume,
|
|
268
|
-
'ask': askPrice,
|
|
269
|
-
'askVolume': askVolume,
|
|
270
|
-
'vwap': undefined,
|
|
271
|
-
'open': undefined,
|
|
272
|
-
'close': last,
|
|
273
|
-
'last': last,
|
|
274
|
-
'previousClose': undefined,
|
|
275
|
-
'change': undefined,
|
|
276
|
-
'percentage': undefined,
|
|
277
|
-
'average': last,
|
|
278
|
-
'baseVolume': undefined,
|
|
279
|
-
'quoteVolume': undefined,
|
|
280
|
-
'info': ticker,
|
|
281
|
-
}, market);
|
|
282
|
-
}
|
|
283
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
284
|
-
/**
|
|
285
|
-
* @method
|
|
286
|
-
* @name asacoine#fetchTickers
|
|
287
|
-
* @description fetches price tickers for multiple markets
|
|
288
|
-
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
289
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the tickers for, all market tickers are returned if not assigned
|
|
290
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
291
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
292
|
-
*/
|
|
293
|
-
const type = this.safeString(params, 'type', 'spot');
|
|
294
|
-
const request = this.omit(params, ['type']);
|
|
295
|
-
await this.loadMarkets(false, { 'type': type });
|
|
296
|
-
if (symbols !== undefined) {
|
|
297
|
-
symbols = this.marketSymbols(symbols);
|
|
298
|
-
}
|
|
299
|
-
let response = {};
|
|
300
|
-
if (type === 'otc') {
|
|
301
|
-
response = await this.publicGetV1MarketPairsCumulative(request);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
response = await this.publicGetV1MarketPairsPricing(request);
|
|
305
|
-
}
|
|
306
|
-
if (type === 'otc') {
|
|
307
|
-
const cumulativeData = this.safeDict(response, 'data', {});
|
|
308
|
-
const keys = this.safeList(cumulativeData, 'keys', []);
|
|
309
|
-
const values = this.safeList(cumulativeData, 'values', []);
|
|
310
|
-
const cumulativeTickers = {};
|
|
311
|
-
for (let i = 0; i < values.length; i++) {
|
|
312
|
-
const row = values[i];
|
|
313
|
-
const raw = {};
|
|
314
|
-
for (let j = 0; j < keys.length; j++) {
|
|
315
|
-
raw[keys[j]] = row[j];
|
|
316
|
-
}
|
|
317
|
-
const name = this.safeString(raw, 'name');
|
|
318
|
-
const [baseId, quoteId] = name.split('-');
|
|
319
|
-
const base = this.safeCurrencyCode(baseId);
|
|
320
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
321
|
-
const market = this.safeMarket(base + '/' + quote);
|
|
322
|
-
const parsed = this.parseTicker(this.safeDict(raw, 'orderBook', {}), market);
|
|
323
|
-
cumulativeTickers[parsed['symbol']] = parsed;
|
|
324
|
-
}
|
|
325
|
-
return this.filterByArrayTickers(cumulativeTickers, 'symbol', symbols);
|
|
326
|
-
}
|
|
327
|
-
const data = this.safeDict(response, 'data', {});
|
|
328
|
-
const baseIds = Object.keys(data);
|
|
329
|
-
const result = {};
|
|
330
|
-
for (let i = 0; i < baseIds.length; i++) {
|
|
331
|
-
const baseId = baseIds[i];
|
|
332
|
-
const quotes = this.safeDict(data, baseId, {});
|
|
333
|
-
const quoteIds = Object.keys(quotes);
|
|
334
|
-
for (let j = 0; j < quoteIds.length; j++) {
|
|
335
|
-
const quoteId = quoteIds[j];
|
|
336
|
-
const ticker = this.safeDict(quotes, quoteId, {});
|
|
337
|
-
const market = this.safeMarket(baseId + '/' + quoteId);
|
|
338
|
-
const parsed = this.parseTicker(ticker, market);
|
|
339
|
-
result[parsed['symbol']] = parsed;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
343
|
-
}
|
|
344
|
-
async fetchTicker(symbol, params = {}) {
|
|
345
|
-
/**
|
|
346
|
-
* @method
|
|
347
|
-
* @name asacoine#fetchTicker
|
|
348
|
-
* @description fetches a price ticker, a statistical calculation for a specific market
|
|
349
|
-
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
350
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
351
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
352
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
353
|
-
*/
|
|
354
|
-
const tickers = await this.fetchTickers([symbol], params);
|
|
355
|
-
return tickers[symbol];
|
|
356
|
-
}
|
|
357
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
358
|
-
const query = this.omit(params, this.extractParams(path));
|
|
359
|
-
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
360
|
-
if (Object.keys(query).length) {
|
|
361
|
-
url += '?' + this.urlencode(query);
|
|
362
|
-
}
|
|
363
|
-
headers = {
|
|
364
|
-
'Content-Type': 'application/json',
|
|
365
|
-
};
|
|
366
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
367
|
-
}
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* @class asacoine
|
|
12
|
+
* @augments Exchange
|
|
13
|
+
*/
|
|
14
|
+
class asacoine extends Exchange["default"] {
|
|
15
|
+
describe() {
|
|
16
|
+
return this.deepExtend(super.describe(), {
|
|
17
|
+
'id': 'asacoine',
|
|
18
|
+
'name': 'Asacoine',
|
|
19
|
+
'countries': ['IR'],
|
|
20
|
+
'rateLimit': 1000,
|
|
21
|
+
'version': 'v1',
|
|
22
|
+
'certified': false,
|
|
23
|
+
'pro': false,
|
|
24
|
+
'has': {
|
|
25
|
+
'CORS': undefined,
|
|
26
|
+
'spot': true,
|
|
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
|
+
'urls': {
|
|
37
|
+
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/asacoine/64x64.png',
|
|
38
|
+
'api': {
|
|
39
|
+
'public': 'https://api.asacoine.com/api',
|
|
40
|
+
},
|
|
41
|
+
'www': 'https://asacoine.com',
|
|
42
|
+
'doc': 'https://api.asacoine.com/api/v1/market/pairs/pricing',
|
|
43
|
+
},
|
|
44
|
+
'api': {
|
|
45
|
+
'public': {
|
|
46
|
+
'get': {
|
|
47
|
+
'v1/market/pairs/pricing': 1,
|
|
48
|
+
'v1/market/pairs/cumulative': 1,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
'commonCurrencies': {
|
|
53
|
+
'TMN': 'IRT',
|
|
54
|
+
},
|
|
55
|
+
'fees': {
|
|
56
|
+
'trading': {
|
|
57
|
+
'tierBased': false,
|
|
58
|
+
'percentage': true,
|
|
59
|
+
'maker': this.parseNumber('0'),
|
|
60
|
+
'taker': this.parseNumber('0'),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
parseMarket(market) {
|
|
66
|
+
const baseId = this.safeString(market, 'baseId');
|
|
67
|
+
const quoteId = this.safeString(market, 'quoteId');
|
|
68
|
+
const base = this.safeCurrencyCode(baseId);
|
|
69
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
70
|
+
return {
|
|
71
|
+
'id': baseId + '/' + quoteId,
|
|
72
|
+
'symbol': base + '/' + quote,
|
|
73
|
+
'base': base,
|
|
74
|
+
'quote': quote,
|
|
75
|
+
'settle': undefined,
|
|
76
|
+
'baseId': baseId,
|
|
77
|
+
'quoteId': quoteId,
|
|
78
|
+
'settleId': undefined,
|
|
79
|
+
'type': 'spot',
|
|
80
|
+
'spot': true,
|
|
81
|
+
'margin': false,
|
|
82
|
+
'swap': false,
|
|
83
|
+
'future': false,
|
|
84
|
+
'option': false,
|
|
85
|
+
'active': true,
|
|
86
|
+
'contract': false,
|
|
87
|
+
'linear': undefined,
|
|
88
|
+
'inverse': undefined,
|
|
89
|
+
'contractSize': undefined,
|
|
90
|
+
'expiry': undefined,
|
|
91
|
+
'expiryDatetime': undefined,
|
|
92
|
+
'strike': undefined,
|
|
93
|
+
'optionType': undefined,
|
|
94
|
+
'precision': {
|
|
95
|
+
'amount': undefined,
|
|
96
|
+
'price': undefined,
|
|
97
|
+
},
|
|
98
|
+
'limits': {
|
|
99
|
+
'leverage': {
|
|
100
|
+
'min': undefined,
|
|
101
|
+
'max': undefined,
|
|
102
|
+
},
|
|
103
|
+
'amount': {
|
|
104
|
+
'min': undefined,
|
|
105
|
+
'max': undefined,
|
|
106
|
+
},
|
|
107
|
+
'price': {
|
|
108
|
+
'min': undefined,
|
|
109
|
+
'max': undefined,
|
|
110
|
+
},
|
|
111
|
+
'cost': {
|
|
112
|
+
'min': undefined,
|
|
113
|
+
'max': undefined,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
'created': undefined,
|
|
117
|
+
'info': this.safeValue(market, 'info', market),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
parseOtcMarket(market) {
|
|
121
|
+
const baseId = this.safeString(market, 'baseId');
|
|
122
|
+
const quoteId = this.safeString(market, 'quoteId');
|
|
123
|
+
const base = this.safeCurrencyCode(baseId);
|
|
124
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
125
|
+
return {
|
|
126
|
+
'id': baseId + '/' + quoteId,
|
|
127
|
+
'symbol': base + '/' + quote,
|
|
128
|
+
'base': base,
|
|
129
|
+
'quote': quote,
|
|
130
|
+
'settle': undefined,
|
|
131
|
+
'baseId': baseId,
|
|
132
|
+
'quoteId': quoteId,
|
|
133
|
+
'settleId': undefined,
|
|
134
|
+
'type': 'otc',
|
|
135
|
+
'spot': false,
|
|
136
|
+
'margin': false,
|
|
137
|
+
'swap': false,
|
|
138
|
+
'future': false,
|
|
139
|
+
'option': false,
|
|
140
|
+
'active': true,
|
|
141
|
+
'contract': false,
|
|
142
|
+
'linear': undefined,
|
|
143
|
+
'inverse': undefined,
|
|
144
|
+
'contractSize': undefined,
|
|
145
|
+
'expiry': undefined,
|
|
146
|
+
'expiryDatetime': undefined,
|
|
147
|
+
'strike': undefined,
|
|
148
|
+
'optionType': undefined,
|
|
149
|
+
'precision': {
|
|
150
|
+
'amount': undefined,
|
|
151
|
+
'price': undefined,
|
|
152
|
+
},
|
|
153
|
+
'limits': {
|
|
154
|
+
'leverage': {
|
|
155
|
+
'min': undefined,
|
|
156
|
+
'max': undefined,
|
|
157
|
+
},
|
|
158
|
+
'amount': {
|
|
159
|
+
'min': undefined,
|
|
160
|
+
'max': undefined,
|
|
161
|
+
},
|
|
162
|
+
'price': {
|
|
163
|
+
'min': undefined,
|
|
164
|
+
'max': undefined,
|
|
165
|
+
},
|
|
166
|
+
'cost': {
|
|
167
|
+
'min': undefined,
|
|
168
|
+
'max': undefined,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
'created': undefined,
|
|
172
|
+
'info': this.safeValue(market, 'info', market),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
parseMarkets(response) {
|
|
176
|
+
const data = this.safeDict(response, 'data', {});
|
|
177
|
+
const baseIds = Object.keys(data);
|
|
178
|
+
const result = [];
|
|
179
|
+
for (let i = 0; i < baseIds.length; i++) {
|
|
180
|
+
const baseId = baseIds[i];
|
|
181
|
+
const quotes = this.safeDict(data, baseId, {});
|
|
182
|
+
const quoteIds = Object.keys(quotes);
|
|
183
|
+
for (let j = 0; j < quoteIds.length; j++) {
|
|
184
|
+
const quoteId = quoteIds[j];
|
|
185
|
+
const ticker = this.safeDict(quotes, quoteId, {});
|
|
186
|
+
result.push(this.parseMarket({ 'baseId': baseId, 'quoteId': quoteId, 'info': ticker }));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
parseCumulativeMarkets(response) {
|
|
192
|
+
const data = this.safeDict(response, 'data', {});
|
|
193
|
+
const keys = this.safeList(data, 'keys', []);
|
|
194
|
+
const values = this.safeList(data, 'values', []);
|
|
195
|
+
const result = [];
|
|
196
|
+
for (let i = 0; i < values.length; i++) {
|
|
197
|
+
const row = values[i];
|
|
198
|
+
const market = {};
|
|
199
|
+
for (let j = 0; j < keys.length; j++) {
|
|
200
|
+
market[keys[j]] = row[j];
|
|
201
|
+
}
|
|
202
|
+
const marketTypes = this.safeList(market, 'marketTypes', []);
|
|
203
|
+
if (!this.inArray('otc', marketTypes)) {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const name = this.safeString(market, 'name');
|
|
207
|
+
const [baseId, quoteId] = name.split('-');
|
|
208
|
+
market['baseId'] = baseId;
|
|
209
|
+
market['quoteId'] = quoteId;
|
|
210
|
+
result.push(this.parseOtcMarket(market));
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
async fetchMarkets(params = {}) {
|
|
215
|
+
/**
|
|
216
|
+
* @method
|
|
217
|
+
* @name asacoine#fetchMarkets
|
|
218
|
+
* @description retrieves data on all markets for asacoine
|
|
219
|
+
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
220
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
221
|
+
* @returns {object[]} an array of objects representing market data
|
|
222
|
+
*/
|
|
223
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
224
|
+
const request = this.omit(params, ['type']);
|
|
225
|
+
if (type === 'otc') {
|
|
226
|
+
const cumulativeResponse = await this.publicGetV1MarketPairsCumulative(request);
|
|
227
|
+
return this.parseCumulativeMarkets(cumulativeResponse);
|
|
228
|
+
}
|
|
229
|
+
const response = await this.publicGetV1MarketPairsPricing(request);
|
|
230
|
+
return this.parseMarkets(response);
|
|
231
|
+
}
|
|
232
|
+
parseTicker(ticker, market = undefined) {
|
|
233
|
+
const bid = this.safeList(ticker, 'bid', []);
|
|
234
|
+
const ask = this.safeList(ticker, 'ask', []);
|
|
235
|
+
const nestedOrderBook = this.safeDict(ticker, 'orderBook');
|
|
236
|
+
let cumulativeOrderBook = nestedOrderBook;
|
|
237
|
+
if ((nestedOrderBook === undefined) && (this.safeString(ticker, 'bestBid') !== undefined)) {
|
|
238
|
+
cumulativeOrderBook = ticker;
|
|
239
|
+
}
|
|
240
|
+
let orderBook = cumulativeOrderBook;
|
|
241
|
+
if (orderBook === undefined) {
|
|
242
|
+
orderBook = {};
|
|
243
|
+
}
|
|
244
|
+
let bidPriceString = this.safeString(orderBook, 'bestBid');
|
|
245
|
+
let askPriceString = this.safeString(orderBook, 'bestAsk');
|
|
246
|
+
let bidVolume = this.safeNumber(orderBook, 'bidSize');
|
|
247
|
+
let askVolume = this.safeNumber(orderBook, 'askSize');
|
|
248
|
+
if (cumulativeOrderBook === undefined) {
|
|
249
|
+
bidPriceString = this.safeString(bid, 0);
|
|
250
|
+
askPriceString = this.safeString(ask, 0);
|
|
251
|
+
bidVolume = this.safeNumber(bid, 1);
|
|
252
|
+
askVolume = this.safeNumber(ask, 1);
|
|
253
|
+
}
|
|
254
|
+
const bidPrice = this.parseNumber(bidPriceString);
|
|
255
|
+
const askPrice = this.parseNumber(askPriceString);
|
|
256
|
+
let last = undefined;
|
|
257
|
+
if ((bidPriceString !== undefined) && (askPriceString !== undefined)) {
|
|
258
|
+
last = this.parseNumber(Precise["default"].stringDiv(Precise["default"].stringAdd(bidPriceString, askPriceString), '2'));
|
|
259
|
+
}
|
|
260
|
+
return this.safeTicker({
|
|
261
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
262
|
+
'timestamp': undefined,
|
|
263
|
+
'datetime': undefined,
|
|
264
|
+
'high': undefined,
|
|
265
|
+
'low': undefined,
|
|
266
|
+
'bid': bidPrice,
|
|
267
|
+
'bidVolume': bidVolume,
|
|
268
|
+
'ask': askPrice,
|
|
269
|
+
'askVolume': askVolume,
|
|
270
|
+
'vwap': undefined,
|
|
271
|
+
'open': undefined,
|
|
272
|
+
'close': last,
|
|
273
|
+
'last': last,
|
|
274
|
+
'previousClose': undefined,
|
|
275
|
+
'change': undefined,
|
|
276
|
+
'percentage': undefined,
|
|
277
|
+
'average': last,
|
|
278
|
+
'baseVolume': undefined,
|
|
279
|
+
'quoteVolume': undefined,
|
|
280
|
+
'info': ticker,
|
|
281
|
+
}, market);
|
|
282
|
+
}
|
|
283
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
284
|
+
/**
|
|
285
|
+
* @method
|
|
286
|
+
* @name asacoine#fetchTickers
|
|
287
|
+
* @description fetches price tickers for multiple markets
|
|
288
|
+
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
289
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the tickers for, all market tickers are returned if not assigned
|
|
290
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
291
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
292
|
+
*/
|
|
293
|
+
const type = this.safeString(params, 'type', 'spot');
|
|
294
|
+
const request = this.omit(params, ['type']);
|
|
295
|
+
await this.loadMarkets(false, { 'type': type });
|
|
296
|
+
if (symbols !== undefined) {
|
|
297
|
+
symbols = this.marketSymbols(symbols);
|
|
298
|
+
}
|
|
299
|
+
let response = {};
|
|
300
|
+
if (type === 'otc') {
|
|
301
|
+
response = await this.publicGetV1MarketPairsCumulative(request);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
response = await this.publicGetV1MarketPairsPricing(request);
|
|
305
|
+
}
|
|
306
|
+
if (type === 'otc') {
|
|
307
|
+
const cumulativeData = this.safeDict(response, 'data', {});
|
|
308
|
+
const keys = this.safeList(cumulativeData, 'keys', []);
|
|
309
|
+
const values = this.safeList(cumulativeData, 'values', []);
|
|
310
|
+
const cumulativeTickers = {};
|
|
311
|
+
for (let i = 0; i < values.length; i++) {
|
|
312
|
+
const row = values[i];
|
|
313
|
+
const raw = {};
|
|
314
|
+
for (let j = 0; j < keys.length; j++) {
|
|
315
|
+
raw[keys[j]] = row[j];
|
|
316
|
+
}
|
|
317
|
+
const name = this.safeString(raw, 'name');
|
|
318
|
+
const [baseId, quoteId] = name.split('-');
|
|
319
|
+
const base = this.safeCurrencyCode(baseId);
|
|
320
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
321
|
+
const market = this.safeMarket(base + '/' + quote);
|
|
322
|
+
const parsed = this.parseTicker(this.safeDict(raw, 'orderBook', {}), market);
|
|
323
|
+
cumulativeTickers[parsed['symbol']] = parsed;
|
|
324
|
+
}
|
|
325
|
+
return this.filterByArrayTickers(cumulativeTickers, 'symbol', symbols);
|
|
326
|
+
}
|
|
327
|
+
const data = this.safeDict(response, 'data', {});
|
|
328
|
+
const baseIds = Object.keys(data);
|
|
329
|
+
const result = {};
|
|
330
|
+
for (let i = 0; i < baseIds.length; i++) {
|
|
331
|
+
const baseId = baseIds[i];
|
|
332
|
+
const quotes = this.safeDict(data, baseId, {});
|
|
333
|
+
const quoteIds = Object.keys(quotes);
|
|
334
|
+
for (let j = 0; j < quoteIds.length; j++) {
|
|
335
|
+
const quoteId = quoteIds[j];
|
|
336
|
+
const ticker = this.safeDict(quotes, quoteId, {});
|
|
337
|
+
const market = this.safeMarket(baseId + '/' + quoteId);
|
|
338
|
+
const parsed = this.parseTicker(ticker, market);
|
|
339
|
+
result[parsed['symbol']] = parsed;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
343
|
+
}
|
|
344
|
+
async fetchTicker(symbol, params = {}) {
|
|
345
|
+
/**
|
|
346
|
+
* @method
|
|
347
|
+
* @name asacoine#fetchTicker
|
|
348
|
+
* @description fetches a price ticker, a statistical calculation for a specific market
|
|
349
|
+
* @see https://api.asacoine.com/api/v1/market/pairs/pricing
|
|
350
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
351
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
352
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
353
|
+
*/
|
|
354
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
355
|
+
return tickers[symbol];
|
|
356
|
+
}
|
|
357
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
358
|
+
const query = this.omit(params, this.extractParams(path));
|
|
359
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
360
|
+
if (Object.keys(query).length) {
|
|
361
|
+
url += '?' + this.urlencode(query);
|
|
362
|
+
}
|
|
363
|
+
headers = {
|
|
364
|
+
'Content-Type': 'application/json',
|
|
365
|
+
};
|
|
366
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
367
|
+
}
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
exports["default"] = asacoine;
|