Пример #1
0
    def _convert_tuple_to_market_trade(self, market_trade_order_tuple):
        volatile_cache = Mediator.get_volatile_cache(volatile_cache_engine=self._volatile_cache_engine)

        # Gather market and trade/order data (which might be stored in a list)
        if isinstance(market_trade_order_tuple, list):
            market_df_list = []
            trade_order_holder = DataFrameHolder()

            for market_df_single, trade_order_holder_single in market_trade_order_tuple:
                market_df_list.append(market_df_single)

                trade_order_holder.add_dataframe_holder(trade_order_holder_single)

            market_df_list = volatile_cache.get_dataframe_handle(market_df_list, burn_after_reading=True)

            # to ensure that any spurious/None elements are removed
            market_df_list = [x for x in market_df_list if isinstance(x, pd.DataFrame)]

            # want to make sure the data is properly ordered too (not guarenteed we'll get it back in right order)
            market_df = self._time_series_ops.concat_dataframe_list(market_df_list)

        else:
            market_df = volatile_cache.get_dataframe_handle(market_trade_order_tuple[0], burn_after_reading=True)
            trade_order_holder = market_trade_order_tuple[1]

        return market_df, trade_order_holder
Пример #2
0
    def get_trade_order_holder(self, tca_request):
        """Gets the trades/orders in the form of a TradeOrderHolder

        Parameters
        ----------
        tca_request : TCARequest
            Parameters for the TCA computation

        Returns
        -------
        TradeOrderHolder
        """

        tca_ticker_loader = Mediator.get_tca_ticker_loader(
            version=self._version)

        if isinstance(tca_request.ticker, list):
            if len(tca_request.ticker) > 1:
                tca_request_list = self._split_tca_request_into_list(
                    tca_request)

                trade_order_holder = DataFrameHolder()

                for tca_request_single in tca_request_list:
                    trade_order_holder.add_dataframe_holder(
                        tca_ticker_loader(version=self._version).
                        get_trade_order_holder(tca_request_single))

        return tca_ticker_loader(
            version=self._version).get_trade_order_holder(tca_request)
Пример #3
0
    def get_trade_order_holder(self, tca_request):

        tca_ticker_loader = Mediator.get_tca_ticker_loader(
            version=self._version)

        if isinstance(tca_request.ticker, list):
            if len(tca_request.ticker) > 1:
                tca_request_list = self._split_tca_request_into_list(
                    tca_request)

                trade_order_holder = DataFrameHolder()

                for tca_request_single in tca_request_list:
                    trade_order_holder.add_dataframe_holder(
                        tca_ticker_loader(version=self._version).
                        get_trade_order_holder(tca_request_single))

        return tca_ticker_loader(
            version=self._version).get_trade_order_holder(tca_request)