def retrieve_transaction_pnls(self, book_ids, asset_manager_id, business_date, periods=None, page_no=None, page_size=None): self.logger.info('Retrieving Transaction PnL result - Asset Manager: %s - Book IDs: (%s) - Business Date: %s' % \ (asset_manager_id, ', '.join(book_ids), business_date)) url = '%s/transaction_pnls/%s' % (self.endpoint, asset_manager_id) search_params = {'business_date': business_date, 'book_ids': book_ids} if periods: search_params['periods'] = periods if page_no: search_params['page_no'] = page_no if page_size: search_params['page_size'] = page_size response = self.session.get(url, params=search_params) if response.ok: transaction_pnls = [ json_to_transaction_pnl(json_transaction_pnl) for json_transaction_pnl in response.json() ] self.logger.info('Returned %s Transaction PnL results.', len(transaction_pnls)) return transaction_pnls else: self.logger.error(response.text) response.raise_for_status()
def amend_transaction_pnls(self, asset_manager_id, transaction_pnls): self.logger.info('Amend Transaction PnL results for - Asset Manager: %s', asset_manager_id) if not isinstance(transaction_pnls, list): transaction_pnls = [transaction_pnls] transaction_pnl_json = [] for transaction_pnl in transaction_pnls: transaction_pnl_json.append(transaction_pnl.to_interface()) url = '%s/transaction_pnls/%s' % (self.endpoint, asset_manager_id) response = self.session.put(url, json=transaction_pnl_json) if response.ok: transaction_pnls = [] for transaction_pnl_json in response.json(): transaction_pnls.append(json_to_transaction_pnl(transaction_pnl_json)) self.logger.info('Amended %s Transaction PnL records', len(transaction_pnls)) return transaction_pnls else: self.logger.error(response.text) response.raise_for_status()