bbgo_origin/python/bbgo/data/ticker.py
2022-05-13 16:30:19 +08:00

32 lines
678 B
Python

from __future__ import annotations
from dataclasses import dataclass
from decimal import Decimal
import bbgo_pb2
from ..utils import parse_number
@dataclass
class Ticker:
exchange: str
symbol: str
open: Decimal
high: Decimal
low: Decimal
close: Decimal
volume: Decimal
@classmethod
def from_pb(cls, obj: bbgo_pb2.KLine) -> Ticker:
return cls(
exchange=obj.exchange,
symbol=obj.symbol,
open=parse_number(obj.open),
high=parse_number(obj.high),
low=parse_number(obj.low),
close=parse_number(obj.close),
volume=parse_number(obj.volume),
)