mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
chore: Split strip_trailing_zeros function in formatters
This commit is contained in:
parent
d07ec50549
commit
ca2d322eb8
|
@ -10,6 +10,15 @@ def decimals_per_coin(coin: str):
|
|||
return DECIMALS_PER_COIN.get(coin, DECIMAL_PER_COIN_FALLBACK)
|
||||
|
||||
|
||||
def strip_trailing_zeros(value: str) -> str:
|
||||
"""
|
||||
Strip trailing zeros from a string
|
||||
:param value: Value to be stripped
|
||||
:return: Stripped value
|
||||
"""
|
||||
return value.rstrip('0').rstrip('.')
|
||||
|
||||
|
||||
def round_value(value: float, decimals: int, keep_trailing_zeros=False) -> str:
|
||||
"""
|
||||
Round value to given decimals
|
||||
|
@ -20,7 +29,7 @@ def round_value(value: float, decimals: int, keep_trailing_zeros=False) -> str:
|
|||
"""
|
||||
val = f"{value:.{decimals}f}"
|
||||
if not keep_trailing_zeros:
|
||||
val = val.rstrip('0').rstrip('.')
|
||||
val = strip_trailing_zeros(val)
|
||||
return val
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user