Beispiel #1
0
    def load_data(self, sid):
        print('txnview load ', sid)
        for ax in self.fig.axes:
            ax.clear()
        datapath = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        datapath = datapath + '/../../pyfolio/tests/test_data/'
        test_returns = pd.read_csv(gzip.open(datapath + 'test_returns.csv.gz'),
                                   index_col=0,
                                   parse_dates=True)
        test_returns = to_series(to_utc(test_returns))
        test_txn = to_utc(
            pd.read_csv(gzip.open(datapath + 'test_txn.csv.gz'),
                        index_col=0,
                        parse_dates=True))
        test_pos = to_utc(
            pd.read_csv(gzip.open(datapath + 'test_pos.csv.gz'),
                        index_col=0,
                        parse_dates=True))
        positions = utils.check_intraday('infer', test_returns, test_pos,
                                         test_txn)

        plotting.plot_turnover(test_returns,
                               test_txn,
                               positions,
                               ax=self.ax_turnover)
        plotting.plot_daily_volume(test_returns,
                                   test_txn,
                                   ax=self.ax_daily_volume)
        try:
            plotting.plot_daily_turnover_hist(test_txn,
                                              positions,
                                              ax=self.ax_turnover_hist)
        except ValueError:
            warnings.warn('Unable to generate turnover plot.', UserWarning)
        plotting.plot_txn_time_hist(test_txn, ax=self.ax_txn_timings)
        for ax in self.fig.axes:
            plt.setp(ax.get_xticklabels(), visible=True)
        self.draw()
Beispiel #2
0
    def load_data(self, sid):
        print('posview load ', sid)
        for ax in self.fig.axes:
            ax.clear()
        datapath = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        datapath = datapath + '/../../pyfolio/tests/test_data/'
        test_returns = pd.read_csv(gzip.open(datapath + 'test_returns.csv.gz'),
                                   index_col=0,
                                   parse_dates=True)
        test_returns = to_series(to_utc(test_returns))
        test_txn = to_utc(
            pd.read_csv(gzip.open(datapath + 'test_txn.csv.gz'),
                        index_col=0,
                        parse_dates=True))
        test_pos = to_utc(
            pd.read_csv(gzip.open(datapath + 'test_pos.csv.gz'),
                        index_col=0,
                        parse_dates=True))

        positions = utils.check_intraday('infer', test_returns, test_pos,
                                         test_txn)
        positions_alloc = pos.get_percent_alloc(positions)
        plotting.plot_exposures(test_returns, positions, ax=self.ax_exposures)
        plotting.plot_holdings(test_returns,
                               positions_alloc,
                               ax=self.ax_holdings)
        plotting.plot_long_short_holdings(test_returns,
                                          positions_alloc,
                                          ax=self.ax_long_short_holdings)
        plotting.plot_gross_leverage(test_returns,
                                     positions,
                                     ax=self.ax_gross_leverage)

        for ax in self.fig.axes:
            plt.setp(ax.get_xticklabels(), visible=True)
        self.draw()
Beispiel #3
0
 def test_check_intraday(self, estimate, returns, positions, transactions,
                         expected):
     detected = check_intraday(estimate, returns, positions, transactions)
     assert_frame_equal(detected, expected)
Beispiel #4
0
 def test_check_intraday(self, estimate, returns,
                         positions, transactions, expected):
     detected = check_intraday(estimate, returns, positions, transactions)
     assert_frame_equal(detected, expected)