def __create_instrument_request(self, correlation_id, symbol=None, market_id=None, exchange=None): ir = openfeed_api_pb2.InstrumentRequest(correlationId=correlation_id, token=self.token, marketId=market_id) if symbol is not None: ir.symbol = symbol if market_id is not None: ir.marketId = market_id if exchange is not None: ir.exchange = exchange return openfeed_api_pb2.OpenfeedGatewayRequest(instrumentRequest=ir)
def __create_subscription_request(self, exchanges=[], symbols=[], service="REAL_TIME", subscription_type=["QUOTE"], snapshot_interval_seconds=60): requests = [] if len(exchanges) > 0: for exch in exchanges: requests.append( openfeed_api_pb2.SubscriptionRequest.Request( exchange=exch, subscriptionType=[ openfeed_api_pb2.SubscriptionType.Value(t) for t in subscription_type ], snapshotIntervalSeconds=snapshot_interval_seconds)) if len(symbols) > 0: for sym in symbols: requests.append( openfeed_api_pb2.SubscriptionRequest.Request( symbol=sym, subscriptionType=[ openfeed_api_pb2.SubscriptionType.Value(t) for t in subscription_type ], snapshotIntervalSeconds=snapshot_interval_seconds)) of_req = openfeed_api_pb2.OpenfeedGatewayRequest( subscriptionRequest=openfeed_api_pb2.SubscriptionRequest( token=self.token, service=openfeed_pb2.Service.Value(service), requests=requests)) return of_req
def __create_login_request(self): return openfeed_api_pb2.OpenfeedGatewayRequest( loginRequest=openfeed_api_pb2.LoginRequest(username=self.username, password=self.password))
def __create_instrument_reference_request(self, correlation_id, exchange): return openfeed_api_pb2.OpenfeedGatewayRequest( instrumentReferenceRequest=openfeed_api_pb2. InstrumentReferenceRequest(correlationId=correlation_id, token=self.token, exchange=exchange))
def __create_exchange_request(self, correlation_id): return openfeed_api_pb2.OpenfeedGatewayRequest( exchangeRequest=openfeed_api_pb2.ExchangeRequest( correlationId=correlation_id, token=self.token))