def stream(self, accountID, **kwargs): """ Get a stream of Prices for an Account starting from when the request is made. Args: accountID: Account Identifier instruments: List of Instruments to stream Prices for. snapshot: Flag that enables/disables the sending of a pricing snapshot when initially connecting to the stream. Returns: v20.response.Response containing the results from submitting the request """ request = Request('GET', '/v3/accounts/{accountID}/pricing/stream') request.set_path_param('accountID', accountID) request.set_param('instruments', kwargs.get('instruments')) request.set_param('snapshot', kwargs.get('snapshot')) request.set_stream(True) class Parser(): def __init__(self, ctx): self.ctx = ctx def __call__(self, line): j = json.loads(line.decode('utf-8')) type = j.get("type") if type is None: return ("pricing.Price", self.ctx.pricing.Price.from_dict(j, self.ctx)) elif type == "HEARTBEAT": return ("pricing.PricingHeartbeat", self.ctx.pricing.PricingHeartbeat.from_dict( j, self.ctx)) return ("pricing.Price", self.ctx.pricing.Price.from_dict(j, self.ctx)) request.set_line_parser(Parser(self.ctx)) response = self.ctx.request(request) return response
def stream(self, accountID, **kwargs): """ Get a stream of Account Prices starting from when the request is made. This pricing stream does not include every single price created for the Account, but instead will provide at most 4 prices per second (every 250 milliseconds) for each instrument being requested. If more than one price is created for an instrument during the 250 millisecond window, only the price in effect at the end of the window is sent. This means that during periods of rapid price movement, subscribers to this stream will not be sent every price. Pricing windows for different connections to the price stream are not all aligned in the same way (i.e. they are not all aligned to the top of the second). This means that during periods of rapid price movement, different subscribers may observe different prices depending on their alignment. Args: accountID: Account Identifier instruments: List of Instruments to stream Prices for. snapshot: Flag that enables/disables the sending of a pricing snapshot when initially connecting to the stream. Returns: v20.response.Response containing the results from submitting the request """ request = Request('GET', '/v3/accounts/{accountID}/pricing/stream') request.set_path_param('accountID', accountID) request.set_param('instruments', kwargs.get('instruments')) request.set_param('snapshot', kwargs.get('snapshot')) request.set_stream(True) class Parser(): def __init__(self, ctx): self.ctx = ctx def __call__(self, line): j = json.loads(line.decode('utf-8')) type = j.get("type") if type is None: return ("pricing.ClientPrice", self.ctx.pricing.ClientPrice.from_dict( j, self.ctx)) elif type == "HEARTBEAT": return ("pricing.PricingHeartbeat", self.ctx.pricing.PricingHeartbeat.from_dict( j, self.ctx)) return ("pricing.ClientPrice", self.ctx.pricing.ClientPrice.from_dict(j, self.ctx)) request.set_line_parser(Parser(self.ctx)) response = self.ctx.request(request) return response
def stream( self, accountID, **kwargs ): """Price Stream Get a stream of Prices for an Account starting from when the request is made. Parameters ---------- accountID : ID of the Account to stream Prices for. instruments : array, optional List of Instruments to stream Prices for. snapshot : , optional Flag that enables/disables the sending of a pricing snapshot when initially connecting to the stream. """ request = Request( 'GET', '/v3/accounts/{accountID}/pricing/stream' ) request.set_path_param( 'accountID', accountID ) request.set_param( 'instruments', kwargs.get('instruments') ) request.set_param( 'snapshot', kwargs.get('snapshot') ) request.set_stream(True) class Parser(): def __init__(self, ctx): self.ctx = ctx def __call__(self, line): j = json.loads(line) type = j.get("type") if type is None: return ( "pricing.Price", self.ctx.pricing.Price.from_dict(j) ) elif type == "HEARTBEAT": return ( "pricing.Heartbeat", self.ctx.pricing.Heartbeat.from_dict(j) ) return ( "pricing.Price", self.ctx.pricing.Price.from_dict(j) ) request.set_line_parser( Parser(self.ctx) ) response = self.ctx.request(request) return response
def stream( self, accountID, **kwargs ): """ Get a stream of Account Prices starting from when the request is made. This pricing stream does not include every single price created for the Account, but instead will provide at most 4 prices per second (every 250 milliseconds) for each instrument being requested. If more than one price is created for an instrument during the 250 millisecond window, only the price in effect at the end of the window is sent. This means that during periods of rapid price movement, subscribers to this stream will not be sent every price. Pricing windows for different connections to the price stream are not all aligned in the same way (i.e. they are not all aligned to the top of the second). This means that during periods of rapid price movement, different subscribers may observe different prices depending on their alignment. Args: accountID: Account Identifier instruments: List of Instruments to stream Prices for. snapshot: Flag that enables/disables the sending of a pricing snapshot when initially connecting to the stream. Returns: v20.response.Response containing the results from submitting the request """ request = Request( 'GET', '/v3/accounts/{accountID}/pricing/stream' ) request.set_path_param( 'accountID', accountID ) request.set_param( 'instruments', kwargs.get('instruments') ) request.set_param( 'snapshot', kwargs.get('snapshot') ) request.set_stream(True) class Parser(): def __init__(self, ctx): self.ctx = ctx def __call__(self, line): j = json.loads(line.decode('utf-8')) type = j.get("type") if type is None: return ( "pricing.ClientPrice", self.ctx.pricing.ClientPrice.from_dict(j, self.ctx) ) elif type == "HEARTBEAT": return ( "pricing.PricingHeartbeat", self.ctx.pricing.PricingHeartbeat.from_dict(j, self.ctx) ) return ( "pricing.ClientPrice", self.ctx.pricing.ClientPrice.from_dict(j, self.ctx) ) request.set_line_parser( Parser(self.ctx) ) response = self.ctx.request(request) return response