Beispiel #1
0
    def get_returns_for_optimisation(
            self, instrument_code: str) -> returnsForOptimisationWithCosts:
        """
        Get pandl for forecasts for a given rule
        THese will include both gross and net returns, in case we do any pooling

        KEY INPUT

        :param instrument_code:
        :type str:

        :returns: accountCurveGroup object

        """
        accounts = self.accounts_stage

        if accounts is missing_data:
            error_msg = (
                "You need an accounts stage in the system to estimate forecast weights"
            )
            self.log.critical(error_msg)
            raise Exception(error_msg)

        cheap_rule_list = self.cheap_trading_rules(instrument_code)
        pandl = accounts.pandl_for_instrument_rules_unweighted(
            instrument_code, cheap_rule_list)

        pandl = returnsForOptimisationWithCosts(pandl)

        return pandl
Beispiel #2
0
    def returns_pre_processor(self) -> returnsPreProcessor:

        instrument_list = self.get_instrument_list(for_instrument_weights=True)
        pandl_across_subsystems_raw = self.pandl_across_subsystems(
            instrument_list=instrument_list
        )
        pandl_across_subsystems_as_returns_object = returnsForOptimisationWithCosts(
            pandl_across_subsystems_raw
        )
        pandl_across_subsystems = dictOfReturnsForOptimisationWithCosts(
            pandl_across_subsystems_as_returns_object
        )

        turnovers = self.turnover_across_subsystems()
        config = self.config

        weighting_params = copy(config.instrument_weight_estimate)

        returns_pre_processor = returnsPreProcessor(
            pandl_across_subsystems,
            turnovers=turnovers,
            log=self.log,
            **weighting_params
        )

        return returns_pre_processor