mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
21 lines
369 B
Python
21 lines
369 B
Python
from datetime import datetime
|
|
from decimal import Decimal
|
|
from typing import Union
|
|
|
|
|
|
def parse_number(s: Union[str, float]) -> Decimal:
|
|
if s is None:
|
|
return 0
|
|
|
|
if s == "":
|
|
return 0
|
|
|
|
return Decimal(s)
|
|
|
|
|
|
def parse_time(t: Union[str, int]) -> datetime:
|
|
if isinstance(t, str):
|
|
t = int(t)
|
|
|
|
return datetime.fromtimestamp(t / 1000)
|