MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetchMarkets

Method fetchMarkets

ts/src/bitso.ts:462–593  ·  view source on GitHub ↗

* @method * @name bitso#fetchMarkets * @description retrieves data on all markets for bitso * @see https://docs.bitso.com/bitso-api/docs/list-available-books * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of o

(params = {})

Source from the content-addressed store, hash-verified

460 * @returns {object[]} an array of objects representing market data
461 */
462 async fetchMarkets (params = {}): Promise<Market[]> {
463 const response = await this.publicGetAvailableBooks (params);
464 //
465 // {
466 // "success":true,
467 // "payload":[
468 // {
469 // "book":"btc_mxn",
470 // "minimum_price":"500",
471 // "maximum_price":"10000000",
472 // "minimum_amount":"0.00005",
473 // "maximum_amount":"500",
474 // "minimum_value":"5",
475 // "maximum_value":"10000000",
476 // "tick_size":"0.01",
477 // "fees":{
478 // "flat_rate":{"maker":"0.500","taker":"0.650"},
479 // "structure":[
480 // {"volume":"1500000","maker":"0.00500","taker":"0.00650"},
481 // {"volume":"2000000","maker":"0.00490","taker":"0.00637"},
482 // {"volume":"5000000","maker":"0.00480","taker":"0.00624"},
483 // {"volume":"7000000","maker":"0.00440","taker":"0.00572"},
484 // {"volume":"10000000","maker":"0.00420","taker":"0.00546"},
485 // {"volume":"15000000","maker":"0.00400","taker":"0.00520"},
486 // {"volume":"35000000","maker":"0.00370","taker":"0.00481"},
487 // {"volume":"50000000","maker":"0.00300","taker":"0.00390"},
488 // {"volume":"150000000","maker":"0.00200","taker":"0.00260"},
489 // {"volume":"250000000","maker":"0.00100","taker":"0.00130"},
490 // {"volume":"9999999999","maker":"0.00000","taker":"0.00130"},
491 // ]
492 // }
493 // },
494 // ]
495 // }
496 const markets = this.safeValue (response, 'payload', []);
497 const result: Market[] = [];
498 for (let i = 0; i < markets.length; i++) {
499 const market = markets[i];
500 const id = this.safeString (market, 'book');
501 const [ baseId, quoteId ] = id.split ('_');
502 let base = baseId.toUpperCase ();
503 let quote = quoteId.toUpperCase ();
504 base = this.safeCurrencyCode (base);
505 quote = this.safeCurrencyCode (quote);
506 const fees = this.safeValue (market, 'fees', {});
507 const flatRate = this.safeValue (fees, 'flat_rate', {});
508 const takerString = this.safeString (flatRate, 'taker');
509 const makerString = this.safeString (flatRate, 'maker');
510 const taker = this.parseNumber (Precise.stringDiv (takerString, '100'));
511 const maker = this.parseNumber (Precise.stringDiv (makerString, '100'));
512 const feeTiers = this.safeValue (fees, 'structure', []);
513 const fee = {
514 'taker': taker,
515 'maker': maker,
516 'percentage': true,
517 'tierBased': true,
518 };
519 const takerFees = [];

Callers

nothing calls this directly

Calls 10

splitMethod · 0.80
pushMethod · 0.80
safeValueMethod · 0.45
safeStringMethod · 0.45
safeCurrencyCodeMethod · 0.45
parseNumberMethod · 0.45
stringDivMethod · 0.45
safeNumberMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected