def persist_curves(self, asset_manager_id, business_date, curves, update_existing_curves=True): """ :param asset_manager_id: :param business_date: :param curves: :param update_existing_rates: :return: """ self.logger.info( 'Persist curves - Asset Manager: %s - Business Date: %s', asset_manager_id, business_date) url = '%s/curves/%s/%s' % (self.endpoint, asset_manager_id, business_date.isoformat()) params = {'update_existing_curves': update_existing_curves} curves_json = [curve.to_interface() for curve in curves] response = self.session.post(url, params=params, json=curves_json) if response.ok: curves = [json_to_curve(curve) for curve in response.json()] return curves else: self.logger.error(response.text) response.raise_for_status()
def retrieve_curve(self, asset_manager_id, business_date, asset_ids = None): self.logger.info('Retrieve curve - Asset Manager: %s - Business Date: %s', asset_manager_id, business_date) url = '%s/curves/%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: curves = [json_to_curve(curve) for curve in response.json() ] self.logger.info('Returned %s curves.', len(curves)) return curves else: self.logger.error(response.text) response.raise_for_status()