def indexing_func(self: DrawdownsT, pd_indexing_func: tp.PandasIndexingFunc, **kwargs) -> DrawdownsT: """Perform indexing on `Drawdowns`.""" new_wrapper, new_records_arr, _, col_idxs = \ Records.indexing_func_meta(self, pd_indexing_func, **kwargs) new_ts = new_wrapper.wrap(self.ts.values[:, col_idxs], group_by=False) return self.copy(wrapper=new_wrapper, records_arr=new_records_arr, ts=new_ts)
def indexing_func_meta( self: OrdersT, pd_indexing_func: tp.PandasIndexingFunc, **kwargs) -> tp.Tuple[OrdersT, tp.MaybeArray, tp.Array1d]: """Perform indexing on `Orders` and return metadata.""" new_wrapper, new_records_arr, group_idxs, col_idxs = \ Records.indexing_func_meta(self, pd_indexing_func, **kwargs) new_close = new_wrapper.wrap(to_2d(self.close, raw=True)[:, col_idxs], group_by=False) return self.copy(wrapper=new_wrapper, records_arr=new_records_arr, close=new_close), group_idxs, col_idxs
def indexing_func(self: RangesT, pd_indexing_func: tp.PandasIndexingFunc, **kwargs) -> RangesT: """Perform indexing on `Ranges`.""" new_wrapper, new_records_arr, _, col_idxs = \ Records.indexing_func_meta(self, pd_indexing_func, **kwargs) if self.ts is not None: new_ts = new_wrapper.wrap(self.ts.values[:, col_idxs], group_by=False) else: new_ts = None return self.replace(wrapper=new_wrapper, records_arr=new_records_arr, ts=new_ts)
def indexing_func(self: OrdersT, pd_indexing_func: tp.PandasIndexingFunc, **kwargs) -> OrdersT: """Perform indexing on `Orders`.""" new_wrapper, new_records_arr, group_idxs, col_idxs = \ Records.indexing_func_meta(self, pd_indexing_func, **kwargs) if self.close is not None: new_close = new_wrapper.wrap(to_2d_array(self.close)[:, col_idxs], group_by=False) else: new_close = None return self.replace( wrapper=new_wrapper, records_arr=new_records_arr, close=new_close )