mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
Merge pull request #549 from narumiruna/python/handlers
python: add event&channel handlers
This commit is contained in:
commit
1cb4b312fc
|
@ -1,4 +1,5 @@
|
|||
from . import enums
|
||||
from . import handlers
|
||||
from . import utils
|
||||
from .services import MarketService
|
||||
from .services import TradingService
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
from .balance import BalanceHandler
|
||||
from .balance import BalanceSnapshotHandler
|
||||
from .balance import BalanceUpdateHandler
|
||||
from .book import BookSnapshotHandler
|
||||
from .book import BookUpdateHandler
|
||||
from .error import ErrorHandler
|
||||
from .handler import Handler
|
||||
from .kline import KLineHandler
|
||||
from .kline import KLineSnapshotHandler
|
||||
from .kline import KLineUpdateHandler
|
||||
from .order import OrderHandler
|
||||
from .order import OrderSnapshotHandler
|
||||
from .order import OrderUpdateHandler
|
||||
from .snapshot import SnapshotHandler
|
||||
from .ticker import TickerHandler
|
||||
from .ticker import TickerSnapshotHandler
|
||||
from .ticker import TickerUpdateHandler
|
||||
from .trade import TradeHandler
|
||||
from .trade import TradeSnapshotHandler
|
||||
from .trade import TradeUpdateHandler
|
||||
from .update import UpdateHandler
|
||||
|
|
31
python/bbgo/handlers/balance.py
Normal file
31
python/bbgo/handlers/balance.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class BalanceHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.BALANCE:
|
||||
return
|
||||
|
||||
super(BalanceHandler, self).__call__(event)
|
||||
|
||||
|
||||
class BalanceSnapshotHandler(BalanceHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(BalanceSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class BalanceUpdateHandler(BalanceHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(BalanceUpdateHandler, self).__call__(event)
|
31
python/bbgo/handlers/book.py
Normal file
31
python/bbgo/handlers/book.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class BookHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.BOOK:
|
||||
return
|
||||
|
||||
super(BookHandler, self).__call__(event)
|
||||
|
||||
|
||||
class BookSnapshotHandler(BookHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(BookSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class BookUpdateHandler(BookHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(BookUpdateHandler, self).__call__(event)
|
31
python/bbgo/handlers/kline.py
Normal file
31
python/bbgo/handlers/kline.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class KLineHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.KLINE:
|
||||
return
|
||||
|
||||
super(KLineHandler, self).__call__(event)
|
||||
|
||||
|
||||
class KLineSnapshotHandler(KLineHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(KLineSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class KLineUpdateHandler(KLineHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(KLineUpdateHandler, self).__call__(event)
|
31
python/bbgo/handlers/order.py
Normal file
31
python/bbgo/handlers/order.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class OrderHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.ORDER:
|
||||
return
|
||||
|
||||
super(OrderHandler, self).__call__(event)
|
||||
|
||||
|
||||
class OrderSnapshotHandler(OrderHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(OrderSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class OrderUpdateHandler(OrderHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(OrderUpdateHandler, self).__call__(event)
|
12
python/bbgo/handlers/snapshot.py
Normal file
12
python/bbgo/handlers/snapshot.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from ..data import Event
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class SnapshotHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(SnapshotHandler, self).__call__(event)
|
31
python/bbgo/handlers/ticker.py
Normal file
31
python/bbgo/handlers/ticker.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class TickerHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.TICKER:
|
||||
return
|
||||
|
||||
super(TickerHandler, self).__call__(event)
|
||||
|
||||
|
||||
class TickerSnapshotHandler(TickerHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(TickerSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class TickerUpdateHandler(TickerHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(TickerUpdateHandler, self).__call__(event)
|
31
python/bbgo/handlers/trade.py
Normal file
31
python/bbgo/handlers/trade.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ..data import Event
|
||||
from ..enums import ChannelType
|
||||
from ..enums import EventType
|
||||
from .handler import Handler
|
||||
|
||||
|
||||
class TradeHandler(Handler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.channel_type != ChannelType.TRADE:
|
||||
return
|
||||
|
||||
super(TradeHandler, self).__call__(event)
|
||||
|
||||
|
||||
class TradeSnapshotHandler(TradeHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.SNAPSHOT:
|
||||
return
|
||||
|
||||
super(TradeSnapshotHandler, self).__call__(event)
|
||||
|
||||
|
||||
class TradeUpdateHandler(TradeHandler):
|
||||
|
||||
def __call__(self, event: Event) -> None:
|
||||
if event.event_type != EventType.UPDATE:
|
||||
return
|
||||
|
||||
super(TradeUpdateHandler, self).__call__(event)
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "bbgo"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
description = ""
|
||||
authors = ["なるみ <weaper@gmail.com>"]
|
||||
packages = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user