Пример #1
0
    def get_all_forecasts_for_a_list_of_instruments(self,
                                                    codes_to_use: list) -> listOfDataFrames:
        forecast_data = listOfDataFrames([
            self.get_all_forecasts(instr_code, self.get_trading_rule_list(instr_code))
            for instr_code in codes_to_use
        ])

        return forecast_data
Пример #2
0
    def _get_portfolio_risk_given_positions(
            self, positions: pd.DataFrame) -> pd.Series:
        weight_per_position = (
            self.portfolio_weights_stage.
            get_per_contract_value_as_proportion_of_capital_df())
        portfolio_weights = listOfDataFrames([weight_per_position,
                                              positions]).fill_and_multipy()

        return self._get_portfolio_risk_given_weights(portfolio_weights)
Пример #3
0
    def single_resampled_set_of_returns(self, frequency: str) -> returnsForOptimisation:

        returns_as_list = listOfDataFrames(self.values())
        pooled_length = len(returns_as_list)

        returns_as_list_downsampled = returns_as_list.resample_sum(frequency)
        returns_as_list_common_ts = returns_as_list_downsampled.reindex_to_common_index()

        returns_for_optimisation = returns_as_list_common_ts.stacked_df_with_added_time_from_list()
        returns_for_optimisation = returnsForOptimisation(returns_for_optimisation,
                                                          frequency = frequency,
                                                          pooled_length=pooled_length)

        return returns_for_optimisation