Wrap Precise into FtPecise

This commit is contained in:
Matthias
2022-08-10 11:26:06 +00:00
parent adc8ee88e2
commit e7cb1b7375
4 changed files with 41 additions and 30 deletions

View File

@@ -1,14 +1,14 @@
from ccxt import Precise
from freqtrade.util import FtPrecise
ws = Precise('-1.123e-6')
ws = Precise('-1.123e-6')
xs = Precise('0.00000002')
ys = Precise('69696900000')
zs = Precise('0')
ws = FtPrecise('-1.123e-6')
ws = FtPrecise('-1.123e-6')
xs = FtPrecise('0.00000002')
ys = FtPrecise('69696900000')
zs = FtPrecise('0')
def test_precise():
def test_FtPrecise():
assert ys * xs == '1393.938'
assert xs * ys == '1393.938'
@@ -45,31 +45,31 @@ def test_precise():
assert xs + zs == '0.00000002'
assert ys + zs == '69696900000'
assert abs(Precise('-500.1')) == '500.1'
assert abs(Precise('213')) == '213'
assert abs(FtPrecise('-500.1')) == '500.1'
assert abs(FtPrecise('213')) == '213'
assert abs(Precise('-500.1')) == '500.1'
assert -Precise('213') == '-213'
assert abs(FtPrecise('-500.1')) == '500.1'
assert -FtPrecise('213') == '-213'
assert Precise('10.1') % Precise('0.5') == '0.1'
assert Precise('5550') % Precise('120') == '30'
assert FtPrecise('10.1') % FtPrecise('0.5') == '0.1'
assert FtPrecise('5550') % FtPrecise('120') == '30'
assert Precise('-0.0') == Precise('0')
assert Precise('5.534000') == Precise('5.5340')
assert FtPrecise('-0.0') == FtPrecise('0')
assert FtPrecise('5.534000') == FtPrecise('5.5340')
assert min(Precise('-3.1415'), Precise('-2')) == '-3.1415'
assert min(FtPrecise('-3.1415'), FtPrecise('-2')) == '-3.1415'
assert max(Precise('3.1415'), Precise('-2')) == '3.1415'
assert max(FtPrecise('3.1415'), FtPrecise('-2')) == '3.1415'
assert Precise('2') > Precise('1.2345')
assert not Precise('-3.1415') > Precise('-2')
assert not Precise('3.1415') > Precise('3.1415')
assert Precise.string_gt('3.14150000000000000000001', '3.1415')
assert FtPrecise('2') > FtPrecise('1.2345')
assert not FtPrecise('-3.1415') > FtPrecise('-2')
assert not FtPrecise('3.1415') > FtPrecise('3.1415')
assert FtPrecise.string_gt('3.14150000000000000000001', '3.1415')
assert Precise('3.1415') >= Precise('3.1415')
assert Precise('3.14150000000000000000001') >= Precise('3.1415')
assert FtPrecise('3.1415') >= FtPrecise('3.1415')
assert FtPrecise('3.14150000000000000000001') >= FtPrecise('3.1415')
assert not Precise('3.1415') < Precise('3.1415')
assert not FtPrecise('3.1415') < FtPrecise('3.1415')
assert Precise('3.1415') <= Precise('3.1415')
assert Precise('3.1415') <= Precise('3.14150000000000000000001')
assert FtPrecise('3.1415') <= FtPrecise('3.1415')
assert FtPrecise('3.1415') <= FtPrecise('3.14150000000000000000001')