From e240361494d60e478f9032ada1cf8c7d93db897f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=BF?= Date: Fri, 22 Apr 2022 15:00:40 +0800 Subject: [PATCH] python: test convert utils --- python/bbgo/handlers/order.py | 1 - python/pyproject.toml | 2 +- python/tests/test_utils.py | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 python/tests/test_utils.py diff --git a/python/bbgo/handlers/order.py b/python/bbgo/handlers/order.py index ff2701786..ccebc934a 100644 --- a/python/bbgo/handlers/order.py +++ b/python/bbgo/handlers/order.py @@ -1,4 +1,3 @@ -from ..data import Event from ..data import UserDataEvent from ..enums import ChannelType from ..enums import EventType diff --git a/python/pyproject.toml b/python/pyproject.toml index 32b20dd4a..71e215997 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bbgo" -version = "0.1.6" +version = "0.1.7" description = "" authors = ["なるみ "] packages = [ diff --git a/python/tests/test_utils.py b/python/tests/test_utils.py new file mode 100644 index 000000000..591bec147 --- /dev/null +++ b/python/tests/test_utils.py @@ -0,0 +1,18 @@ +from bbgo.utils import parse_float +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(): + assert parse_float(None) == 0 + assert parse_float("") == 0 + + s = "3.14159265358979" + f = 3.14159265358979 + assert parse_float(s) == f