Skip to content

Commit d6cdaa9

Browse files
Merge branch 'master' of https://github.com/ccxt/ccxt
2 parents 9940ce9 + 265aab1 commit d6cdaa9

File tree

10 files changed

+77
-16
lines changed

10 files changed

+77
-16
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ jobs:
3838
with:
3939
python-version: '3.11'
4040
cache: 'pip'
41-
- name: Install GH CLI
42-
uses: dev-hanz-ops/install-gh-cli-action@v0.2.1
41+
- uses: actions4gh/setup-gh@v1
4342
- name: create usr/share/dotnet folder
4443
run: |
4544
sudo mkdir -p /usr/share/dotnet

cs/ccxt/exchanges/coinmetro.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public override object describe()
200200
{ "precisionMode", TICK_SIZE },
201201
{ "options", new Dictionary<string, object>() {
202202
{ "currenciesByIdForParseMarket", null },
203-
{ "currencyIdsListForParseMarket", null },
203+
{ "currencyIdsListForParseMarket", new List<object>() {"QRDO"} },
204204
} },
205205
{ "features", new Dictionary<string, object>() {
206206
{ "spot", new Dictionary<string, object>() {
@@ -399,7 +399,13 @@ public async override Task<object> fetchCurrencies(object parameters = null)
399399
{
400400
object currenciesById = this.indexBy(result, "id");
401401
((IDictionary<string,object>)this.options)["currenciesByIdForParseMarket"] = currenciesById;
402-
((IDictionary<string,object>)this.options)["currencyIdsListForParseMarket"] = new List<object>(((IDictionary<string,object>)currenciesById).Keys);
402+
object currentCurrencyIdsList = this.safeList(this.options, "currencyIdsListForParseMarket", new List<object>() {});
403+
object currencyIdsList = new List<object>(((IDictionary<string,object>)currenciesById).Keys);
404+
for (object i = 0; isLessThan(i, getArrayLength(currencyIdsList)); postFixIncrement(ref i))
405+
{
406+
((IList<object>)currentCurrencyIdsList).Add(getValue(currencyIdsList, i));
407+
}
408+
((IDictionary<string,object>)this.options)["currencyIdsListForParseMarket"] = currentCurrencyIdsList;
403409
}
404410
return result;
405411
}
@@ -508,11 +514,26 @@ public virtual object parseMarketId(object marketId)
508514
object baseId = null;
509515
object quoteId = null;
510516
object currencyIds = this.safeValue(this.options, "currencyIdsListForParseMarket", new List<object>() {});
517+
// Bubble sort by length (longest first)
518+
object currencyIdsLength = getArrayLength(currencyIds);
519+
for (object i = 0; isLessThan(i, currencyIdsLength); postFixIncrement(ref i))
520+
{
521+
for (object j = 0; isLessThan(j, subtract(subtract(currencyIdsLength, i), 1)); postFixIncrement(ref j))
522+
{
523+
object a = getValue(currencyIds, j);
524+
object b = getValue(currencyIds, add(j, 1));
525+
if (isTrue(isLessThan(getArrayLength(a), getArrayLength(b))))
526+
{
527+
((List<object>)currencyIds)[Convert.ToInt32(j)] = b;
528+
((List<object>)currencyIds)[Convert.ToInt32(add(j, 1))] = a;
529+
}
530+
}
531+
}
511532
for (object i = 0; isLessThan(i, getArrayLength(currencyIds)); postFixIncrement(ref i))
512533
{
513534
object currencyId = getValue(currencyIds, i);
514535
object entryIndex = getIndexOf(marketId, currencyId);
515-
if (isTrue(!isEqual(entryIndex, -1)))
536+
if (isTrue(isEqual(entryIndex, 0)))
516537
{
517538
object restId = ((string)marketId).Replace((string)currencyId, (string)"");
518539
if (isTrue(this.inArray(restId, currencyIds)))

dist/ccxt.browser.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297250,7 +297250,10 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A
297250297250
[type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params, 'spot');
297251297251
await this.authenticate(type);
297252297252
const url = this.urls['api']['ws'][type];
297253-
let currencies = Object.keys(this.currencies_by_id);
297253+
// coinex throws a closes the websocket when subscribing over 1422 currencies, therefore we filter out inactive currencies
297254+
const activeCurrencies = this.filterBy(this.currencies_by_id, 'active', true);
297255+
const activeCurrenciesById = this.indexBy(activeCurrencies, 'id');
297256+
let currencies = Object.keys(activeCurrenciesById);
297254297257
if (currencies === undefined) {
297255297258
currencies = [];
297256297259
}

dist/ccxt.browser.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/src/pro/coinex.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ class coinex extends coinex$1 {
253253
[type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params, 'spot');
254254
await this.authenticate(type);
255255
const url = this.urls['api']['ws'][type];
256-
let currencies = Object.keys(this.currencies_by_id);
256+
// coinex throws a closes the websocket when subscribing over 1422 currencies, therefore we filter out inactive currencies
257+
const activeCurrencies = this.filterBy(this.currencies_by_id, 'active', true);
258+
const activeCurrenciesById = this.indexBy(activeCurrencies, 'id');
259+
let currencies = Object.keys(activeCurrenciesById);
257260
if (currencies === undefined) {
258261
currencies = [];
259262
}

js/src/pro/coinex.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ export default class coinex extends coinexRest {
256256
[type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params, 'spot');
257257
await this.authenticate(type);
258258
const url = this.urls['api']['ws'][type];
259-
let currencies = Object.keys(this.currencies_by_id);
259+
// coinex throws a closes the websocket when subscribing over 1422 currencies, therefore we filter out inactive currencies
260+
const activeCurrencies = this.filterBy(this.currencies_by_id, 'active', true);
261+
const activeCurrenciesById = this.indexBy(activeCurrencies, 'id');
262+
let currencies = Object.keys(activeCurrenciesById);
260263
if (currencies === undefined) {
261264
currencies = [];
262265
}

python/ccxt/async_support/coinmetro.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def describe(self):
219219
# exchange-specific options
220220
'options': {
221221
'currenciesByIdForParseMarket': None,
222-
'currencyIdsListForParseMarket': None,
222+
'currencyIdsListForParseMarket': ['QRDO'],
223223
},
224224
'features': {
225225
'spot': {
@@ -407,7 +407,11 @@ async def fetch_currencies(self, params={}) -> Currencies:
407407
if self.safe_value(self.options, 'currenciesByIdForParseMarket') is None:
408408
currenciesById = self.index_by(result, 'id')
409409
self.options['currenciesByIdForParseMarket'] = currenciesById
410-
self.options['currencyIdsListForParseMarket'] = list(currenciesById.keys())
410+
currentCurrencyIdsList = self.safe_list(self.options, 'currencyIdsListForParseMarket', [])
411+
currencyIdsList = list(currenciesById.keys())
412+
for i in range(0, len(currencyIdsList)):
413+
currentCurrencyIdsList.append(currencyIdsList[i])
414+
self.options['currencyIdsListForParseMarket'] = currentCurrencyIdsList
411415
return result
412416

413417
async def fetch_markets(self, params={}) -> List[Market]:
@@ -506,10 +510,19 @@ def parse_market_id(self, marketId):
506510
baseId = None
507511
quoteId = None
508512
currencyIds = self.safe_value(self.options, 'currencyIdsListForParseMarket', [])
513+
# Bubble sort by length(longest first)
514+
currencyIdsLength = len(currencyIds)
515+
for i in range(0, currencyIdsLength):
516+
for j in range(0, currencyIdsLength - i - 1):
517+
a = currencyIds[j]
518+
b = currencyIds[j + 1]
519+
if len(a) < len(b):
520+
currencyIds[j] = b
521+
currencyIds[j + 1] = a
509522
for i in range(0, len(currencyIds)):
510523
currencyId = currencyIds[i]
511524
entryIndex = marketId.find(currencyId)
512-
if entryIndex != -1:
525+
if entryIndex == 0:
513526
restId = marketId.replace(currencyId, '')
514527
if self.in_array(restId, currencyIds):
515528
if entryIndex == 0:

python/ccxt/coinmetro.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def describe(self):
219219
# exchange-specific options
220220
'options': {
221221
'currenciesByIdForParseMarket': None,
222-
'currencyIdsListForParseMarket': None,
222+
'currencyIdsListForParseMarket': ['QRDO'],
223223
},
224224
'features': {
225225
'spot': {
@@ -407,7 +407,11 @@ def fetch_currencies(self, params={}) -> Currencies:
407407
if self.safe_value(self.options, 'currenciesByIdForParseMarket') is None:
408408
currenciesById = self.index_by(result, 'id')
409409
self.options['currenciesByIdForParseMarket'] = currenciesById
410-
self.options['currencyIdsListForParseMarket'] = list(currenciesById.keys())
410+
currentCurrencyIdsList = self.safe_list(self.options, 'currencyIdsListForParseMarket', [])
411+
currencyIdsList = list(currenciesById.keys())
412+
for i in range(0, len(currencyIdsList)):
413+
currentCurrencyIdsList.append(currencyIdsList[i])
414+
self.options['currencyIdsListForParseMarket'] = currentCurrencyIdsList
411415
return result
412416

413417
def fetch_markets(self, params={}) -> List[Market]:
@@ -506,10 +510,19 @@ def parse_market_id(self, marketId):
506510
baseId = None
507511
quoteId = None
508512
currencyIds = self.safe_value(self.options, 'currencyIdsListForParseMarket', [])
513+
# Bubble sort by length(longest first)
514+
currencyIdsLength = len(currencyIds)
515+
for i in range(0, currencyIdsLength):
516+
for j in range(0, currencyIdsLength - i - 1):
517+
a = currencyIds[j]
518+
b = currencyIds[j + 1]
519+
if len(a) < len(b):
520+
currencyIds[j] = b
521+
currencyIds[j + 1] = a
509522
for i in range(0, len(currencyIds)):
510523
currencyId = currencyIds[i]
511524
entryIndex = marketId.find(currencyId)
512-
if entryIndex != -1:
525+
if entryIndex == 0:
513526
restId = marketId.replace(currencyId, '')
514527
if self.in_array(restId, currencyIds):
515528
if entryIndex == 0:

python/ccxt/pro/coinex.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ async def watch_balance(self, params={}) -> Balances:
263263
type, params = self.handle_market_type_and_params('watchBalance', None, params, 'spot')
264264
await self.authenticate(type)
265265
url = self.urls['api']['ws'][type]
266-
currencies = list(self.currencies_by_id.keys())
266+
# coinex throws a closes the websocket when subscribing over 1422 currencies, therefore we filter out inactive currencies
267+
activeCurrencies = self.filter_by(self.currencies_by_id, 'active', True)
268+
activeCurrenciesById = self.index_by(activeCurrencies, 'id')
269+
currencies = list(activeCurrenciesById.keys())
267270
if currencies is None:
268271
currencies = []
269272
messageHash = 'balances'

skip-tests.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,9 @@
16921692
},
16931693
"coinlist": {
16941694
"skipMethods": {
1695+
"loadMarkets": {
1696+
"precision": "ammount is sometimes 0"
1697+
},
16951698
"ticker": {
16961699
"baseVolume": "quoteVolume >= baseVolume * low is failing",
16971700
"bid": "invalid"

0 commit comments

Comments
 (0)