mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 00:05:15 +00:00
32 lines
678 B
Python
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),
|
|
)
|