MCPcopy
hub / github.com/ccxt/ccxt / parsePrecision

Method parsePrecision

java/lib/src/main/java/io/github/ccxt/Exchange.java:11797–11831  ·  view source on GitHub ↗
(Object precision, Object... optionalArgs)

Source from the content-addressed store, hash-verified

11795 }
11796
11797 public Object parsePrecision(Object precision, Object... optionalArgs)
11798 {
11799 /**
11800 * @ignore
11801 * @method
11802 * @param {string} precision The number of digits to the right of the decimal
11803 * @returns {string} a string number equal to 1e-precision
11804 */
11805 if (Helpers.isTrue(Helpers.isEqual(precision, null)))
11806 {
11807 return null;
11808 }
11809 Object precisionNumber = Helpers.parseInt(precision);
11810 if (Helpers.isTrue(Helpers.isEqual(precisionNumber, 0)))
11811 {
11812 return "1";
11813 }
11814 if (Helpers.isTrue(Helpers.isGreaterThan(precisionNumber, 0)))
11815 {
11816 Object parsedPrecision = "0.";
11817 for (var i = 0; Helpers.isLessThan(i, Helpers.subtract(precisionNumber, 1)); i++)
11818 {
11819 parsedPrecision = Helpers.add(parsedPrecision, "0");
11820 }
11821 return Helpers.add(parsedPrecision, "1");
11822 } else
11823 {
11824 Object parsedPrecision = "1";
11825 for (var i = 0; Helpers.isLessThan(i, Helpers.subtract(Helpers.multiply(precisionNumber, Helpers.opNeg(1)), 1)); i++)
11826 {
11827 parsedPrecision = Helpers.add(parsedPrecision, "0");
11828 }
11829 return Helpers.add(parsedPrecision, "0");
11830 }
11831 }
11832
11833 public Object integerPrecisionToAmount(Object precision)
11834 {

Callers 15

testParsePrecisionMethod · 0.95
parseMarketMethod · 0.45
parseMarketMethod · 0.45
parseSpotMarketMethod · 0.45
parseCurrencyMethod · 0.45
parseCurrencyMethod · 0.45
fetchSpotMarketsMethod · 0.45
parseMarketMethod · 0.45
parseCurrencyMethod · 0.45
parseCurrencyMethod · 0.45
parseCurrencyMethod · 0.45

Calls 9

isTrueMethod · 0.95
isEqualMethod · 0.95
parseIntMethod · 0.95
isGreaterThanMethod · 0.95
isLessThanMethod · 0.95
subtractMethod · 0.95
addMethod · 0.95
multiplyMethod · 0.95
opNegMethod · 0.95

Tested by 1

testParsePrecisionMethod · 0.76