Пример #1
0
 def position_search(self, asset_manager_id, book_ids=None, account_ids=None,
                     accounting_types=None, asset_ids=None,
                     position_date=None, include_cash=False, 
                     page_no=None, page_size=None):
     self.logger.info('Search Positions - Asset Manager: %s', asset_manager_id)
     search_params = {}
     # Potentially roll into a loop
     if book_ids:
         search_params['book_ids'] = ','.join(book_ids)
     if account_ids:
         search_params['account_ids'] = ','.join(account_ids)
     if accounting_types:
         search_params['accounting_types'] = ','.join(accounting_types)
     if asset_ids:
         search_params['asset_ids'] = ','.join(asset_ids)
     if position_date:
         search_params['position_date'] = position_date
     if include_cash:
         search_params['include_cash'] = include_cash
     if page_no is not None:
         search_params['page_no'] = page_no
     if page_size:
         search_params['page_size'] = page_size
     url = '%s/positions/%s' % (self.endpoint, asset_manager_id)
     response = self.session.get(url, params=search_params)
     if response.ok:
         positions = [json_to_position(json_position) for json_position in response.json()]
         self.logger.info('Returned %s Positions.', len(positions))
         return positions
     else:
         self.logger.error(response.text)
         response.raise_for_status()
Пример #2
0
 def position_search(self, asset_manager_ids=None, book_ids=None, account_ids=None,
                     accounting_types=['Transaction Date'], asset_ids=None, position_date=None):
     self.logger.info('Search Positions - Asset Manager(s): %s', asset_manager_ids)
     url = self.endpoint + '/positions'
     search_params = {}
     # Potentially roll into a loop
     if asset_manager_ids:
         search_params['asset_manager_ids'] = ','.join([str(amid) for amid in asset_manager_ids])
     if book_ids:
         search_params['book_ids'] = ','.join(book_ids)
     if account_ids:
         search_params['account_ids'] = ','.join(account_ids)
     if accounting_types:
         search_params['accounting_types'] = ','.join(accounting_types)
     if asset_ids:
         search_params['asset_ids'] = ','.join(asset_ids)
     if position_date:
         search_params['position_date'] = position_date
     response = self.session.get(url, params=search_params)
     if response.ok:
         positions = [json_to_position(json_position) for json_position in response.json()]
         self.logger.info('Returned %s Positions.', len(positions))
         return positions
     else:
         self.logger.error(response.text)
         response.raise_for_status()
Пример #3
0
 def positions_by_asset_manager_book(self, asset_manager_id, book_id):
     self.logger.info('Retrieve Positions by Asset Manager: %s and Book: %s', asset_manager_id, book_id)
     url = '%s/positions/%s/%s' % (self.endpoint, asset_manager_id, book_id)
     response = self.session.get(url)
     if response.ok:
         positions = [json_to_position(json_position) for json_position in response.json()]
         self.logger.info('Returned %s Positions.', len(positions))
         return positions
     else:
         self.logger.error(response.text)
         response.raise_for_status()
Пример #4
0
 def positions_by_asset_manager(self, asset_manager_id, book_ids=None):
     self.logger.info('Retrieve Positions by Asset Manager: %s', asset_manager_id)
     url = '%s/positions/%s' % (self.endpoint, asset_manager_id)
     params = {'book_ids': ','.join(book_ids)} if book_ids else {}
     response = self.session.get(url, params=params)
     if response.ok:
         positions = [json_to_position(json_position) for json_position in response.json()]
         self.logger.info('Returned %s Positions.', len(positions))
         return positions
     else:
         self.logger.error(response.text)
         response.raise_for_status()
Пример #5
0
 def test_JsonToPosition(self):
     position = generate_position()
     json_position = position.to_json()
     gen_position = json_to_position(json_position)
     self.assertEqual(gen_position, position)