mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
python: move examples
This commit is contained in:
parent
c9792e21ee
commit
42aab0cfbb
24
python/examples/subscribe_user_data.py
Normal file
24
python/examples/subscribe_user_data.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
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()
|
Loading…
Reference in New Issue
Block a user