Ejemplo n.º 1
0
        def _subsystem_turnover(
                system, instrument_code,  this_stage, roundpositions):

            positions = this_stage.get_subsystem_position(instrument_code)
            average_position_for_turnover=this_stage.get_volatility_scalar(instrument_code)
            
            return turnover(positions, average_position_for_turnover)
    def instrument_turnover(
        self, instrument_code: str, roundpositions: bool = True
    ) -> float:
        """
        Get the annualised turnover for an instrument

        :param instrument_code: instrument to get values for
        :type instrument_code: str

        :param rule_variation_name: rule to get values for
        :type rule_variation_name: str

        :returns: float


        """
        average_position_for_turnover = (
            self.get_average_position_for_instrument_at_portfolio_level(instrument_code)
        )

        positions = self.get_buffered_position(
            instrument_code, roundpositions=roundpositions
        )

        return turnover(positions, average_position_for_turnover)
    def subsystem_turnover(self, instrument_code: str) -> float:
        positions = self.get_subsystem_position(instrument_code)

        average_position_for_turnover = self.get_volatility_scalar(instrument_code)

        subsystem_turnover = turnover(positions, average_position_for_turnover)

        return subsystem_turnover
Ejemplo n.º 4
0
        def _subsystem_turnover(system, instrument_code, this_stage,
                                roundpositions):

            positions = this_stage.get_subsystem_position(instrument_code)
            average_position_for_turnover = this_stage.get_volatility_scalar(
                instrument_code)

            return turnover(positions, average_position_for_turnover)
Ejemplo n.º 5
0
        def _instrument_turnover(
                system, instrument_code,  this_stage, roundpositions):

            average_position_for_turnover=multiply_df_single_column( this_stage.get_volatility_scalar(instrument_code), 
                                                                     this_stage.get_instrument_scaling_factor(instrument_code),
                                                                     ffill=(True, True))
            
            positions = this_stage.get_buffered_position(instrument_code, roundpositions = roundpositions)
            
            return turnover(positions, average_position_for_turnover)
Ejemplo n.º 6
0
        def _forecast_turnover(
                system, instrument_code, rule_variation_name, this_stage):

            forecast = this_stage.get_capped_forecast(
                instrument_code, rule_variation_name)

            average_forecast_for_turnover=system_defaults['average_absolute_forecast']
            turnover_for_SR=turnover(forecast, average_forecast_for_turnover)
            
            return turnover_for_SR
Ejemplo n.º 7
0
        def _forecast_turnover(system, instrument_code, rule_variation_name,
                               this_stage):

            forecast = this_stage.get_capped_forecast(instrument_code,
                                                      rule_variation_name)

            average_forecast_for_turnover = system_defaults[
                'average_absolute_forecast']
            turnover_for_SR = turnover(forecast, average_forecast_for_turnover)

            return turnover_for_SR
Ejemplo n.º 8
0
    def _forecast_turnover_for_individual_instrument(
            self, instrument_code: str, rule_variation_name: str) -> float:

        forecast = self.get_capped_forecast(instrument_code,
                                            rule_variation_name)

        average_forecast_for_turnover = self.average_forecast()

        annual_turnover_for_forecast = turnover(forecast,
                                                average_forecast_for_turnover)

        return annual_turnover_for_forecast
Ejemplo n.º 9
0
        def _instrument_turnover(system, instrument_code, this_stage,
                                 roundpositions):

            average_position_for_turnover = multiply_df_single_column(
                this_stage.get_volatility_scalar(instrument_code),
                this_stage.get_instrument_scaling_factor(instrument_code),
                ffill=(True, True))

            positions = this_stage.get_buffered_position(
                instrument_code, roundpositions=roundpositions)

            return turnover(positions, average_position_for_turnover)
Ejemplo n.º 10
0
    def optimised_turnover_at_portfolio_level(
        self,
        instrument_code: str,
    ) -> float:

        ## assumes we use all capital
        average_position_for_turnover = self.get_volatility_scalar(
            instrument_code)

        ## Using actual capital
        positions = self.get_optimised_position(instrument_code)

        ## Turnover will be at portfolio level, so a small number, but meaningful when added up
        return turnover(positions, average_position_for_turnover)
Ejemplo n.º 11
0
    def subsystem_turnover(self, instrument_code):
        """
        Get the annualised turnover for an instrument subsystem

        :param instrument_code: instrument to get values for
        :type instrument_code: str

        :returns: float


        """

        positions = self.get_aligned_subsystem_position(instrument_code)
        average_position_for_turnover = self.get_aligned_volatility_scalar(
            instrument_code)

        return turnover(positions, average_position_for_turnover)
