bbgo_origin/python
2022-04-13 23:27:44 +08:00
..
bbgo python: remove some enums 2022-04-13 23:20:57 +08:00
tests python: remove grpc test cases 2022-04-13 23:27:44 +08:00
.gitignore Add python gitignore 2022-03-15 18:40:53 +08:00
bbgo_pb2_grpc.py python: update grpc code 2022-04-13 23:22:13 +08:00
bbgo_pb2.py python: update grpc code 2022-04-13 23:22:13 +08:00
poetry.lock Add grpc client 2022-03-15 18:43:57 +08:00
pyproject.toml Move bbgo_pb2 files and add them to packages 2022-04-10 02:04:06 +08:00
query_klines.py python: fix lint 2022-04-13 23:20:57 +08:00
README.md python: update README.md 2022-04-13 23:25:23 +08:00
setup.cfg Add grpc client 2022-03-15 18:43:57 +08:00
stream.py python: simplify event handler 2022-04-13 23:20:57 +08:00
subscribe.py python: fix market service 2022-04-13 23:20:57 +08:00

pybbgo

Installation

cd <path/to/bbgo/python>
pip install .

Usage

Stream

from loguru import logger

from bbgo import Stream
from bbgo.data import Event
from bbgo.handlers import UpdateHandler


class LogBook(UpdateHandler):

    def handle(self, event: Event) -> None:
        logger.info(event)


host = '127.0.0.1'
port = 50051

stream = Stream(host, port)
stream.subscribe('max', 'book', 'BTCUSDT', 'full')
stream.subscribe('max', 'book', 'ETHUSDT', 'full')
stream.add_event_handler(LogBook())
stream.start()