def persist_fx_rates(self, asset_manager_id, business_date, fx_rates, update_existing_rates=True): """ :param asset_manager_id: :param business_date: The business date for which these are rates. Not really needed, could be derived... :param fx_rates: :param update_existing_rates: :return: """ self.logger.info( 'Persist FX Rates - Asset Manager: %s - Business Date: %s', asset_manager_id, business_date) url = '%s/fx-rates/%s/%s' % (self.endpoint, asset_manager_id, business_date.isoformat()) params = {'update_existing_rates': update_existing_rates} fx_rates_json = [fx_rate.to_interface() for fx_rate in fx_rates] response = self.session.post(url, params=params, json=fx_rates_json) if response.ok: fx_rates = [ json_to_fx_rate(fx_rate) for fx_rate in response.json() ] return fx_rates else: self.logger.error(response.text) response.raise_for_status()
def retrieve_fx_rates(self, asset_manager_id, business_date, asset_ids=None): self.logger.info('Retrieve FX Rates - Asset Manager: %s - Business Date: %s', asset_manager_id, business_date) url = '%s/fx-rates/%s/%s' % (self.endpoint, asset_manager_id, business_date.isoformat()) params = {'asset_ids': ','.join(asset_ids)} if asset_ids else {} response = self.session.get(url=url, params=params) if response.ok: fx_rates = [json_to_fx_rate(fx_rate) for fx_rate in response.json()] self.logger.info('Returned %s FX Rates.', len(fx_rates)) return fx_rates else: self.logger.error(response.text) response.raise_for_status()
def search_fx_rates(self, asset_manager_id, client_ids=None, asset_ids=None, rate_types=None, rate_statuses=None, business_date_start=None, business_date_end=None, rate_timestamp_start=None, rate_timestamp_end=None): self.logger.info('Search FX Rates - Asset Manager: %s', asset_manager_id) url = '%s/fx-rates/%s' % (self.endpoint, asset_manager_id) params = {} if client_ids: params['client_ids'] = ','.join(client_ids) if asset_ids: params['asset_ids'] = ','.join(asset_ids) if rate_types: params['rate_types'] = ','.join(rate_types) if rate_statuses: params['rate_statuses'] = ','.join(rate_statuses) if business_date_start: params['business_date_start'] = business_date_start.date( ).isoformat() if business_date_end: params['business_date_end'] = business_date_end.date().isoformat() if rate_timestamp_start: params['rate_timestamp_start'] = rate_timestamp_start.strftime( '%H:%m:%s') if rate_timestamp_end: params['rate_timestamp_end'] = rate_timestamp_end.strftime( '%H:%m:%s') response = self.session.get(url=url, params=params) if response.ok: fx_rates = [ json_to_fx_rate(fx_rate) for fx_rate in response.json() ] self.logger.info('Returned %s FX Rates.', len(fx_rates)) return fx_rates else: self.logger.error(response.text) response.raise_for_status()