Ejemplo n.º 12
0
    def subsystem_turnover(self, instrument_code, roundpositions=True):
        """
        Get the annualised turnover for an instrument subsystem

        :param instrument_code: instrument to get values for
        :type instrument_code: str

        :returns: float


        """

        positions = self.get_aligned_subsystem_position(instrument_code)
        average_position_for_turnover = self.get_aligned_volatility_scalar(
            instrument_code)

        return turnover(positions, average_position_for_turnover)
Ejemplo n.º 13
0
    def forecast_turnover_for_list_by_instrument(self, instrument_code_list,
                                                 rule_variation_name):

        forecast_list = [
            self.get_capped_forecast(instrument_code, rule_variation_name)
            for instrument_code in instrument_code_list
        ]

        config = self.parent.config  ## FIX ME CHANGE
        average_forecast_for_turnover = config.average_absolute_forecast

        turnovers = [
            turnover(forecast, average_forecast_for_turnover)
            for forecast in forecast_list
        ]

        return turnovers
Ejemplo n.º 14
0
    def forecast_turnover_for_list(
            self,
            instrument_code_list,
            rule_variation_name):
        """
        Get the average turnover for a rule, over instrument_code_list

        :param instrument_code_list: instruments to get values for
        :type instrument_code_list: list of str

        :param rule_variation_name: rule to get values for
        :type rule_variation_name: str

        :returns: float

        """

        average_forecast_for_turnover = get_default_config_key_value(
            "average_absolute_forecast"
        )

        forecast_list = [
            self.get_capped_forecast(instrument_code, rule_variation_name)
            for instrument_code in instrument_code_list
        ]

        turnovers = [
            turnover(forecast, average_forecast_for_turnover)
            for forecast in forecast_list
        ]

        if len(instrument_code_list) == 1:
            return turnovers[0]

        # weight by length
        forecast_lengths = [len(forecast.index) for forecast in forecast_list]
        total_length = sum(forecast_lengths)
        weighted_turnovers = [
            tover * fc_length / total_length
            for (tover, fc_length) in zip(turnovers, forecast_lengths)
        ]

        avg_turnover = sum(weighted_turnovers)

        return avg_turnover
Ejemplo n.º 15
0
    def forecast_turnover_for_list(self, instrument_code_list,
                                   rule_variation_name):
        """
        Get the average turnover for a rule, over instrument_code_list

        :param instrument_code_list: instruments to get values for
        :type instrument_code_list: list of str

        :param rule_variation_name: rule to get values for
        :type rule_variation_name: str

        :returns: float

        """

        average_forecast_for_turnover = system_defaults[
            'average_absolute_forecast']

        forecast_list = [
            self.get_capped_forecast(instrument_code, rule_variation_name)
            for instrument_code in instrument_code_list
        ]

        turnovers = [
            turnover(forecast, average_forecast_for_turnover)
            for forecast in forecast_list
        ]

        if len(instrument_code_list) == 1:
            return turnovers[0]

        # weight by length
        forecast_lengths = [len(forecast.index) for forecast in forecast_list]
        total_length = sum(forecast_lengths)
        weighted_turnovers = [
            tover * fc_length / total_length
            for (tover, fc_length) in zip(turnovers, forecast_lengths)
        ]

        avg_turnover = sum(weighted_turnovers)

        return avg_turnover
Ejemplo n.º 16
0
    def instrument_turnover(self, instrument_code, roundpositions=True):
        """
        Get the annualised turnover for an instrument

        :param instrument_code: instrument to get values for
        :type instrument_code: str

        :param rule_variation_name: rule to get values for
        :type rule_variation_name: str

        :returns: float


        """
        average_position_for_turnover = self.get_aligned_volatility_scalar(
            instrument_code) * self.get_instrument_scaling_factor(
                instrument_code)

        positions = self.get_buffered_position(instrument_code,
                                               roundpositions=roundpositions)

        return turnover(positions, average_position_for_turnover)
Ejemplo n.º 17
0
    def instrument_turnover(self, instrument_code, roundpositions=True):
        """
        Get the annualised turnover for an instrument

        :param instrument_code: instrument to get values for
        :type instrument_code: str

        :param rule_variation_name: rule to get values for
        :type rule_variation_name: str

        :returns: float


        """
        average_position_for_turnover = self.get_aligned_volatility_scalar(
            instrument_code) * self.get_instrument_scaling_factor(
                instrument_code)

        positions = self.get_buffered_position(
            instrument_code, roundpositions=roundpositions)

        return turnover(positions, average_position_for_turnover)