bbgo_origin/python/bbgo/data/subscription.py

33 lines
722 B
Python
Raw Permalink Normal View History

2022-04-13 09:40:21 +00:00
from __future__ import annotations
from dataclasses import dataclass
import bbgo_pb2
from ..enums import ChannelType
from ..enums import DepthType
@dataclass
class Subscription:
exchange: str
channel: ChannelType
symbol: str
depth: DepthType = None
interval: str = None
def to_pb(self) -> bbgo_pb2.Subscription:
subscription_pb = bbgo_pb2.Subscription(
exchange=self.exchange,
2022-04-15 06:57:33 +00:00
channel=self.channel.value,
2022-04-13 09:40:21 +00:00
symbol=self.symbol,
)
if self.depth is not None:
subscription_pb.depth = self.depth.value
if self.interval is not None:
subscription_pb.interval = self.interval
return subscription_pb