diff --git a/cs/ccxt/base/Exchange.Number.cs b/cs/ccxt/base/Exchange.Number.cs index db83dd619785..efa352492798 100644 --- a/cs/ccxt/base/Exchange.Number.cs +++ b/cs/ccxt/base/Exchange.Number.cs @@ -300,6 +300,8 @@ public static string NumberToString(object number) { if (number == null) return null; + if (number.GetType() == typeof(string)) + return number as string; if (number.GetType() == typeof(Int32) || number.GetType() == typeof(Int64)) return number.ToString(); diff --git a/python/ccxt/base/decimal_to_precision.py b/python/ccxt/base/decimal_to_precision.py index 4be38f010765..6dccb5faec05 100644 --- a/python/ccxt/base/decimal_to_precision.py +++ b/python/ccxt/base/decimal_to_precision.py @@ -169,6 +169,8 @@ def number_to_string(x): # avoids scientific notation for too large and too small numbers if x is None: return None + if isinstance(x, str): + return x d = decimal.Decimal(str(x)) formatted = '{:f}'.format(d) return formatted.rstrip('0').rstrip('.') if '.' in formatted else formatted diff --git a/ts/src/base/functions/number.ts b/ts/src/base/functions/number.ts index 15a3167b904d..6da47ba44a26 100644 --- a/ts/src/base/functions/number.ts +++ b/ts/src/base/functions/number.ts @@ -39,6 +39,7 @@ const precisionConstants = { function numberToString (x) { // avoids scientific notation for too large and too small numbers if (x === undefined) return undefined; + if (typeof x === 'string') return x; if (typeof x !== 'number') return x.toString (); const s = x.toString (); if (Math.abs (x) < 1.0) {