def failure(error: ApiException) -> None: """ The responsibility of this function is to handle a failed API call :param ApiException error: The error from the API call :return: None """ lpt.display_error(error) exit()
def test_aggregate_holdings(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") qah.process_args( self.api, qah.parse( args=[ "Finbourne-Examples", "Global-Equity", "2020-01-01", "--pricing-scope", "Finbourne-Examples", "--recipe", "FinbourneExamplesRecipeMidThenBid", "--properties", "Instrument/JLH/AssetClass", "Instrument/JLH/Sector", "Instrument/JLH/AssetType", ] ), ).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertIsInstance(right, DataFrame), )
def test_get_holdings(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") # Query Portfolio JLH3 qh.process_args(self.api, qh.parse(args=["JLH", "JLH3", "-t"])).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertIsInstance(right, DataFrame), )
def finished(error=None): if error is not None: lpt.display_error(error) if len(records) == 0: print("No results") exit(-1) df = pd.DataFrame.from_records(records) leading_cols = ["#", "Start-Time", "Date", "PV", "Duration", "LUSID", "Id"] cols = set(df.columns.values) other_cols = list(sorted(cols - set(leading_cols))) for col in other_cols: df[col] = df[col].fillna(0).astype(int) return lpt.trim_df(df[leading_cols + other_cols], args.limit)
def test_reconcile_holdings(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") qrh.process_args( self.api, qrh.parse(args=["JLH", "JLH1", "2020-01-01", "JLH", "JLH3", "2020-01-01"]), ).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertIsInstance(right, DataFrame), )
def test_create_properties(self): # Create Properties result = cp.process_args( self.api, cp.parse(args=[ "--prop", "Transaction/JLH/sub-acct", "Transaction/JLH/account", "Holding/JLH/prop1", "Holding/JLH/prop2", ]), ) if result is not None: result.if_left(lambda left: self.fail(lpt.display_error(left)))
def test_upload_multiple_transaction(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") # Load JLH2 and JLH3 Transactions from second sheet from example Excel file up.process_args( self.api, up.parse(args=[ "JLH", "col:portfolio-code", # col: prefix indicates code is in the sheet "-t", f"{self.test_data_path.joinpath('examples').joinpath('transactions-examples.xlsx:Multiple')}", ]), ).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertEqual(right, "Done!"), )
def test_upload_transactions(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") # Load JLH1 Transactions from first sheet from example Excel file up.process_args( self.api, up.parse(args=[ "JLH", "JLH1", "-t", f"{self.test_data_path.joinpath('examples').joinpath('transactions-examples.xlsx')}", ]), ).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertEqual(right, "Done!"), )
def test_upload_holding(self): if not self.target_portfolios_exist(): self.skipTest("missing target portfolios") up.process_args( self.api, up.parse(args=[ "JLH", "JLH1", "-p", f"{self.test_data_path.joinpath('examples').joinpath('holdings-examples.xlsx')}", "2019-01-01", ]), ).match( lambda left: self.fail(lpt.display_error(left)), lambda right: self.assertEqual(right, "Done!"), )
def failure(error): lpt.display_error(error) exit()