def list( self, accountID, **kwargs ): """List Trades Get a list of Trades for an Account Parameters ---------- accountID : ID of the Account to fetch Trades for. ids : array, optional List of Trade IDs to retrieve. state : , optional The state to filter the requested Trades by. instrument : , optional The instrument to filter the requested Trades by. count : integer, optional The maximum number of Trades to return. beforeID : , optional The maximum Trade ID to return. If not provided the most recent Trades in the Account are returned. """ request = Request( 'GET', '/v3/accounts/{accountID}/trades' ) request.set_path_param( 'accountID', accountID ) request.set_param( 'ids', kwargs.get('ids') ) request.set_param( 'state', kwargs.get('state') ) request.set_param( 'instrument', kwargs.get('instrument') ) request.set_param( 'count', kwargs.get('count') ) request.set_param( 'beforeID', kwargs.get('beforeID') ) response = self.ctx.request(request) if response.content_type is None: return response if not response.content_type.startswith("application/json"): return response jbody = json.loads(response.raw_body) parsed_body = {} if response.status is 200: if jbody.get('trades') is not None: parsed_body['trades'] = [ Trade.from_dict(d) for d in jbody.get('trades') ] if jbody.get('lastTransactionID') is not None: parsed_body['lastTransactionID'] = \ jbody.get('lastTransactionID') if response.status is 401: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') if response.status is 404: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') if response.status is 405: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') response.body = parsed_body return response
def get( self, accountID, **kwargs ): """Current Prices Get pricing information for a specified list of Instruments within an Account. Parameters ---------- accountID : ID of the Account to fetch current Prices for. instruments : array, optional List of Instruments to get pricing for. since : , optional Date/Time filter to apply to the returned prices. Only prices with a time later than this filter will be provided. """ request = Request( 'GET', '/v3/accounts/{accountID}/pricing' ) request.set_path_param( 'accountID', accountID ) request.set_param( 'instruments', kwargs.get('instruments') ) request.set_param( 'since', kwargs.get('since') ) response = self.ctx.request(request) if response.content_type is None: return response if not response.content_type.startswith("application/json"): return response jbody = json.loads(response.raw_body) parsed_body = {} if response.status is 200: if jbody.get('prices') is not None: parsed_body['prices'] = [ Price.from_dict(d) for d in jbody.get('prices') ] if response.status is 400: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') if response.status is 401: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') if response.status is 404: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') if response.status is 405: if jbody.get('errorCode') is not None: parsed_body['errorCode'] = \ jbody.get('errorCode') if jbody.get('errorMessage') is not None: parsed_body['errorMessage'] = \ jbody.get('errorMessage') response.body = parsed_body return response