bbgo_origin/python/examples/subscribe.py

26 lines
617 B
Python
Raw Permalink Normal View History

2022-04-13 06:52:34 +00:00
import click
2022-04-13 09:40:21 +00:00
from loguru import logger
2022-04-13 06:52:34 +00:00
from bbgo import MarketService
2022-04-13 09:40:21 +00:00
from bbgo.data import Subscription
from bbgo.enums import ChannelType
from bbgo.enums import DepthType
2022-04-13 06:52:34 +00:00
@click.command()
@click.option('--host', default='127.0.0.1')
@click.option('--port', default=50051)
def main(host, port):
2022-04-13 09:40:21 +00:00
subscriptions = [
Subscription('binance', ChannelType.BOOK, symbol='BTCUSDT', depth=DepthType.FULL),
]
2022-04-13 06:52:34 +00:00
2022-04-14 08:06:36 +00:00
service = MarketService(host, port)
2022-04-13 09:40:21 +00:00
response_iter = service.subscribe(subscriptions)
for response in response_iter:
logger.info(response)
2022-04-13 06:52:34 +00:00
if __name__ == '__main__':
main()