bbgo_origin/python/tests/test_utils.py

20 lines
369 B
Python
Raw Permalink Normal View History

2022-05-13 08:30:19 +00:00
from decimal import Decimal
from bbgo.utils import parse_number
2022-04-22 07:00:40 +00:00
from bbgo.utils import parse_time
def test_parse_time():
t = 1650610080000
d = parse_time(t)
assert d.timestamp() == t / 1000
def test_parse_float():
2022-05-13 08:30:19 +00:00
assert parse_number(None) == 0
assert parse_number("") == 0
2022-04-22 07:00:40 +00:00
s = "3.14159265358979"
2022-05-13 08:30:19 +00:00
assert parse_number(s) == Decimal(s)