mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Add user data service
This commit is contained in:
parent
dbb3da97e5
commit
8e601a5cde
|
@ -1,3 +1,4 @@
|
|||
from .bbgo import MarketService
|
||||
from .bbgo import TradingService
|
||||
from .services import MarketService
|
||||
from .services import TradingService
|
||||
from .services import UserDataService
|
||||
from .stream import Stream
|
||||
|
|
|
@ -4,6 +4,15 @@ from . import bbgo_pb2
|
|||
from . import bbgo_pb2_grpc
|
||||
|
||||
|
||||
class UserDataService(object):
|
||||
|
||||
def __init__(self, stub: bbgo_pb2_grpc.UserDataServiceStub):
|
||||
self.stub = stub
|
||||
|
||||
def subscribe_user_data(self):
|
||||
return self.stub.SubscribeUserData(bbgo_pb2.Empty())
|
||||
|
||||
|
||||
class MarketService(object):
|
||||
|
||||
def __init__(self, stub: bbgo_pb2_grpc.MarketDataServiceStub):
|
|
@ -1,37 +1,9 @@
|
|||
import random
|
||||
import time
|
||||
|
||||
from bbgo import bbgo_pb2
|
||||
from bbgo import bbgo_pb2_grpc
|
||||
|
||||
|
||||
class TestTradingServicer(bbgo_pb2_grpc.TradingServiceServicer):
|
||||
|
||||
def Subcribe(self, request, context):
|
||||
i = 0
|
||||
while True:
|
||||
for subscription in request.subscriptions:
|
||||
yield bbgo_pb2.SubscribeResponse(
|
||||
channel=subscription.channel,
|
||||
event=bbgo_pb2.Event.UPDATE,
|
||||
exchange=subscription.exchange,
|
||||
symbol=subscription.symbol + f'_{i}',
|
||||
)
|
||||
i += 1
|
||||
time.sleep(random.random())
|
||||
|
||||
def SubcribeUserData(self, request, context):
|
||||
i = 0
|
||||
while True:
|
||||
yield bbgo_pb2.SubscribeResponse(
|
||||
channel=bbgo_pb2.Channel.USER,
|
||||
event=bbgo_pb2.Event.ORDER_UPDATE,
|
||||
exchange='max',
|
||||
symbol=f'user_{i}',
|
||||
)
|
||||
i += 1
|
||||
time.sleep(random.random())
|
||||
|
||||
def SubmitOrder(self, request, context):
|
||||
submit_order = request.submit_order
|
||||
|
||||
|
@ -50,18 +22,3 @@ class TestTradingServicer(bbgo_pb2_grpc.TradingServiceServicer):
|
|||
error = bbgo_pb2.Error(error_code=0, error_message='')
|
||||
|
||||
return bbgo_pb2.SubmitOrderResponse(order=order, error=error)
|
||||
|
||||
def CancelOrder(self, request, context):
|
||||
pass
|
||||
|
||||
def QueryOrder(self, request, context):
|
||||
pass
|
||||
|
||||
def QueryOrders(self, request, context):
|
||||
pass
|
||||
|
||||
def QueryTrades(self, request, context):
|
||||
pass
|
||||
|
||||
def QueryKLines(self, request, context):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user