Skip to content

Commit

Permalink
python: add enum and data classess
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Apr 13, 2022
1 parent 2af3dfb commit e29b6e8
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 50 deletions.
1 change: 1 addition & 0 deletions python/bbgo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import enums
from .services import MarketService
from .services import TradingService
from .services import UserDataService
Expand Down
3 changes: 3 additions & 0 deletions python/bbgo/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .balance import Balance
from .kline import KLine
from .order import Order
9 changes: 9 additions & 0 deletions python/bbgo/data/balance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dataclasses import dataclass


@dataclass
class Balance:
exchange: str
currency: str
available: float
locked: float
18 changes: 18 additions & 0 deletions python/bbgo/data/kline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from dataclasses import dataclass
from datetime import datetime


@dataclass
class KLine:
exchange: str
symbol: str
open: float
high: float
low: float
close: float
volume: float
session: str = None
start_time: datetime = None
end_time: datetime = None
quote_volume: float = None
closed: bool = None
24 changes: 24 additions & 0 deletions python/bbgo/data/order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from dataclasses import dataclass
from datetime import datetime

from ..enums import OrderType
from ..enums import SideType


@dataclass
class Order:
order_id: str
side: SideType
order_type: OrderType
price: float
stop_price: float
average_price: float
status: str
market: str
created_at: datetime
volume: float
remaining_volume: float
executed_volume: float
trade_count: int
client_order_id: str
group_id: str
4 changes: 4 additions & 0 deletions python/bbgo/enums/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .channel_type import ChannelType
from .event_type import EventType
from .order_type import OrderType
from .side_type import SideType
9 changes: 9 additions & 0 deletions python/bbgo/enums/channel_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from enum import Enum


class ChannelType(Enum):
BOOK = 'book'
TRADE = 'trade'
TICKER = 'ticker'
USER = 'user'
KLINE = 'kline'
16 changes: 16 additions & 0 deletions python/bbgo/enums/event_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from enum import Enum


class EventType(Enum):
ERROR = 'error'
SUBSCRIBED = 'subscribed'
UNSUBSCRIBED = 'unsubscribed'
AUTHENTICATED = 'authenticated'
SNAPSHOT = 'snapshot'
UPDATE = 'update'
ORDER_SNAPSHOT = 'order_snapshot'
ORDER_UPDATE = 'order_update'
TRADE_SNAPSHOT = 'trade_snapshot'
TRADE_UPDATE = 'trade_update'
ACCOUNT_SNAPSHOT = 'account_snapshot'
ACCOUNT_UPDATE = 'account_update'
10 changes: 10 additions & 0 deletions python/bbgo/enums/order_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from enum import Enum


class OrderType(Enum):
MARKET = 'market'
LIMIT = 'limit'
STOP_MARKET = 'stop_market'
STOP_LIMIT = 'stop_limit'
POST_ONLY = 'post_only'
IOC_LIMIT = 'ioc_limit'
6 changes: 6 additions & 0 deletions python/bbgo/enums/side_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum


class SideType(Enum):
BUY = 'buy'
SELL = 'sell'
100 changes: 50 additions & 50 deletions python/bbgo_pb2.py

Large diffs are not rendered by default.

0 comments on commit e29b6e8

Please sign in to comment.