mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 03:23:52 +00:00
20 lines
323 B
Python
20 lines
323 B
Python
|
from datetime import datetime
|
||
|
from typing import Union
|
||
|
|
||
|
|
||
|
def parse_float(s: str) -> float:
|
||
|
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),
|