bbgo_origin/python/bbgo/utils/convert.py

20 lines
337 B
Python
Raw Normal View History

2022-04-18 03:45:03 +00:00
from datetime import datetime
from typing import Union
def parse_float(s: Union[str, float]) -> float:
2022-04-18 03:45:03 +00:00
if s is None:
return 0
if s == "":
return 0
return float(s)
def parse_time(t: Union[str, int]) -> datetime:
if isinstance(t, str):
t = int(t)
return datetime.fromtimestamp(t / 1000),