ccxt-ir 4.14.4 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/talasea.js +260 -0
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/talasea.d.ts +8 -0
- package/js/src/abstract/talasea.js +11 -0
- package/js/src/base/Exchange.d.ts +2 -2
- package/js/src/coinbaseexchange.d.ts +1 -1
- 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/starknet/utils/calldata/parser/index.d.ts +1 -1
- package/js/src/talasea.d.ts +20 -0
- package/js/src/talasea.js +253 -0
- package/js/test.js +25 -15
- package/package.json +1 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
import Exchange from './base/Exchange.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* @class talasea
|
|
6
|
+
* @augments Exchange
|
|
7
|
+
*/
|
|
8
|
+
export default class talasea extends Exchange {
|
|
9
|
+
describe() {
|
|
10
|
+
return this.deepExtend(super.describe(), {
|
|
11
|
+
'id': 'talasea',
|
|
12
|
+
'name': 'Talasea',
|
|
13
|
+
'countries': ['IR'],
|
|
14
|
+
'rateLimit': 1000,
|
|
15
|
+
'version': 'api',
|
|
16
|
+
'certified': false,
|
|
17
|
+
'pro': false,
|
|
18
|
+
'has': {
|
|
19
|
+
'CORS': undefined,
|
|
20
|
+
'spot': false,
|
|
21
|
+
'margin': false,
|
|
22
|
+
'swap': false,
|
|
23
|
+
'future': false,
|
|
24
|
+
'option': false,
|
|
25
|
+
'addMargin': false,
|
|
26
|
+
'cancelAllOrders': false,
|
|
27
|
+
'cancelOrder': false,
|
|
28
|
+
'cancelOrders': false,
|
|
29
|
+
'createDepositAddress': false,
|
|
30
|
+
'createOrder': false,
|
|
31
|
+
'createStopLimitOrder': false,
|
|
32
|
+
'createStopMarketOrder': false,
|
|
33
|
+
'createStopOrder': false,
|
|
34
|
+
'editOrder': false,
|
|
35
|
+
'fetchBalance': false,
|
|
36
|
+
'fetchBorrowInterest': false,
|
|
37
|
+
'fetchBorrowRateHistories': false,
|
|
38
|
+
'fetchBorrowRateHistory': false,
|
|
39
|
+
'fetchClosedOrders': false,
|
|
40
|
+
'fetchCrossBorrowRate': false,
|
|
41
|
+
'fetchCrossBorrowRates': false,
|
|
42
|
+
'fetchCurrencies': false,
|
|
43
|
+
'fetchDepositAddress': false,
|
|
44
|
+
'fetchDeposits': false,
|
|
45
|
+
'fetchFundingHistory': false,
|
|
46
|
+
'fetchFundingRate': false,
|
|
47
|
+
'fetchFundingRateHistory': false,
|
|
48
|
+
'fetchFundingRates': false,
|
|
49
|
+
'fetchIndexOHLCV': false,
|
|
50
|
+
'fetchIsolatedBorrowRate': false,
|
|
51
|
+
'fetchIsolatedBorrowRates': false,
|
|
52
|
+
'fetchL2OrderBook': false,
|
|
53
|
+
'fetchL3OrderBook': false,
|
|
54
|
+
'fetchLedger': false,
|
|
55
|
+
'fetchLedgerEntry': false,
|
|
56
|
+
'fetchLeverageTiers': false,
|
|
57
|
+
'fetchMarkets': true,
|
|
58
|
+
'fetchMarkOHLCV': false,
|
|
59
|
+
'fetchMyTrades': false,
|
|
60
|
+
'fetchOHLCV': false,
|
|
61
|
+
'fetchOpenInterestHistory': false,
|
|
62
|
+
'fetchOpenOrders': false,
|
|
63
|
+
'fetchOrder': false,
|
|
64
|
+
'fetchOrderBook': false,
|
|
65
|
+
'fetchOrders': false,
|
|
66
|
+
'fetchOrderTrades': 'emulated',
|
|
67
|
+
'fetchPositions': false,
|
|
68
|
+
'fetchPremiumIndexOHLCV': false,
|
|
69
|
+
'fetchTicker': true,
|
|
70
|
+
'fetchTickers': true,
|
|
71
|
+
'fetchTime': false,
|
|
72
|
+
'fetchTrades': false,
|
|
73
|
+
'fetchTradingFee': false,
|
|
74
|
+
'fetchTradingFees': false,
|
|
75
|
+
'fetchWithdrawals': false,
|
|
76
|
+
'otc': true,
|
|
77
|
+
'setLeverage': false,
|
|
78
|
+
'setMarginMode': false,
|
|
79
|
+
'transfer': false,
|
|
80
|
+
'withdraw': false,
|
|
81
|
+
},
|
|
82
|
+
'options': {
|
|
83
|
+
'defaultType': 'otc',
|
|
84
|
+
},
|
|
85
|
+
'urls': {
|
|
86
|
+
'api': {
|
|
87
|
+
'public': 'https://api.talasea.ir/api',
|
|
88
|
+
},
|
|
89
|
+
'www': 'https://talasea.ir',
|
|
90
|
+
'doc': 'https://talasea.ir',
|
|
91
|
+
},
|
|
92
|
+
'api': {
|
|
93
|
+
'public': {
|
|
94
|
+
'get': {
|
|
95
|
+
'market/getGoldPrice': 1,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
'fees': {
|
|
100
|
+
'trading': {
|
|
101
|
+
'tierBased': false,
|
|
102
|
+
'percentage': true,
|
|
103
|
+
'maker': this.parseNumber('0.01'),
|
|
104
|
+
'taker': this.parseNumber('0.01'),
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async fetchMarkets(params = {}) {
|
|
110
|
+
/**
|
|
111
|
+
* @method
|
|
112
|
+
* @name talasea#fetchMarkets
|
|
113
|
+
* @description retrieves the available market from talasea
|
|
114
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
115
|
+
* @returns {object[]} an array of objects representing market data
|
|
116
|
+
*/
|
|
117
|
+
const response = await this.publicGetMarketGetGoldPrice(params);
|
|
118
|
+
const market = this.parseMarket(response);
|
|
119
|
+
const result = [market];
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
parseMarket(market) {
|
|
123
|
+
const disableBuy = this.safeBool(market, 'disableBuy', false);
|
|
124
|
+
const disableSell = this.safeBool(market, 'disableSell', false);
|
|
125
|
+
let active = true;
|
|
126
|
+
if (disableBuy || disableSell) {
|
|
127
|
+
active = false;
|
|
128
|
+
}
|
|
129
|
+
const result = {
|
|
130
|
+
'id': 'XAU18IRT',
|
|
131
|
+
'symbol': 'XAU18/IRT',
|
|
132
|
+
'base': 'XAU18',
|
|
133
|
+
'quote': 'IRT',
|
|
134
|
+
'settle': undefined,
|
|
135
|
+
'baseId': 'XAU18',
|
|
136
|
+
'quoteId': 'IRT',
|
|
137
|
+
'settleId': undefined,
|
|
138
|
+
'type': 'otc',
|
|
139
|
+
'spot': false,
|
|
140
|
+
'margin': false,
|
|
141
|
+
'swap': false,
|
|
142
|
+
'future': false,
|
|
143
|
+
'option': false,
|
|
144
|
+
'active': active,
|
|
145
|
+
'contract': false,
|
|
146
|
+
'linear': undefined,
|
|
147
|
+
'inverse': undefined,
|
|
148
|
+
'contractSize': undefined,
|
|
149
|
+
'expiry': undefined,
|
|
150
|
+
'expiryDatetime': undefined,
|
|
151
|
+
'strike': undefined,
|
|
152
|
+
'optionType': undefined,
|
|
153
|
+
'precision': {
|
|
154
|
+
'amount': undefined,
|
|
155
|
+
'price': undefined,
|
|
156
|
+
},
|
|
157
|
+
'limits': {
|
|
158
|
+
'leverage': {
|
|
159
|
+
'min': undefined,
|
|
160
|
+
'max': undefined,
|
|
161
|
+
},
|
|
162
|
+
'amount': {
|
|
163
|
+
'min': undefined,
|
|
164
|
+
'max': undefined,
|
|
165
|
+
},
|
|
166
|
+
'price': {
|
|
167
|
+
'min': undefined,
|
|
168
|
+
'max': undefined,
|
|
169
|
+
},
|
|
170
|
+
'cost': {
|
|
171
|
+
'min': this.safeNumber(market, 'minOrderValue'),
|
|
172
|
+
'max': this.safeNumber(market, 'maxOrderValue'),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
'created': undefined,
|
|
176
|
+
'info': market,
|
|
177
|
+
};
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
async fetchTicker(symbol, params = {}) {
|
|
181
|
+
/**
|
|
182
|
+
* @method
|
|
183
|
+
* @name talasea#fetchTicker
|
|
184
|
+
* @description fetches a price ticker, a statistical calculation for a specific market
|
|
185
|
+
* @see https://api.talasea.ir/api/market/getGoldPrice
|
|
186
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
187
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
188
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
189
|
+
*/
|
|
190
|
+
await this.loadMarkets();
|
|
191
|
+
const market = this.market(symbol);
|
|
192
|
+
const response = await this.publicGetMarketGetGoldPrice(params);
|
|
193
|
+
const ticker = this.parseTicker(response, market);
|
|
194
|
+
return ticker;
|
|
195
|
+
}
|
|
196
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
197
|
+
/**
|
|
198
|
+
* @method
|
|
199
|
+
* @name talasea#fetchTickers
|
|
200
|
+
* @description fetches price tickers for all markets
|
|
201
|
+
* @see https://api.talasea.ir/api/market/getGoldPrice
|
|
202
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the tickers for, all market tickers are returned if not assigned
|
|
203
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
204
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
205
|
+
*/
|
|
206
|
+
await this.loadMarkets();
|
|
207
|
+
if (symbols !== undefined) {
|
|
208
|
+
symbols = this.marketSymbols(symbols);
|
|
209
|
+
}
|
|
210
|
+
const response = await this.publicGetMarketGetGoldPrice(params);
|
|
211
|
+
const market = this.market('XAU18/IRT');
|
|
212
|
+
const ticker = this.parseTicker(response, market);
|
|
213
|
+
const result = {};
|
|
214
|
+
result[ticker['symbol']] = ticker;
|
|
215
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
216
|
+
}
|
|
217
|
+
parseTicker(ticker, market = undefined) {
|
|
218
|
+
const result = this.safeTicker({
|
|
219
|
+
'symbol': market['symbol'],
|
|
220
|
+
'timestamp': undefined,
|
|
221
|
+
'datetime': undefined,
|
|
222
|
+
'high': undefined,
|
|
223
|
+
'low': undefined,
|
|
224
|
+
'bid': undefined,
|
|
225
|
+
'bidVolume': undefined,
|
|
226
|
+
'ask': undefined,
|
|
227
|
+
'askVolume': undefined,
|
|
228
|
+
'vwap': undefined,
|
|
229
|
+
'open': undefined,
|
|
230
|
+
'close': this.safeNumber(ticker, 'price') * 1000,
|
|
231
|
+
'last': this.safeNumber(ticker, 'price') * 1000,
|
|
232
|
+
'previousClose': undefined,
|
|
233
|
+
'change': undefined,
|
|
234
|
+
'percentage': this.safeNumber(ticker, 'change24h'),
|
|
235
|
+
'average': undefined,
|
|
236
|
+
'baseVolume': undefined,
|
|
237
|
+
'quoteVolume': undefined,
|
|
238
|
+
'info': ticker,
|
|
239
|
+
}, market);
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
243
|
+
const query = this.omit(params, this.extractParams(path));
|
|
244
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
245
|
+
if (Object.keys(query).length) {
|
|
246
|
+
url += '?' + this.urlencode(query);
|
|
247
|
+
}
|
|
248
|
+
headers = {
|
|
249
|
+
'Content-Type': 'application/json',
|
|
250
|
+
};
|
|
251
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
252
|
+
}
|
|
253
|
+
}
|
package/js/test.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
import ccxt from './ccxt';
|
|
2
|
-
async function
|
|
3
|
-
const exchange = new ccxt.
|
|
2
|
+
async function testTalasea() {
|
|
3
|
+
const exchange = new ccxt.talasea({
|
|
4
4
|
enableRateLimit: true,
|
|
5
5
|
timeout: 20000,
|
|
6
6
|
});
|
|
7
7
|
try {
|
|
8
8
|
const markets = await exchange.fetchMarkets();
|
|
9
9
|
if (markets.length === 0) {
|
|
10
|
-
throw new Error('
|
|
10
|
+
throw new Error('Talasea returned no markets');
|
|
11
|
+
}
|
|
12
|
+
const market = markets[0];
|
|
13
|
+
if (market['symbol'] !== 'XAU18/IRT') {
|
|
14
|
+
throw new Error('Talasea did not return the XAU18/IRT market');
|
|
11
15
|
}
|
|
12
16
|
const tickers = await exchange.fetchTickers();
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
throw new Error('
|
|
17
|
+
const goldTicker = tickers['XAU18/IRT'];
|
|
18
|
+
if (goldTicker === undefined) {
|
|
19
|
+
throw new Error('Talasea did not return an XAU18/IRT ticker');
|
|
20
|
+
}
|
|
21
|
+
const ticker = await exchange.fetchTicker('XAU18/IRT');
|
|
22
|
+
if (ticker['last'] === undefined) {
|
|
23
|
+
throw new Error('Talasea did not return a gold price');
|
|
16
24
|
}
|
|
17
|
-
console.log('
|
|
18
|
-
endpoint: 'https://api.
|
|
25
|
+
console.log('Talasea test passed:', {
|
|
26
|
+
endpoint: 'https://api.talasea.ir/api/market/getGoldPrice',
|
|
19
27
|
markets: markets.length,
|
|
20
28
|
tickers: Object.keys(tickers).length,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
gold: {
|
|
30
|
+
symbol: ticker.symbol,
|
|
31
|
+
last: ticker.last,
|
|
32
|
+
percentage: ticker.percentage,
|
|
33
|
+
minOrderValue: market.limits.cost.min,
|
|
34
|
+
maxOrderValue: market.limits.cost.max,
|
|
35
|
+
active: market.active,
|
|
26
36
|
},
|
|
27
37
|
});
|
|
28
38
|
}
|
|
@@ -30,7 +40,7 @@ async function testSaraf() {
|
|
|
30
40
|
await exchange.close();
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
console.error('
|
|
43
|
+
testTalasea().catch((error) => {
|
|
44
|
+
console.error('Talasea test failed:', error);
|
|
35
45
|
process.exitCode = 1;
|
|
36
46
|
});
|
package/package.json
CHANGED