Beispiel #1
0
    def _load_results_data(cls):
        excel_importer = ExcelImporter()  # type: ExcelImporter
        input_data_path = join(dirname(__file__),
                               'test_portfolio_base_results.xlsx')
        cls.rets_for_fully_invested_const_weights = excel_importer.import_container(
            input_data_path,
            'D5',
            'D508',
            SimpleReturnsSeries,
            sheet_name='returns',
            include_index=False)
        cls.rets_for_not_fully_invested_const_weights = excel_importer.import_container(
            input_data_path,
            'J5',
            'J508',
            SimpleReturnsSeries,
            sheet_name='returns',
            include_index=False)
        cls.rets_for_fully_invested_drift_weights = excel_importer.import_container(
            input_data_path,
            'E5',
            'E508',
            SimpleReturnsSeries,
            sheet_name='returns',
            include_index=False)
        cls.rets_for_not_fully_invested_drift_weights = excel_importer.import_container(
            input_data_path,
            'K5',
            'K508',
            SimpleReturnsSeries,
            sheet_name='returns',
            include_index=False)
        cls.alloc_for_not_fully_invested_drift_weights = excel_importer.import_container(
            input_data_path,
            'C4',
            'V507',
            QFDataFrame,
            sheet_name='drifting weights - alloc 75%',
            include_index=False)
        cls.alloc_for_fully_invested_drift_weights = excel_importer.import_container(
            input_data_path,
            'C4',
            'V507',
            QFDataFrame,
            sheet_name='drifting weights - alloc 100%',
            include_index=False)

        # set proper index for all of the loaded results
        for returns_tms in [
                cls.rets_for_fully_invested_const_weights,
                cls.rets_for_not_fully_invested_const_weights,
                cls.rets_for_fully_invested_drift_weights,
                cls.rets_for_not_fully_invested_drift_weights,
                cls.alloc_for_not_fully_invested_drift_weights,
                cls.alloc_for_fully_invested_drift_weights
        ]:
            returns_tms.index = assets_df.index.copy()
Beispiel #2
0
    def setUp(self):
        dates = DatetimeIndex(date_range(start='2014-01-01', freq='d', periods=10))
        returns = np.arange(0, 1, 0.1)
        self.test_series = QFSeries(index=dates, data=returns)

        reversed_returns = returns[::-1]
        test_series_reversed = QFSeries(index=dates, data=reversed_returns)

        self.test_data_frame = concat([self.test_series, test_series_reversed], axis=1, join='inner')

        self.xl_importer = ExcelImporter()
Beispiel #3
0
def import_data(frequency: Frequency, file_path: str):
    xlsx = ExcelImporter()
    df = xlsx.import_container(file_path,
                               'A1',
                               'J1888',
                               sheet_name="Data",
                               include_index=True,
                               include_column_names=True)
    weights = xlsx.import_container(file_path,
                                    'M15',
                                    'N23',
                                    sheet_name="Data",
                                    include_index=True,
                                    include_column_names=False)

    simple_ret_df = DataFrame()
    for column in df:
        prices = PricesSeries(df[column])
        simple_returns = get_aggregate_returns(prices, frequency)
        simple_ret_df[column] = simple_returns

    return simple_ret_df, weights
Beispiel #4
0
def _get_assets_df():
    input_data_path = join(dirname(__file__), 'test_data.xlsx')
    excel_importer = ExcelImporter()
    return excel_importer.import_container(input_data_path, 'A2', 'U505',
                                           SimpleReturnsDataFrame)