Esempio n. 1
0
    def test_upsert_instruments_with_invalid_mapping(self):

        args = self.invalid_args.copy()
        test_data_root = Path(__file__).parent.joinpath("test_data")
        args["file_path"] = test_data_root.joinpath("instruments.csv")
        args["mapping"] = test_data_root.joinpath("mapping_inst_invalid.json")

        LusidLogger(args["debug"])
        responses = load_instruments(args)

        self.assertEqual(0, len(responses["instruments"]["errors"]))
        self.assertEqual(
            20,
            sum([
                len(response.failed)
                for response in responses["instruments"]["success"]
            ]),
        )
        self.assertEqual(
            0,
            sum([
                len(response.values)
                for response in responses["instruments"]["success"]
            ]),
        )

        LusidLogger("debug")
Esempio n. 2
0
 def setUpClass(cls) -> None:
     LusidLogger(cls.valid_args["debug"])
Esempio n. 3
0
def main(argv):
    args, ap = parse_args(sys.argv[1:])
    LusidLogger(args["debug"])
    load_instruments(args)

    return 0
def main():
    args, ap = parse_args(sys.argv[1:])
    LusidLogger(args["debug"])
    load_transactions(args)

    return 0
def main():
    args, ap = parse_args(sys.argv[1:])
    LusidLogger(args["debug"])
    load_portfolios(args)

    return 0
Esempio n. 6
0
    def setUpClass(cls) -> None:
        test_data_root = Path(__file__).parent.joinpath("test_data")
        cls.mapping_valid = test_data_root.joinpath("mapping.json")
        cls.mapping_invalid = test_data_root.joinpath("mapping_invalid.json")
        cls.valid_instruments = test_data_root.joinpath("instruments.csv")
        cls.cur_dir = os.path.dirname(__file__)
        cls.secrets = Path(__file__).parent.parent.parent.joinpath(
            "secrets.json")
        cls.testscope = "testscope0001"

        cls.valid_args = {
            "file_path": os.path.join(cls.cur_dir, cls.valid_instruments),
            "secrets_file": cls.secrets,
            "mapping": os.path.join(cls.cur_dir, cls.mapping_valid),
            "delimiter": None,
            "scope": cls.testscope,
            "num_header": 0,
            "num_footer": 0,
            "debug": "debug",
            "batch_size": None,
            "dryrun": False,
            "line_terminator": r"\n",
            "display_response_head": True,
        }

        cls.invalid_args = {
            "file_path": os.path.join(cls.cur_dir, cls.valid_instruments),
            "secrets_file": cls.secrets,
            "mapping": os.path.join(cls.cur_dir, cls.mapping_invalid),
            "delimiter": None,
            "scope": cls.testscope,
            "num_header": 0,
            "num_footer": 0,
            "debug": "debug",
            "batch_size": None,
            "dryrun": False,
            "line_terminator": r"\n",
            "display_response_head": True,
        }

        LusidLogger("debug")

        factory = lusid.utilities.ApiClientFactory(
            api_secrets_filename=cls.secrets)
        portfolios_api = factory.build(PortfoliosApi)
        portfolios_response = portfolios_api.list_portfolios_for_scope(
            scope=cls.testscope)

        existing_portfolios = [
            portfolio.id.code for portfolio in portfolios_response.values
        ]
        test_list = ["Global-Strategies", "GlobalCreditFund"]

        if not all(x in existing_portfolios for x in test_list):
            transactions_portfolio_api = factory.build(
                TransactionPortfoliosApi)
            for portfolio in test_list:
                if portfolio not in existing_portfolios:
                    transaction_portfolio_request1 = lusid.models.CreateTransactionPortfolioRequest(
                        display_name=portfolio,
                        code=portfolio,
                        base_currency="GBP",
                        created="2018-03-05T12:00:00+00:00",
                    )
                    transactions_portfolio_response1 = transactions_portfolio_api.create_portfolio(
                        scope=cls.testscope,
                        transaction_portfolio=transaction_portfolio_request1,
                    )
                    logging.info(f"created portfolio: {portfolio}")
Esempio n. 7
0
def main(argv):
    args, ap = parse_args(sys.argv[1:])
    LusidLogger(args["debug"])
    load_holdings(args)

    return 0