bbgo_origin/python/examples/subscribe_user_data.py

25 lines
545 B
Python
Raw Normal View History

2022-04-15 07:35:29 +00:00
import grpc
from loguru import logger
import bbgo_pb2
import bbgo_pb2_grpc
from bbgo.data import UserDataEvent
def main():
host = '127.0.0.1'
port = 50051
address = f'{host}:{port}'
channel = grpc.insecure_channel(address)
stub = bbgo_pb2_grpc.UserDataServiceStub(channel)
request = bbgo_pb2.UserDataRequest(session='max')
response_iter = stub.Subscribe(request)
for response in response_iter:
event = UserDataEvent.from_pb(response)
logger.info(event)
if __name__ == '__main__':
main()