ccxt-ir 4.8.2 → 4.9.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.
@@ -0,0 +1,326 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/bitunix.js';
9
+ // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class bitunix
12
+ * @augments Exchange
13
+ * @description Set rateLimit to 1000 if fully verified
14
+ */
15
+ export default class bitunix extends Exchange {
16
+ describe() {
17
+ return this.deepExtend(super.describe(), {
18
+ 'id': 'bitunix',
19
+ 'name': 'bitunix',
20
+ 'countries': ['IR'],
21
+ 'rateLimit': 1000,
22
+ 'version': '1',
23
+ 'certified': false,
24
+ 'pro': false,
25
+ 'has': {
26
+ 'CORS': undefined,
27
+ 'spot': true,
28
+ 'margin': false,
29
+ 'swap': false,
30
+ 'future': true,
31
+ 'option': false,
32
+ 'addMargin': false,
33
+ 'cancelAllOrders': false,
34
+ 'cancelOrder': false,
35
+ 'cancelOrders': false,
36
+ 'createDepositAddress': false,
37
+ 'createOrder': false,
38
+ 'createStopLimitOrder': false,
39
+ 'createStopMarketOrder': false,
40
+ 'createStopOrder': false,
41
+ 'editOrder': false,
42
+ 'fetchBalance': false,
43
+ 'fetchBorrowInterest': false,
44
+ 'fetchBorrowRateHistories': false,
45
+ 'fetchBorrowRateHistory': false,
46
+ 'fetchClosedOrders': false,
47
+ 'fetchCrossBorrowRate': false,
48
+ 'fetchCrossBorrowRates': false,
49
+ 'fetchCurrencies': false,
50
+ 'fetchDepositAddress': false,
51
+ 'fetchDeposits': false,
52
+ 'fetchFundingHistory': false,
53
+ 'fetchFundingRate': false,
54
+ 'fetchFundingRateHistory': false,
55
+ 'fetchFundingRates': false,
56
+ 'fetchIndexOHLCV': false,
57
+ 'fetchIsolatedBorrowRate': false,
58
+ 'fetchIsolatedBorrowRates': false,
59
+ 'fetchL2OrderBook': false,
60
+ 'fetchL3OrderBook': false,
61
+ 'fetchLedger': false,
62
+ 'fetchLedgerEntry': false,
63
+ 'fetchLeverageTiers': false,
64
+ 'fetchMarkets': true,
65
+ 'fetchMarkOHLCV': false,
66
+ 'fetchMyTrades': false,
67
+ 'fetchOHLCV': true,
68
+ 'fetchOpenInterestHistory': false,
69
+ 'fetchOpenOrders': false,
70
+ 'fetchOrder': false,
71
+ 'fetchOrderBook': true,
72
+ 'fetchOrders': false,
73
+ 'fetchOrderTrades': 'emulated',
74
+ 'fetchPositions': false,
75
+ 'fetchPremiumIndexOHLCV': false,
76
+ 'fetchTicker': true,
77
+ 'fetchTickers': true,
78
+ 'fetchTime': false,
79
+ 'fetchTrades': false,
80
+ 'fetchTradingFee': false,
81
+ 'fetchTradingFees': false,
82
+ 'fetchWithdrawals': false,
83
+ 'setLeverage': false,
84
+ 'setMarginMode': false,
85
+ 'transfer': false,
86
+ 'withdraw': false,
87
+ },
88
+ 'comment': 'This comment is optional',
89
+ 'urls': {
90
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitunix/64x64.png',
91
+ 'api': {
92
+ 'market': 'https://openapi.bitunix.com/',
93
+ 'tickers': 'https://api.bitunix.com/',
94
+ },
95
+ 'www': 'https://www.bitunix.com/',
96
+ 'doc': [
97
+ 'https://openapidoc.bitunix.com/',
98
+ ],
99
+ },
100
+ 'timeframes': {
101
+ '1m': '1',
102
+ '5m': '5',
103
+ '15m': '15',
104
+ '30m': '30',
105
+ '1h': '60',
106
+ '3h': '180',
107
+ '4h': '240',
108
+ '12h': '720',
109
+ '1d': '1D',
110
+ '1w': '1W',
111
+ },
112
+ 'api': {
113
+ 'public': {
114
+ 'get': {
115
+ 'api/spot/v1/common/coin_pair/list/': 1,
116
+ 'web/api/v1/common/tickers/': 1,
117
+ },
118
+ },
119
+ },
120
+ 'fees': {
121
+ 'trading': {
122
+ 'tierBased': false,
123
+ 'percentage': true,
124
+ 'maker': this.parseNumber('0.001'),
125
+ 'taker': this.parseNumber('0.001'),
126
+ },
127
+ },
128
+ });
129
+ }
130
+ async fetchMarkets(params = {}) {
131
+ /**
132
+ * @method
133
+ * @name bitunix#fetchMarkets
134
+ * @description retrieves data on all markets for bitunix
135
+ * @see https://api-docs.bitunix.ir/#be8d9c51a2
136
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
137
+ * @returns {object[]} an array of objects representing market data
138
+ */
139
+ const response = await this.publicGetApiSpotV1CommonCoinPairList(params);
140
+ const markets = this.safeList(response, 'data');
141
+ const result = [];
142
+ for (let i = 0; i < markets.length; i++) {
143
+ const market = this.parseMarket(markets[i]);
144
+ result.push(market);
145
+ }
146
+ return result;
147
+ }
148
+ parseMarket(market) {
149
+ // {
150
+ // id: 1,
151
+ // symbol: "btcusdt",
152
+ // base: "BTC",
153
+ // baseIcon: "https://img.bitunix.com/config/kv/228408.png",
154
+ // quote: "USDT",
155
+ // quoteIcon: "https://img.bitunix.com/config/coin/USDT.png",
156
+ // basePrecision: 5,
157
+ // quotePrecision: 2,
158
+ // minPrice: "10.0000000000000000",
159
+ // minVolume: "0.0000500000000000",
160
+ // maxAmount: "500000.0000000000000000",
161
+ // minAmount: "0.0000000000000000",
162
+ // maxLimitOrderAmount: "1500000.0000000000000000",
163
+ // maxMarketOrderAmount: "2000000.0000000000000000",
164
+ // maxSlippage: "0.0500",
165
+ // premiumFactor: "0.0500",
166
+ // minBuyPriceOffset: "-0.8000",
167
+ // maxSellPriceOffset: "50.0000",
168
+ // isOpen: 1,
169
+ // isHot: 1,
170
+ // isRecommend: 1,
171
+ // isShow: 1,
172
+ // tradeArea: "USDT",
173
+ // sort: 1,
174
+ // openTime: null,
175
+ // ctime: "2023-05-12T18:03:08Z",
176
+ // precisions: [
177
+ // "0.0100000000000000",
178
+ // "0.1000000000000000",
179
+ // "1.0000000000000000",
180
+ // "10.0000000000000000",
181
+ // "100.0000000000000000"
182
+ // ]
183
+ // }
184
+ const baseId = this.safeString(market, 'base');
185
+ const quoteId = this.safeString(market, 'quote');
186
+ const base = this.safeCurrencyCode(baseId);
187
+ const quote = this.safeCurrencyCode(quoteId);
188
+ const id = (base + quote);
189
+ return {
190
+ 'id': id,
191
+ 'symbol': base + '/' + quote,
192
+ 'base': base,
193
+ 'quote': quote,
194
+ 'settle': undefined,
195
+ 'baseId': baseId,
196
+ 'quoteId': quoteId,
197
+ 'settleId': undefined,
198
+ 'type': 'spot',
199
+ 'spot': true,
200
+ 'margin': false,
201
+ 'swap': false,
202
+ 'future': false,
203
+ 'option': false,
204
+ 'active': true,
205
+ 'contract': false,
206
+ 'linear': undefined,
207
+ 'inverse': undefined,
208
+ 'contractSize': undefined,
209
+ 'expiry': undefined,
210
+ 'expiryDatetime': undefined,
211
+ 'strike': undefined,
212
+ 'optionType': undefined,
213
+ 'precision': {
214
+ 'amount': undefined,
215
+ 'price': undefined,
216
+ },
217
+ 'limits': {
218
+ 'leverage': {
219
+ 'min': undefined,
220
+ 'max': undefined,
221
+ },
222
+ 'amount': {
223
+ 'min': undefined,
224
+ 'max': undefined,
225
+ },
226
+ 'price': {
227
+ 'min': undefined,
228
+ 'max': undefined,
229
+ },
230
+ 'cost': {
231
+ 'min': undefined,
232
+ 'max': undefined,
233
+ },
234
+ },
235
+ 'created': undefined,
236
+ 'info': market,
237
+ };
238
+ }
239
+ async fetchTickers(symbols = undefined, params = {}) {
240
+ /**
241
+ * @method
242
+ * @name bitunix#fetchTickers
243
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
244
+ * @see https://api-docs.bitunix.ir/#be8d9c51a2
245
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
246
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
247
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
248
+ */
249
+ await this.loadMarkets();
250
+ if (symbols !== undefined) {
251
+ symbols = this.marketSymbols(symbols);
252
+ }
253
+ const response = await this.publicGetWebApiV1CommonTickers();
254
+ const markets = this.safeList(response, 'data');
255
+ const result = {};
256
+ for (let i = 0; i < markets.length; i++) {
257
+ const ticker = this.parseTicker(markets[i]);
258
+ const symbol = ticker['symbol'];
259
+ result[symbol] = ticker;
260
+ }
261
+ return this.filterByArrayTickers(result, 'symbol', symbols);
262
+ }
263
+ async fetchTicker(symbol, params = {}) {
264
+ /**
265
+ * @method
266
+ * @name bitunix#fetchTicker
267
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
268
+ * @see https://api-docs.bitunix.ir/#be8d9c51a2
269
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
270
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
271
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
272
+ */
273
+ const ticker = await this.fetchTickers([symbol]);
274
+ return ticker[symbol];
275
+ }
276
+ parseTicker(ticker, market = undefined) {
277
+ // {
278
+ // symbol: "BTCUSDT",
279
+ // base: "BTC",
280
+ // quote: "USDT",
281
+ // close: "112832.34",
282
+ // rose24h: "0.2276416293",
283
+ // volume: "228310106.7861019"
284
+ // },
285
+ const marketType = 'spot';
286
+ const marketId = this.safeString(ticker, 'symbol');
287
+ const symbol = this.safeSymbol(marketId, market, undefined, marketType);
288
+ const last = this.safeFloat(ticker, 'close', 0);
289
+ const change = this.safeFloat(ticker, 'rose24h', 0);
290
+ const quoteVolume = this.safeFloat(ticker, 'volume', 0);
291
+ let baseVolume = 0;
292
+ if (last !== 0) {
293
+ baseVolume = quoteVolume / last;
294
+ }
295
+ return this.safeTicker({
296
+ 'symbol': symbol,
297
+ 'timestamp': undefined,
298
+ 'datetime': undefined,
299
+ 'high': undefined,
300
+ 'low': undefined,
301
+ 'bid': undefined,
302
+ 'bidVolume': undefined,
303
+ 'ask': undefined,
304
+ 'askVolume': undefined,
305
+ 'vwap': undefined,
306
+ 'open': undefined,
307
+ 'close': last,
308
+ 'last': last,
309
+ 'previousClose': undefined,
310
+ 'change': change,
311
+ 'percentage': change,
312
+ 'average': undefined,
313
+ 'baseVolume': baseVolume,
314
+ 'quoteVolume': quoteVolume,
315
+ 'info': ticker,
316
+ }, market);
317
+ }
318
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
319
+ let url = this.urls['api']['market'] + '/' + path;
320
+ if (path === 'web/api/v1/common/tickers/') {
321
+ url = this.urls['api']['tickers'] + '/' + path;
322
+ }
323
+ headers = { 'Content-Type': 'application/json' };
324
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
325
+ }
326
+ }
@@ -311,7 +311,7 @@ export default class coinbaseexchange extends Exchange {
311
311
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
312
312
  */
313
313
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
314
- parseTransactionStatus(transaction: any): "canceled" | "pending" | "ok" | "failed";
314
+ parseTransactionStatus(transaction: any): "canceled" | "pending" | "failed" | "ok";
315
315
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
316
316
  /**
317
317
  * @method
@@ -1,8 +1,2 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  export = $root;
8
2
  declare var $root: {};
@@ -5,7 +5,7 @@ export function deflate(data: any, opts: any, cb: any): () => void;
5
5
  * @param opts The compression options
6
6
  * @returns The deflated version of the data
7
7
  */
8
- export function deflateSync(data: any, opts: any): Uint8Array | Uint16Array | Uint32Array;
8
+ export function deflateSync(data: any, opts: any): Uint8Array | Uint32Array | Uint16Array;
9
9
  export function inflate(data: any, opts: any, cb: any): () => void;
10
10
  /**
11
11
  * Expands DEFLATE data with no wrapper
@@ -21,7 +21,7 @@ export function gzip(data: any, opts: any, cb: any): () => void;
21
21
  * @param opts The compression options
22
22
  * @returns The gzipped version of the data
23
23
  */
24
- export function gzipSync(data: any, opts: any): Uint8Array | Uint16Array | Uint32Array;
24
+ export function gzipSync(data: any, opts: any): Uint8Array | Uint32Array | Uint16Array;
25
25
  export function gunzip(data: any, opts: any, cb: any): () => void;
26
26
  /**
27
27
  * Expands GZIP data
@@ -37,7 +37,7 @@ export function zlib(data: any, opts: any, cb: any): () => void;
37
37
  * @param opts The compression options
38
38
  * @returns The zlib-compressed version of the data
39
39
  */
40
- export function zlibSync(data: any, opts: any): Uint8Array | Uint16Array | Uint32Array;
40
+ export function zlibSync(data: any, opts: any): Uint8Array | Uint32Array | Uint16Array;
41
41
  export function unzlib(data: any, opts: any, cb: any): () => void;
42
42
  /**
43
43
  * Expands Zlib data
@@ -61,7 +61,7 @@ export function decompressSync(data: any, out: any): any;
61
61
  * not need to be true unless decoding a binary string.
62
62
  * @returns The string encoded in UTF-8/Latin-1 binary
63
63
  */
64
- export function strToU8(str: any, latin1: any): Uint8Array | Uint16Array | Uint32Array;
64
+ export function strToU8(str: any, latin1: any): Uint8Array | Uint32Array | Uint16Array;
65
65
  /**
66
66
  * Converts a Uint8Array to a string
67
67
  * @param dat The data to decode to string
@@ -69,7 +69,7 @@ export function strToU8(str: any, latin1: any): Uint8Array | Uint16Array | Uint3
69
69
  * not need to be true unless encoding to binary string.
70
70
  * @returns The original UTF-8/Latin-1 string
71
71
  */
72
- export function strFromU8(dat: any, latin1: any): string | Uint8Array | Uint16Array | Uint32Array;
72
+ export function strFromU8(dat: any, latin1: any): string | Uint8Array | Uint32Array | Uint16Array;
73
73
  export function zip(data: any, opts: any, cb: any): () => void;
74
74
  /**
75
75
  * Synchronously creates a ZIP file. Prefer using `zip` for better performance
@@ -12,7 +12,7 @@ export declare class Stream {
12
12
  parseStringUTF(start: number, end: number): string;
13
13
  parseStringBMP(start: number, end: number): string;
14
14
  parseTime(start: number, end: number, shortYear: boolean): string;
15
- parseInteger(start: number, end: number): string | 0 | -1;
15
+ parseInteger(start: number, end: number): string | -1 | 0;
16
16
  parseBitString(start: number, end: number, maxLength: number): string;
17
17
  parseOctetString(start: number, end: number, maxLength: number): string;
18
18
  parseOID(start: number, end: number, maxLength: number): string;
@@ -25,7 +25,7 @@ export declare class ASN1 {
25
25
  private tag;
26
26
  sub: ASN1[];
27
27
  typeName(): string;
28
- content(maxLength: number): string | 0 | -1;
28
+ content(maxLength: number): string | -1 | 0;
29
29
  toString(): string;
30
30
  toPrettyString(indent: string): string;
31
31
  posStart(): number;
@@ -15,7 +15,7 @@ export declare class BigInteger {
15
15
  protected intValue(): number;
16
16
  protected byteValue(): number;
17
17
  protected shortValue(): number;
18
- protected signum(): 0 | 1 | -1;
18
+ protected signum(): 1 | -1 | 0;
19
19
  toByteArray(): number[];
20
20
  protected equals(a: BigInteger): boolean;
21
21
  protected min(a: BigInteger): BigInteger;
@@ -1,9 +1,3 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  declare const _default: string;
8
2
  export declare namespace formatters {
9
3
  function RFC1738(value: any): string;
@@ -1,9 +1,3 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  import formats = require("./formats.cjs");
8
2
  import parse = require("./parse.cjs");
9
3
  import stringify = require("./stringify.cjs");
@@ -1,8 +1,2 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  declare function _exports(str: any, opts: any): any;
8
2
  export = _exports;
@@ -1,8 +1,2 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  declare function _exports(object: any, opts: any): string;
8
2
  export = _exports;
@@ -1,9 +1,3 @@
1
- // ----------------------------------------------------------------------------
2
-
3
- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
- // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
- // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
-
7
1
  export function arrayToObject(source: any, options: any): any;
8
2
  export function assign(target: any, source: any): any;
9
3
  export function combine(a: any, b: any): any[];
@@ -1,5 +1,5 @@
1
1
  import { Abi, FunctionAbi, RawArgs } from '../../../types/index.js';
2
2
  import { AbiParserInterface } from './interface.js';
3
3
  export declare function createAbiParser(abi: Abi): AbiParserInterface;
4
- export declare function getAbiVersion(abi: Abi): 0 | 1 | 2;
4
+ export declare function getAbiVersion(abi: Abi): 1 | 0 | 2;
5
5
  export declare function isNoConstructorValid(method: string, argsCalldata: RawArgs, abiMethod?: FunctionAbi): boolean;
package/js/src/xt.js CHANGED
@@ -1635,7 +1635,7 @@ export default class xt extends Exchange {
1635
1635
  response = await this.publicInverseGetFutureMarketV1PublicQAggTicker(this.extend(request, params));
1636
1636
  }
1637
1637
  else {
1638
- response = await this.publicSpotGetTicker24h(this.extend(request, params));
1638
+ response = await this.publicSpotGetTicker(this.extend(request, params));
1639
1639
  }
1640
1640
  //
1641
1641
  // spot
@@ -1898,7 +1898,7 @@ export default class xt extends Exchange {
1898
1898
  'change': this.safeNumber(ticker, 'cv'),
1899
1899
  'percentage': this.parseNumber(percentage),
1900
1900
  'average': undefined,
1901
- 'baseVolume': undefined,
1901
+ 'baseVolume': this.safeNumber2(ticker, 'a', 'q'),
1902
1902
  'quoteVolume': this.safeNumber2(ticker, 'a', 'v'),
1903
1903
  'info': ticker,
1904
1904
  }, market);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt-ir",
3
- "version": "4.8.2",
3
+ "version": "4.9.0",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",