ccxt-ir 4.9.27 → 4.9.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/raastin.js +11 -0
- package/dist/cjs/src/bit24.js +380 -380
- package/dist/cjs/src/bitpin.js +478 -478
- package/dist/cjs/src/kifpoolme.js +4 -4
- package/dist/cjs/src/raastin.js +367 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/bitpin.d.ts +11 -11
- package/js/src/abstract/raastin.d.ts +10 -0
- package/js/src/abstract/raastin.js +11 -0
- package/js/src/base/Exchange.d.ts +926 -926
- package/js/src/bit24.js +383 -383
- package/js/src/bitpin.js +481 -481
- package/js/src/coinbaseexchange.d.ts +334 -334
- package/js/src/kifpoolme.js +4 -4
- package/js/src/protobuf/mexc/compiled.d.cts +2 -2
- package/js/src/raastin.d.ts +22 -0
- package/js/src/raastin.js +366 -0
- package/js/src/static_dependencies/fflake/browser.d.ts +222 -222
- package/js/src/static_dependencies/qs/formats.d.cts +8 -8
- package/js/src/static_dependencies/qs/index.d.cts +4 -4
- package/js/src/static_dependencies/qs/parse.d.cts +2 -2
- package/js/src/static_dependencies/qs/stringify.d.cts +2 -2
- package/js/src/static_dependencies/qs/utils.d.cts +9 -9
- package/package.json +1 -1
package/dist/cjs/src/bitpin.js
CHANGED
|
@@ -5,484 +5,484 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var bitpin$1 = require('./abstract/bitpin.js');
|
|
6
6
|
|
|
7
7
|
// ----------------------------------------------------------------------------
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
/**
|
|
10
|
-
* @class bitpin
|
|
11
|
-
* @augments Exchange
|
|
12
|
-
* @description Set rateLimit to 1000 if fully verified
|
|
13
|
-
*/
|
|
14
|
-
class bitpin extends bitpin$1["default"] {
|
|
15
|
-
describe() {
|
|
16
|
-
return this.deepExtend(super.describe(), {
|
|
17
|
-
'id': 'bitpin',
|
|
18
|
-
'name': 'bitpin',
|
|
19
|
-
'countries': ['IR'],
|
|
20
|
-
'rateLimit': 1000,
|
|
21
|
-
'version': '1',
|
|
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
|
-
'addMargin': false,
|
|
32
|
-
'cancelAllOrders': false,
|
|
33
|
-
'cancelOrder': false,
|
|
34
|
-
'cancelOrders': false,
|
|
35
|
-
'createDepositAddress': false,
|
|
36
|
-
'createOrder': false,
|
|
37
|
-
'createStopLimitOrder': false,
|
|
38
|
-
'createStopMarketOrder': false,
|
|
39
|
-
'createStopOrder': false,
|
|
40
|
-
'editOrder': false,
|
|
41
|
-
'fetchBalance': false,
|
|
42
|
-
'fetchBorrowInterest': false,
|
|
43
|
-
'fetchBorrowRateHistories': false,
|
|
44
|
-
'fetchBorrowRateHistory': false,
|
|
45
|
-
'fetchClosedOrders': false,
|
|
46
|
-
'fetchCrossBorrowRate': false,
|
|
47
|
-
'fetchCrossBorrowRates': false,
|
|
48
|
-
'fetchCurrencies': false,
|
|
49
|
-
'fetchDepositAddress': false,
|
|
50
|
-
'fetchDeposits': false,
|
|
51
|
-
'fetchFundingHistory': false,
|
|
52
|
-
'fetchFundingRate': false,
|
|
53
|
-
'fetchFundingRateHistory': false,
|
|
54
|
-
'fetchFundingRates': false,
|
|
55
|
-
'fetchIndexOHLCV': false,
|
|
56
|
-
'fetchIsolatedBorrowRate': false,
|
|
57
|
-
'fetchIsolatedBorrowRates': false,
|
|
58
|
-
'fetchL2OrderBook': false,
|
|
59
|
-
'fetchL3OrderBook': false,
|
|
60
|
-
'fetchLedger': false,
|
|
61
|
-
'fetchLedgerEntry': false,
|
|
62
|
-
'fetchLeverageTiers': false,
|
|
63
|
-
'fetchMarkets': true,
|
|
64
|
-
'fetchMarkOHLCV': false,
|
|
65
|
-
'fetchMyTrades': false,
|
|
66
|
-
'fetchOHLCV': true,
|
|
67
|
-
'fetchOpenInterestHistory': false,
|
|
68
|
-
'fetchOpenOrders': false,
|
|
69
|
-
'fetchOrder': false,
|
|
70
|
-
'fetchOrderBook': true,
|
|
71
|
-
'fetchOrders': false,
|
|
72
|
-
'fetchOrderTrades': 'emulated',
|
|
73
|
-
'fetchPositions': false,
|
|
74
|
-
'fetchPremiumIndexOHLCV': false,
|
|
75
|
-
'fetchTicker': true,
|
|
76
|
-
'fetchTickers': true,
|
|
77
|
-
'fetchTime': false,
|
|
78
|
-
'fetchTrades': false,
|
|
79
|
-
'fetchTradingFee': false,
|
|
80
|
-
'fetchTradingFees': false,
|
|
81
|
-
'fetchWithdrawals': false,
|
|
82
|
-
'setLeverage': false,
|
|
83
|
-
'setMarginMode': false,
|
|
84
|
-
'transfer': false,
|
|
85
|
-
'withdraw': false,
|
|
86
|
-
},
|
|
87
|
-
'comment': 'This comment is optional',
|
|
88
|
-
'urls': {
|
|
89
|
-
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitpin/64x64.png',
|
|
90
|
-
'api': {
|
|
91
|
-
'public': 'https://api.bitpin.ir',
|
|
92
|
-
'OHLCV': 'https://api.bitpin.org',
|
|
93
|
-
},
|
|
94
|
-
'www': 'https://bitpin.ir',
|
|
95
|
-
'doc': [
|
|
96
|
-
'https://docs.bitpin.ir',
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
'timeframes': {
|
|
100
|
-
'1m': '1',
|
|
101
|
-
'5m': '5',
|
|
102
|
-
'15m': '15',
|
|
103
|
-
'30m': '30',
|
|
104
|
-
'1h': '60',
|
|
105
|
-
'3h': '180',
|
|
106
|
-
'4h': '240',
|
|
107
|
-
'12h': '720',
|
|
108
|
-
'1d': '1D',
|
|
109
|
-
'1w': '1W',
|
|
110
|
-
},
|
|
111
|
-
'api': {
|
|
112
|
-
'public': {
|
|
113
|
-
'get': {
|
|
114
|
-
'v1/mkt/markets/': 1,
|
|
115
|
-
'v2/mth/actives/': 1,
|
|
116
|
-
'v1/mkt/tv/get_bars/': 1,
|
|
117
|
-
'v4/mth/orderbook/': 1,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
'fees': {
|
|
122
|
-
'trading': {
|
|
123
|
-
'tierBased': false,
|
|
124
|
-
'percentage': true,
|
|
125
|
-
'maker': this.parseNumber('0.001'),
|
|
126
|
-
'taker': this.parseNumber('0.001'),
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
async fetchMarkets(params = {}) {
|
|
132
|
-
/**
|
|
133
|
-
* @method
|
|
134
|
-
* @name bitpin#fetchMarkets
|
|
135
|
-
* @description retrieves data on all markets for bitpin
|
|
136
|
-
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
137
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
138
|
-
* @returns {object[]} an array of objects representing market data
|
|
139
|
-
*/
|
|
140
|
-
const response = await this.publicGetV1MktMarkets(params);
|
|
141
|
-
const markets = this.safeList(response, 'results');
|
|
142
|
-
const result = [];
|
|
143
|
-
for (let i = 0; i < markets.length; i++) {
|
|
144
|
-
const market = this.parseMarket(markets[i]);
|
|
145
|
-
result.push(market);
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
parseMarket(market) {
|
|
150
|
-
const id = this.safeString(market, 'id');
|
|
151
|
-
const baseCurrency = this.safeDict(market, 'currency1');
|
|
152
|
-
const quoteCurrency = this.safeDict(market, 'currency2');
|
|
153
|
-
let baseId = this.safeString(baseCurrency, 'code');
|
|
154
|
-
let quoteId = this.safeString(quoteCurrency, 'code');
|
|
155
|
-
const base = this.safeCurrencyCode(baseId);
|
|
156
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
157
|
-
baseId = baseId.toLowerCase();
|
|
158
|
-
quoteId = quoteId.toLowerCase();
|
|
159
|
-
return {
|
|
160
|
-
'id': id,
|
|
161
|
-
'symbol': base + '/' + quote,
|
|
162
|
-
'base': base,
|
|
163
|
-
'quote': quote,
|
|
164
|
-
'settle': undefined,
|
|
165
|
-
'baseId': baseId,
|
|
166
|
-
'quoteId': quoteId,
|
|
167
|
-
'settleId': undefined,
|
|
168
|
-
'type': 'spot',
|
|
169
|
-
'spot': true,
|
|
170
|
-
'margin': false,
|
|
171
|
-
'swap': false,
|
|
172
|
-
'future': false,
|
|
173
|
-
'option': false,
|
|
174
|
-
'active': true,
|
|
175
|
-
'contract': false,
|
|
176
|
-
'linear': undefined,
|
|
177
|
-
'inverse': undefined,
|
|
178
|
-
'contractSize': undefined,
|
|
179
|
-
'expiry': undefined,
|
|
180
|
-
'expiryDatetime': undefined,
|
|
181
|
-
'strike': undefined,
|
|
182
|
-
'optionType': undefined,
|
|
183
|
-
'precision': {
|
|
184
|
-
'amount': undefined,
|
|
185
|
-
'price': undefined,
|
|
186
|
-
},
|
|
187
|
-
'limits': {
|
|
188
|
-
'leverage': {
|
|
189
|
-
'min': undefined,
|
|
190
|
-
'max': undefined,
|
|
191
|
-
},
|
|
192
|
-
'amount': {
|
|
193
|
-
'min': undefined,
|
|
194
|
-
'max': undefined,
|
|
195
|
-
},
|
|
196
|
-
'price': {
|
|
197
|
-
'min': undefined,
|
|
198
|
-
'max': undefined,
|
|
199
|
-
},
|
|
200
|
-
'cost': {
|
|
201
|
-
'min': undefined,
|
|
202
|
-
'max': undefined,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
'created': undefined,
|
|
206
|
-
'info': market,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
210
|
-
/**
|
|
211
|
-
* @method
|
|
212
|
-
* @name bitpin#fetchTickers
|
|
213
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
214
|
-
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
215
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
216
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
217
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
218
|
-
*/
|
|
219
|
-
await this.loadMarkets();
|
|
220
|
-
if (symbols !== undefined) {
|
|
221
|
-
symbols = this.marketSymbols(symbols);
|
|
222
|
-
}
|
|
223
|
-
const response = await this.publicGetV1MktMarkets(params);
|
|
224
|
-
const markets = this.safeList(response, 'results');
|
|
225
|
-
const result = {};
|
|
226
|
-
for (let i = 0; i < markets.length; i++) {
|
|
227
|
-
const is_active = this.safeBool(markets[i], 'tradable');
|
|
228
|
-
if (is_active === true) {
|
|
229
|
-
const ticker = this.parseTicker(markets[i]);
|
|
230
|
-
const symbol = ticker['symbol'];
|
|
231
|
-
result[symbol] = ticker;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
235
|
-
}
|
|
236
|
-
async fetchTicker(symbol, params = {}) {
|
|
237
|
-
/**
|
|
238
|
-
* @method
|
|
239
|
-
* @name bitpin#fetchTicker
|
|
240
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
241
|
-
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
242
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
243
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
244
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
245
|
-
*/
|
|
246
|
-
const ticker = await this.fetchTickers([symbol]);
|
|
247
|
-
return ticker[symbol];
|
|
248
|
-
}
|
|
249
|
-
parseTicker(ticker, market = undefined) {
|
|
250
|
-
// {
|
|
251
|
-
// 'id': 1,
|
|
252
|
-
// 'currency1': {
|
|
253
|
-
// 'id': 1,
|
|
254
|
-
// 'title': 'Bitcoin',
|
|
255
|
-
// 'title_fa': 'بیت کوین',
|
|
256
|
-
// 'code': 'BTC',
|
|
257
|
-
// 'tradable': true,
|
|
258
|
-
// 'for_test': false,
|
|
259
|
-
// 'image': 'https://cdn.bitpin.ir/media/market/currency/1697370601.svg',
|
|
260
|
-
// 'decimal': 2,
|
|
261
|
-
// 'decimal_amount': 8,
|
|
262
|
-
// 'decimal_irt': 0,
|
|
263
|
-
// 'color': 'f7931a',
|
|
264
|
-
// 'high_risk': false,
|
|
265
|
-
// 'show_high_risk': false,
|
|
266
|
-
// 'withdraw_commission': '0.003000000000000000',
|
|
267
|
-
// 'tags': [
|
|
268
|
-
// {
|
|
269
|
-
// 'id': 44,
|
|
270
|
-
// 'name': 'لایه ۱',
|
|
271
|
-
// 'name_en': 'layer-1',
|
|
272
|
-
// 'has_chart': true,
|
|
273
|
-
// },
|
|
274
|
-
// {
|
|
275
|
-
// 'id': 52,
|
|
276
|
-
// 'name': 'اثبات کار',
|
|
277
|
-
// 'name_en': 'pow',
|
|
278
|
-
// 'has_chart': true,
|
|
279
|
-
// },
|
|
280
|
-
// ],
|
|
281
|
-
// 'etf': false,
|
|
282
|
-
// 'for_binvest': false,
|
|
283
|
-
// 'for_loan': true,
|
|
284
|
-
// 'for_stake': false,
|
|
285
|
-
// 'recommend_for_deposit_weight': 1,
|
|
286
|
-
// },
|
|
287
|
-
// 'currency2': {
|
|
288
|
-
// 'id': 2,
|
|
289
|
-
// 'title': 'Toman',
|
|
290
|
-
// 'title_fa': 'تومان',
|
|
291
|
-
// 'code': 'IRT',
|
|
292
|
-
// 'tradable': true,
|
|
293
|
-
// 'for_test': false,
|
|
294
|
-
// 'image': 'https://cdn.bitpin.ir/media/market/currency/1684671406.svg',
|
|
295
|
-
// 'decimal': 0,
|
|
296
|
-
// 'decimal_amount': 0,
|
|
297
|
-
// 'decimal_irt': 1,
|
|
298
|
-
// 'color': '00fd22',
|
|
299
|
-
// 'high_risk': false,
|
|
300
|
-
// 'show_high_risk': false,
|
|
301
|
-
// 'withdraw_commission': '0.000200000000000000',
|
|
302
|
-
// 'tags': [ ],
|
|
303
|
-
// 'etf': false,
|
|
304
|
-
// 'for_binvest': false,
|
|
305
|
-
// 'for_loan': false,
|
|
306
|
-
// 'for_stake': false,
|
|
307
|
-
// 'recommend_for_deposit_weight': 0,
|
|
308
|
-
// },
|
|
309
|
-
// 'tradable': true,
|
|
310
|
-
// 'for_test': false,
|
|
311
|
-
// 'otc_sell_percent': '0.01000',
|
|
312
|
-
// 'otc_buy_percent': '0.01000',
|
|
313
|
-
// 'otc_max_buy_amount': '0.017000000000000000',
|
|
314
|
-
// 'otc_max_sell_amount': '0.017000000000000000',
|
|
315
|
-
// 'order_book_info': {
|
|
316
|
-
// 'created_at': null,
|
|
317
|
-
// 'price': '3894924262',
|
|
318
|
-
// 'change': 0.0179,
|
|
319
|
-
// 'min': '3777777800',
|
|
320
|
-
// 'max': '3925000000',
|
|
321
|
-
// 'time': '2024-05-19T13:45:00.000Z',
|
|
322
|
-
// 'mean': '3833950912',
|
|
323
|
-
// 'value': '6215833783',
|
|
324
|
-
// 'amount': '1.62286922',
|
|
325
|
-
// },
|
|
326
|
-
// 'internal_price_info': {
|
|
327
|
-
// 'created_at': 1716126301.298626,
|
|
328
|
-
// 'price': '3894924262',
|
|
329
|
-
// 'change': 1.8,
|
|
330
|
-
// 'min': '3777777800',
|
|
331
|
-
// 'max': '3925000000',
|
|
332
|
-
// 'time': null,
|
|
333
|
-
// 'mean': null,
|
|
334
|
-
// 'value': null,
|
|
335
|
-
// 'amount': null,
|
|
336
|
-
// },
|
|
337
|
-
// 'price_info': {
|
|
338
|
-
// 'created_at': 1716126370.677,
|
|
339
|
-
// 'price': '3906940950',
|
|
340
|
-
// 'change': 2.04,
|
|
341
|
-
// 'min': '3785113135',
|
|
342
|
-
// 'max': '3921003333',
|
|
343
|
-
// 'time': null,
|
|
344
|
-
// 'mean': null,
|
|
345
|
-
// 'value': null,
|
|
346
|
-
// 'amount': null,
|
|
347
|
-
// },
|
|
348
|
-
// 'price': '3906940950',
|
|
349
|
-
// 'title': 'Bitcoin/Toman',
|
|
350
|
-
// 'code': 'BTC_IRT',
|
|
351
|
-
// 'title_fa': 'بیت کوین/تومان',
|
|
352
|
-
// 'trading_view_source': 'BINANCE',
|
|
353
|
-
// 'trading_view_symbol': 'BTCUSDT',
|
|
354
|
-
// 'otc_market': false,
|
|
355
|
-
// 'text': '',
|
|
356
|
-
// 'volume_24h': '2318294704054686.000000000000000000',
|
|
357
|
-
// 'market_cap': '43370130583253964.000000000000000000',
|
|
358
|
-
// 'circulating_supply': '19588837.000000000000000000',
|
|
359
|
-
// 'all_time_high': '3577014315.000000000000000000',
|
|
360
|
-
// 'popularity_weight': 0,
|
|
361
|
-
// 'freshness_weight': 0,
|
|
362
|
-
// }
|
|
363
|
-
const marketType = 'spot';
|
|
364
|
-
const priceInfo = this.safeValue(ticker, 'order_book_info');
|
|
365
|
-
const marketId = this.safeString(ticker, 'id');
|
|
366
|
-
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
367
|
-
const high = this.safeFloat(priceInfo, 'max', 0);
|
|
368
|
-
const low = this.safeFloat(priceInfo, 'min', 0);
|
|
369
|
-
const last = this.safeFloat(priceInfo, 'price', 0);
|
|
370
|
-
const change = this.safeFloat(priceInfo, 'change', 0);
|
|
371
|
-
const baseVolume = this.safeFloat(priceInfo, 'amount', 0);
|
|
372
|
-
const quoteVolume = this.safeFloat(priceInfo, 'value', 0);
|
|
373
|
-
return this.safeTicker({
|
|
374
|
-
'symbol': symbol,
|
|
375
|
-
'timestamp': undefined,
|
|
376
|
-
'datetime': undefined,
|
|
377
|
-
'high': high,
|
|
378
|
-
'low': low,
|
|
379
|
-
'bid': undefined,
|
|
380
|
-
'bidVolume': undefined,
|
|
381
|
-
'ask': undefined,
|
|
382
|
-
'askVolume': undefined,
|
|
383
|
-
'vwap': undefined,
|
|
384
|
-
'open': undefined,
|
|
385
|
-
'close': last,
|
|
386
|
-
'last': last,
|
|
387
|
-
'previousClose': undefined,
|
|
388
|
-
'change': change,
|
|
389
|
-
'percentage': undefined,
|
|
390
|
-
'average': undefined,
|
|
391
|
-
'baseVolume': baseVolume,
|
|
392
|
-
'quoteVolume': quoteVolume,
|
|
393
|
-
'info': ticker,
|
|
394
|
-
}, market);
|
|
395
|
-
}
|
|
396
|
-
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
397
|
-
/**
|
|
398
|
-
* @method
|
|
399
|
-
* @name bitpin#fetchOHLCV
|
|
400
|
-
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
401
|
-
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
402
|
-
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
403
|
-
* @param {string} timeframe the length of time each candle represents
|
|
404
|
-
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
405
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
406
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
407
|
-
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
408
|
-
*/
|
|
409
|
-
await this.loadMarkets();
|
|
410
|
-
const market = this.market(symbol);
|
|
411
|
-
const endTime = Date.now();
|
|
412
|
-
const request = {
|
|
413
|
-
'symbol': market['symbol'].replace('/', '_'),
|
|
414
|
-
'from': (endTime / 1000) - (24 * 60 * 60),
|
|
415
|
-
'to': endTime / 1000,
|
|
416
|
-
'res': this.safeString(this.timeframes, timeframe, timeframe),
|
|
417
|
-
};
|
|
418
|
-
if (since !== undefined) {
|
|
419
|
-
request['from'] = since / 1000;
|
|
420
|
-
}
|
|
421
|
-
request['from'] = this.safeInteger(request, 'from');
|
|
422
|
-
request['to'] = this.safeInteger(request, 'to');
|
|
423
|
-
if (timeframe !== undefined) {
|
|
424
|
-
request['res'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
425
|
-
}
|
|
426
|
-
const response = await this.publicGetV1MktTvGetBars(request);
|
|
427
|
-
const ohlcvs = [];
|
|
428
|
-
for (let i = 0; i < response.length; i++) {
|
|
429
|
-
ohlcvs.push([
|
|
430
|
-
this.safeValue(response[i], 'ts'),
|
|
431
|
-
this.safeFloat(response[i], 'open'),
|
|
432
|
-
this.safeFloat(response[i], 'high'),
|
|
433
|
-
this.safeFloat(response[i], 'low'),
|
|
434
|
-
this.safeFloat(response[i], 'close'),
|
|
435
|
-
this.safeFloat(response[i], 'volume'),
|
|
436
|
-
]);
|
|
437
|
-
}
|
|
438
|
-
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
439
|
-
}
|
|
440
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
441
|
-
/**
|
|
442
|
-
* @method
|
|
443
|
-
* @name bitpin#fetchOrderBooks
|
|
444
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
|
|
445
|
-
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
446
|
-
* @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
|
|
447
|
-
* @param {int} [limit] max number of entries per orderbook to return, default is undefined
|
|
448
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
449
|
-
* @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
|
|
450
|
-
*/
|
|
451
|
-
await this.loadMarkets();
|
|
452
|
-
const market = this.market(symbol);
|
|
453
|
-
const request = {
|
|
454
|
-
'symbol': market['id'],
|
|
455
|
-
'limit': limit || 100,
|
|
456
|
-
};
|
|
457
|
-
const orderBookRequest = await this.publicGetV4MthOrderbook(this.extend(request, params));
|
|
458
|
-
const bids = this.safeList(orderBookRequest, 'bids', []);
|
|
459
|
-
const asks = this.safeList(orderBookRequest, 'asks', []);
|
|
460
|
-
const bidlist = [];
|
|
461
|
-
const askslist = [];
|
|
462
|
-
for (let i = 0; i < bids.length; i++) {
|
|
463
|
-
const bid = bids[i];
|
|
464
|
-
bidlist.push({ 'price': this.safeFloat(bid, 0), 'amount': this.safeFloat(bid, 1) });
|
|
465
|
-
}
|
|
466
|
-
for (let j = 0; j < asks.length; j++) {
|
|
467
|
-
const ask = asks[j];
|
|
468
|
-
askslist.push({ 'price': this.safeFloat(ask, 0), 'amount': this.safeFloat(ask, 1) });
|
|
469
|
-
}
|
|
470
|
-
const orderBook = { 'bid': bidlist, 'ask': askslist };
|
|
471
|
-
const timestamp = Date.now();
|
|
472
|
-
return this.parseOrderBook(orderBook, symbol, timestamp, 'bid', 'ask', 'price', 'amount');
|
|
473
|
-
}
|
|
474
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
475
|
-
const query = this.omit(params, this.extractParams(path));
|
|
476
|
-
let url = this.urls['api'][api] + '/' + path;
|
|
477
|
-
if (path === 'v1/mkt/tv/get_bars/') {
|
|
478
|
-
url = this.urls['api']['OHLCV'] + '/' + path + '?' + this.urlencode(query);
|
|
479
|
-
}
|
|
480
|
-
if (path === 'v4/mth/orderbook/') {
|
|
481
|
-
url = url + params['symbol'] + '/?limit=' + params['limit'];
|
|
482
|
-
}
|
|
483
|
-
headers = { 'Content-Type': 'application/json' };
|
|
484
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
485
|
-
}
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
/**
|
|
10
|
+
* @class bitpin
|
|
11
|
+
* @augments Exchange
|
|
12
|
+
* @description Set rateLimit to 1000 if fully verified
|
|
13
|
+
*/
|
|
14
|
+
class bitpin extends bitpin$1["default"] {
|
|
15
|
+
describe() {
|
|
16
|
+
return this.deepExtend(super.describe(), {
|
|
17
|
+
'id': 'bitpin',
|
|
18
|
+
'name': 'bitpin',
|
|
19
|
+
'countries': ['IR'],
|
|
20
|
+
'rateLimit': 1000,
|
|
21
|
+
'version': '1',
|
|
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
|
+
'addMargin': false,
|
|
32
|
+
'cancelAllOrders': false,
|
|
33
|
+
'cancelOrder': false,
|
|
34
|
+
'cancelOrders': false,
|
|
35
|
+
'createDepositAddress': false,
|
|
36
|
+
'createOrder': false,
|
|
37
|
+
'createStopLimitOrder': false,
|
|
38
|
+
'createStopMarketOrder': false,
|
|
39
|
+
'createStopOrder': false,
|
|
40
|
+
'editOrder': false,
|
|
41
|
+
'fetchBalance': false,
|
|
42
|
+
'fetchBorrowInterest': false,
|
|
43
|
+
'fetchBorrowRateHistories': false,
|
|
44
|
+
'fetchBorrowRateHistory': false,
|
|
45
|
+
'fetchClosedOrders': false,
|
|
46
|
+
'fetchCrossBorrowRate': false,
|
|
47
|
+
'fetchCrossBorrowRates': false,
|
|
48
|
+
'fetchCurrencies': false,
|
|
49
|
+
'fetchDepositAddress': false,
|
|
50
|
+
'fetchDeposits': false,
|
|
51
|
+
'fetchFundingHistory': false,
|
|
52
|
+
'fetchFundingRate': false,
|
|
53
|
+
'fetchFundingRateHistory': false,
|
|
54
|
+
'fetchFundingRates': false,
|
|
55
|
+
'fetchIndexOHLCV': false,
|
|
56
|
+
'fetchIsolatedBorrowRate': false,
|
|
57
|
+
'fetchIsolatedBorrowRates': false,
|
|
58
|
+
'fetchL2OrderBook': false,
|
|
59
|
+
'fetchL3OrderBook': false,
|
|
60
|
+
'fetchLedger': false,
|
|
61
|
+
'fetchLedgerEntry': false,
|
|
62
|
+
'fetchLeverageTiers': false,
|
|
63
|
+
'fetchMarkets': true,
|
|
64
|
+
'fetchMarkOHLCV': false,
|
|
65
|
+
'fetchMyTrades': false,
|
|
66
|
+
'fetchOHLCV': true,
|
|
67
|
+
'fetchOpenInterestHistory': false,
|
|
68
|
+
'fetchOpenOrders': false,
|
|
69
|
+
'fetchOrder': false,
|
|
70
|
+
'fetchOrderBook': true,
|
|
71
|
+
'fetchOrders': false,
|
|
72
|
+
'fetchOrderTrades': 'emulated',
|
|
73
|
+
'fetchPositions': false,
|
|
74
|
+
'fetchPremiumIndexOHLCV': false,
|
|
75
|
+
'fetchTicker': true,
|
|
76
|
+
'fetchTickers': true,
|
|
77
|
+
'fetchTime': false,
|
|
78
|
+
'fetchTrades': false,
|
|
79
|
+
'fetchTradingFee': false,
|
|
80
|
+
'fetchTradingFees': false,
|
|
81
|
+
'fetchWithdrawals': false,
|
|
82
|
+
'setLeverage': false,
|
|
83
|
+
'setMarginMode': false,
|
|
84
|
+
'transfer': false,
|
|
85
|
+
'withdraw': false,
|
|
86
|
+
},
|
|
87
|
+
'comment': 'This comment is optional',
|
|
88
|
+
'urls': {
|
|
89
|
+
'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitpin/64x64.png',
|
|
90
|
+
'api': {
|
|
91
|
+
'public': 'https://api.bitpin.ir',
|
|
92
|
+
'OHLCV': 'https://api.bitpin.org',
|
|
93
|
+
},
|
|
94
|
+
'www': 'https://bitpin.ir',
|
|
95
|
+
'doc': [
|
|
96
|
+
'https://docs.bitpin.ir',
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
'timeframes': {
|
|
100
|
+
'1m': '1',
|
|
101
|
+
'5m': '5',
|
|
102
|
+
'15m': '15',
|
|
103
|
+
'30m': '30',
|
|
104
|
+
'1h': '60',
|
|
105
|
+
'3h': '180',
|
|
106
|
+
'4h': '240',
|
|
107
|
+
'12h': '720',
|
|
108
|
+
'1d': '1D',
|
|
109
|
+
'1w': '1W',
|
|
110
|
+
},
|
|
111
|
+
'api': {
|
|
112
|
+
'public': {
|
|
113
|
+
'get': {
|
|
114
|
+
'v1/mkt/markets/': 1,
|
|
115
|
+
'v2/mth/actives/': 1,
|
|
116
|
+
'v1/mkt/tv/get_bars/': 1,
|
|
117
|
+
'v4/mth/orderbook/': 1,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
'fees': {
|
|
122
|
+
'trading': {
|
|
123
|
+
'tierBased': false,
|
|
124
|
+
'percentage': true,
|
|
125
|
+
'maker': this.parseNumber('0.001'),
|
|
126
|
+
'taker': this.parseNumber('0.001'),
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async fetchMarkets(params = {}) {
|
|
132
|
+
/**
|
|
133
|
+
* @method
|
|
134
|
+
* @name bitpin#fetchMarkets
|
|
135
|
+
* @description retrieves data on all markets for bitpin
|
|
136
|
+
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
137
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
138
|
+
* @returns {object[]} an array of objects representing market data
|
|
139
|
+
*/
|
|
140
|
+
const response = await this.publicGetV1MktMarkets(params);
|
|
141
|
+
const markets = this.safeList(response, 'results');
|
|
142
|
+
const result = [];
|
|
143
|
+
for (let i = 0; i < markets.length; i++) {
|
|
144
|
+
const market = this.parseMarket(markets[i]);
|
|
145
|
+
result.push(market);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
parseMarket(market) {
|
|
150
|
+
const id = this.safeString(market, 'id');
|
|
151
|
+
const baseCurrency = this.safeDict(market, 'currency1');
|
|
152
|
+
const quoteCurrency = this.safeDict(market, 'currency2');
|
|
153
|
+
let baseId = this.safeString(baseCurrency, 'code');
|
|
154
|
+
let quoteId = this.safeString(quoteCurrency, 'code');
|
|
155
|
+
const base = this.safeCurrencyCode(baseId);
|
|
156
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
157
|
+
baseId = baseId.toLowerCase();
|
|
158
|
+
quoteId = quoteId.toLowerCase();
|
|
159
|
+
return {
|
|
160
|
+
'id': id,
|
|
161
|
+
'symbol': base + '/' + quote,
|
|
162
|
+
'base': base,
|
|
163
|
+
'quote': quote,
|
|
164
|
+
'settle': undefined,
|
|
165
|
+
'baseId': baseId,
|
|
166
|
+
'quoteId': quoteId,
|
|
167
|
+
'settleId': undefined,
|
|
168
|
+
'type': 'spot',
|
|
169
|
+
'spot': true,
|
|
170
|
+
'margin': false,
|
|
171
|
+
'swap': false,
|
|
172
|
+
'future': false,
|
|
173
|
+
'option': false,
|
|
174
|
+
'active': true,
|
|
175
|
+
'contract': false,
|
|
176
|
+
'linear': undefined,
|
|
177
|
+
'inverse': undefined,
|
|
178
|
+
'contractSize': undefined,
|
|
179
|
+
'expiry': undefined,
|
|
180
|
+
'expiryDatetime': undefined,
|
|
181
|
+
'strike': undefined,
|
|
182
|
+
'optionType': undefined,
|
|
183
|
+
'precision': {
|
|
184
|
+
'amount': undefined,
|
|
185
|
+
'price': undefined,
|
|
186
|
+
},
|
|
187
|
+
'limits': {
|
|
188
|
+
'leverage': {
|
|
189
|
+
'min': undefined,
|
|
190
|
+
'max': undefined,
|
|
191
|
+
},
|
|
192
|
+
'amount': {
|
|
193
|
+
'min': undefined,
|
|
194
|
+
'max': undefined,
|
|
195
|
+
},
|
|
196
|
+
'price': {
|
|
197
|
+
'min': undefined,
|
|
198
|
+
'max': undefined,
|
|
199
|
+
},
|
|
200
|
+
'cost': {
|
|
201
|
+
'min': undefined,
|
|
202
|
+
'max': undefined,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
'created': undefined,
|
|
206
|
+
'info': market,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
210
|
+
/**
|
|
211
|
+
* @method
|
|
212
|
+
* @name bitpin#fetchTickers
|
|
213
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
214
|
+
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
215
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
216
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
217
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
218
|
+
*/
|
|
219
|
+
await this.loadMarkets();
|
|
220
|
+
if (symbols !== undefined) {
|
|
221
|
+
symbols = this.marketSymbols(symbols);
|
|
222
|
+
}
|
|
223
|
+
const response = await this.publicGetV1MktMarkets(params);
|
|
224
|
+
const markets = this.safeList(response, 'results');
|
|
225
|
+
const result = {};
|
|
226
|
+
for (let i = 0; i < markets.length; i++) {
|
|
227
|
+
const is_active = this.safeBool(markets[i], 'tradable');
|
|
228
|
+
if (is_active === true) {
|
|
229
|
+
const ticker = this.parseTicker(markets[i]);
|
|
230
|
+
const symbol = ticker['symbol'];
|
|
231
|
+
result[symbol] = ticker;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
235
|
+
}
|
|
236
|
+
async fetchTicker(symbol, params = {}) {
|
|
237
|
+
/**
|
|
238
|
+
* @method
|
|
239
|
+
* @name bitpin#fetchTicker
|
|
240
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
241
|
+
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
242
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
243
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
244
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
245
|
+
*/
|
|
246
|
+
const ticker = await this.fetchTickers([symbol]);
|
|
247
|
+
return ticker[symbol];
|
|
248
|
+
}
|
|
249
|
+
parseTicker(ticker, market = undefined) {
|
|
250
|
+
// {
|
|
251
|
+
// 'id': 1,
|
|
252
|
+
// 'currency1': {
|
|
253
|
+
// 'id': 1,
|
|
254
|
+
// 'title': 'Bitcoin',
|
|
255
|
+
// 'title_fa': 'بیت کوین',
|
|
256
|
+
// 'code': 'BTC',
|
|
257
|
+
// 'tradable': true,
|
|
258
|
+
// 'for_test': false,
|
|
259
|
+
// 'image': 'https://cdn.bitpin.ir/media/market/currency/1697370601.svg',
|
|
260
|
+
// 'decimal': 2,
|
|
261
|
+
// 'decimal_amount': 8,
|
|
262
|
+
// 'decimal_irt': 0,
|
|
263
|
+
// 'color': 'f7931a',
|
|
264
|
+
// 'high_risk': false,
|
|
265
|
+
// 'show_high_risk': false,
|
|
266
|
+
// 'withdraw_commission': '0.003000000000000000',
|
|
267
|
+
// 'tags': [
|
|
268
|
+
// {
|
|
269
|
+
// 'id': 44,
|
|
270
|
+
// 'name': 'لایه ۱',
|
|
271
|
+
// 'name_en': 'layer-1',
|
|
272
|
+
// 'has_chart': true,
|
|
273
|
+
// },
|
|
274
|
+
// {
|
|
275
|
+
// 'id': 52,
|
|
276
|
+
// 'name': 'اثبات کار',
|
|
277
|
+
// 'name_en': 'pow',
|
|
278
|
+
// 'has_chart': true,
|
|
279
|
+
// },
|
|
280
|
+
// ],
|
|
281
|
+
// 'etf': false,
|
|
282
|
+
// 'for_binvest': false,
|
|
283
|
+
// 'for_loan': true,
|
|
284
|
+
// 'for_stake': false,
|
|
285
|
+
// 'recommend_for_deposit_weight': 1,
|
|
286
|
+
// },
|
|
287
|
+
// 'currency2': {
|
|
288
|
+
// 'id': 2,
|
|
289
|
+
// 'title': 'Toman',
|
|
290
|
+
// 'title_fa': 'تومان',
|
|
291
|
+
// 'code': 'IRT',
|
|
292
|
+
// 'tradable': true,
|
|
293
|
+
// 'for_test': false,
|
|
294
|
+
// 'image': 'https://cdn.bitpin.ir/media/market/currency/1684671406.svg',
|
|
295
|
+
// 'decimal': 0,
|
|
296
|
+
// 'decimal_amount': 0,
|
|
297
|
+
// 'decimal_irt': 1,
|
|
298
|
+
// 'color': '00fd22',
|
|
299
|
+
// 'high_risk': false,
|
|
300
|
+
// 'show_high_risk': false,
|
|
301
|
+
// 'withdraw_commission': '0.000200000000000000',
|
|
302
|
+
// 'tags': [ ],
|
|
303
|
+
// 'etf': false,
|
|
304
|
+
// 'for_binvest': false,
|
|
305
|
+
// 'for_loan': false,
|
|
306
|
+
// 'for_stake': false,
|
|
307
|
+
// 'recommend_for_deposit_weight': 0,
|
|
308
|
+
// },
|
|
309
|
+
// 'tradable': true,
|
|
310
|
+
// 'for_test': false,
|
|
311
|
+
// 'otc_sell_percent': '0.01000',
|
|
312
|
+
// 'otc_buy_percent': '0.01000',
|
|
313
|
+
// 'otc_max_buy_amount': '0.017000000000000000',
|
|
314
|
+
// 'otc_max_sell_amount': '0.017000000000000000',
|
|
315
|
+
// 'order_book_info': {
|
|
316
|
+
// 'created_at': null,
|
|
317
|
+
// 'price': '3894924262',
|
|
318
|
+
// 'change': 0.0179,
|
|
319
|
+
// 'min': '3777777800',
|
|
320
|
+
// 'max': '3925000000',
|
|
321
|
+
// 'time': '2024-05-19T13:45:00.000Z',
|
|
322
|
+
// 'mean': '3833950912',
|
|
323
|
+
// 'value': '6215833783',
|
|
324
|
+
// 'amount': '1.62286922',
|
|
325
|
+
// },
|
|
326
|
+
// 'internal_price_info': {
|
|
327
|
+
// 'created_at': 1716126301.298626,
|
|
328
|
+
// 'price': '3894924262',
|
|
329
|
+
// 'change': 1.8,
|
|
330
|
+
// 'min': '3777777800',
|
|
331
|
+
// 'max': '3925000000',
|
|
332
|
+
// 'time': null,
|
|
333
|
+
// 'mean': null,
|
|
334
|
+
// 'value': null,
|
|
335
|
+
// 'amount': null,
|
|
336
|
+
// },
|
|
337
|
+
// 'price_info': {
|
|
338
|
+
// 'created_at': 1716126370.677,
|
|
339
|
+
// 'price': '3906940950',
|
|
340
|
+
// 'change': 2.04,
|
|
341
|
+
// 'min': '3785113135',
|
|
342
|
+
// 'max': '3921003333',
|
|
343
|
+
// 'time': null,
|
|
344
|
+
// 'mean': null,
|
|
345
|
+
// 'value': null,
|
|
346
|
+
// 'amount': null,
|
|
347
|
+
// },
|
|
348
|
+
// 'price': '3906940950',
|
|
349
|
+
// 'title': 'Bitcoin/Toman',
|
|
350
|
+
// 'code': 'BTC_IRT',
|
|
351
|
+
// 'title_fa': 'بیت کوین/تومان',
|
|
352
|
+
// 'trading_view_source': 'BINANCE',
|
|
353
|
+
// 'trading_view_symbol': 'BTCUSDT',
|
|
354
|
+
// 'otc_market': false,
|
|
355
|
+
// 'text': '',
|
|
356
|
+
// 'volume_24h': '2318294704054686.000000000000000000',
|
|
357
|
+
// 'market_cap': '43370130583253964.000000000000000000',
|
|
358
|
+
// 'circulating_supply': '19588837.000000000000000000',
|
|
359
|
+
// 'all_time_high': '3577014315.000000000000000000',
|
|
360
|
+
// 'popularity_weight': 0,
|
|
361
|
+
// 'freshness_weight': 0,
|
|
362
|
+
// }
|
|
363
|
+
const marketType = 'spot';
|
|
364
|
+
const priceInfo = this.safeValue(ticker, 'order_book_info');
|
|
365
|
+
const marketId = this.safeString(ticker, 'id');
|
|
366
|
+
const symbol = this.safeSymbol(marketId, market, undefined, marketType);
|
|
367
|
+
const high = this.safeFloat(priceInfo, 'max', 0);
|
|
368
|
+
const low = this.safeFloat(priceInfo, 'min', 0);
|
|
369
|
+
const last = this.safeFloat(priceInfo, 'price', 0);
|
|
370
|
+
const change = this.safeFloat(priceInfo, 'change', 0);
|
|
371
|
+
const baseVolume = this.safeFloat(priceInfo, 'amount', 0);
|
|
372
|
+
const quoteVolume = this.safeFloat(priceInfo, 'value', 0);
|
|
373
|
+
return this.safeTicker({
|
|
374
|
+
'symbol': symbol,
|
|
375
|
+
'timestamp': undefined,
|
|
376
|
+
'datetime': undefined,
|
|
377
|
+
'high': high,
|
|
378
|
+
'low': low,
|
|
379
|
+
'bid': undefined,
|
|
380
|
+
'bidVolume': undefined,
|
|
381
|
+
'ask': undefined,
|
|
382
|
+
'askVolume': undefined,
|
|
383
|
+
'vwap': undefined,
|
|
384
|
+
'open': undefined,
|
|
385
|
+
'close': last,
|
|
386
|
+
'last': last,
|
|
387
|
+
'previousClose': undefined,
|
|
388
|
+
'change': change,
|
|
389
|
+
'percentage': undefined,
|
|
390
|
+
'average': undefined,
|
|
391
|
+
'baseVolume': baseVolume,
|
|
392
|
+
'quoteVolume': quoteVolume,
|
|
393
|
+
'info': ticker,
|
|
394
|
+
}, market);
|
|
395
|
+
}
|
|
396
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
397
|
+
/**
|
|
398
|
+
* @method
|
|
399
|
+
* @name bitpin#fetchOHLCV
|
|
400
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
401
|
+
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
402
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
403
|
+
* @param {string} timeframe the length of time each candle represents
|
|
404
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
405
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
406
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
407
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
408
|
+
*/
|
|
409
|
+
await this.loadMarkets();
|
|
410
|
+
const market = this.market(symbol);
|
|
411
|
+
const endTime = Date.now();
|
|
412
|
+
const request = {
|
|
413
|
+
'symbol': market['symbol'].replace('/', '_'),
|
|
414
|
+
'from': (endTime / 1000) - (24 * 60 * 60),
|
|
415
|
+
'to': endTime / 1000,
|
|
416
|
+
'res': this.safeString(this.timeframes, timeframe, timeframe),
|
|
417
|
+
};
|
|
418
|
+
if (since !== undefined) {
|
|
419
|
+
request['from'] = since / 1000;
|
|
420
|
+
}
|
|
421
|
+
request['from'] = this.safeInteger(request, 'from');
|
|
422
|
+
request['to'] = this.safeInteger(request, 'to');
|
|
423
|
+
if (timeframe !== undefined) {
|
|
424
|
+
request['res'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
425
|
+
}
|
|
426
|
+
const response = await this.publicGetV1MktTvGetBars(request);
|
|
427
|
+
const ohlcvs = [];
|
|
428
|
+
for (let i = 0; i < response.length; i++) {
|
|
429
|
+
ohlcvs.push([
|
|
430
|
+
this.safeValue(response[i], 'ts'),
|
|
431
|
+
this.safeFloat(response[i], 'open'),
|
|
432
|
+
this.safeFloat(response[i], 'high'),
|
|
433
|
+
this.safeFloat(response[i], 'low'),
|
|
434
|
+
this.safeFloat(response[i], 'close'),
|
|
435
|
+
this.safeFloat(response[i], 'volume'),
|
|
436
|
+
]);
|
|
437
|
+
}
|
|
438
|
+
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
439
|
+
}
|
|
440
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
441
|
+
/**
|
|
442
|
+
* @method
|
|
443
|
+
* @name bitpin#fetchOrderBooks
|
|
444
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
|
|
445
|
+
* @see https://api-docs.bitpin.ir/#be8d9c51a2
|
|
446
|
+
* @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
|
|
447
|
+
* @param {int} [limit] max number of entries per orderbook to return, default is undefined
|
|
448
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
449
|
+
* @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
|
|
450
|
+
*/
|
|
451
|
+
await this.loadMarkets();
|
|
452
|
+
const market = this.market(symbol);
|
|
453
|
+
const request = {
|
|
454
|
+
'symbol': market['id'],
|
|
455
|
+
'limit': limit || 100,
|
|
456
|
+
};
|
|
457
|
+
const orderBookRequest = await this.publicGetV4MthOrderbook(this.extend(request, params));
|
|
458
|
+
const bids = this.safeList(orderBookRequest, 'bids', []);
|
|
459
|
+
const asks = this.safeList(orderBookRequest, 'asks', []);
|
|
460
|
+
const bidlist = [];
|
|
461
|
+
const askslist = [];
|
|
462
|
+
for (let i = 0; i < bids.length; i++) {
|
|
463
|
+
const bid = bids[i];
|
|
464
|
+
bidlist.push({ 'price': this.safeFloat(bid, 0), 'amount': this.safeFloat(bid, 1) });
|
|
465
|
+
}
|
|
466
|
+
for (let j = 0; j < asks.length; j++) {
|
|
467
|
+
const ask = asks[j];
|
|
468
|
+
askslist.push({ 'price': this.safeFloat(ask, 0), 'amount': this.safeFloat(ask, 1) });
|
|
469
|
+
}
|
|
470
|
+
const orderBook = { 'bid': bidlist, 'ask': askslist };
|
|
471
|
+
const timestamp = Date.now();
|
|
472
|
+
return this.parseOrderBook(orderBook, symbol, timestamp, 'bid', 'ask', 'price', 'amount');
|
|
473
|
+
}
|
|
474
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
475
|
+
const query = this.omit(params, this.extractParams(path));
|
|
476
|
+
let url = this.urls['api'][api] + '/' + path;
|
|
477
|
+
if (path === 'v1/mkt/tv/get_bars/') {
|
|
478
|
+
url = this.urls['api']['OHLCV'] + '/' + path + '?' + this.urlencode(query);
|
|
479
|
+
}
|
|
480
|
+
if (path === 'v4/mth/orderbook/') {
|
|
481
|
+
url = url + params['symbol'] + '/?limit=' + params['limit'];
|
|
482
|
+
}
|
|
483
|
+
headers = { 'Content-Type': 'application/json' };
|
|
484
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
485
|
+
}
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
exports["default"] = bitpin;
|