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

Method integerPrecisionToAmount

ts/src/base/Exchange.ts:7571–7593  ·  view source on GitHub ↗
(precision: Str)

Source from the content-addressed store, hash-verified

7569 }
7570
7571 integerPrecisionToAmount (precision: Str) {
7572 /**
7573 * @ignore
7574 * @method
7575 * @description handles positive & negative numbers too. parsePrecision() does not handle negative numbers, but this method handles
7576 * @param {string} precision The number of digits to the right of the decimal
7577 * @returns {string} a string number equal to 1e-precision
7578 */
7579 if (precision === undefined) {
7580 return undefined;
7581 }
7582 if (Precise.stringGe (precision, '0')) {
7583 return this.parsePrecision (precision);
7584 } else {
7585 const positivePrecisionString = Precise.stringAbs (precision);
7586 const positivePrecision = parseInt (positivePrecisionString);
7587 let parsedPrecision = '1';
7588 for (let i = 0; i < positivePrecision - 1; i++) {
7589 parsedPrecision = parsedPrecision + '0';
7590 }
7591 return parsedPrecision + '0';
7592 }
7593 }
7594
7595 async loadTimeDifference (params = {}) {
7596 const serverTime = await this.fetchTime (params);

Callers 1

fetchMarketsMethod · 0.45

Calls 4

parsePrecisionMethod · 0.95
parseIntFunction · 0.85
stringGeMethod · 0.45
stringAbsMethod · 0.45

Tested by

no test coverage detected