Exemplo n.º 1
0
    def __init__(self,
                 wrapper: ArrayWrapper,
                 records_arr: tp.RecordArray,
                 close: tp.ArrayLike,
                 idx_field: str = 'exit_idx',
                 trade_type: int = TradeType.Trade,
                 **kwargs) -> None:
        Records.__init__(self,
                         wrapper,
                         records_arr,
                         idx_field=idx_field,
                         close=close,
                         trade_type=trade_type,
                         **kwargs)
        self._close = broadcast_to(close, wrapper.dummy(group_by=False))
        self._trade_type = trade_type

        if trade_type == TradeType.Trade:
            if not all(field in records_arr.dtype.names
                       for field in trade_dt.names):
                raise TypeError("Records array must match trade_dt")
        else:
            if not all(field in records_arr.dtype.names
                       for field in position_dt.names):
                raise TypeError("Records array must match position_dt")
Exemplo n.º 2
0
    def __init__(self,
                 wrapper: ArrayWrapper,
                 records_arr: tp.RecordArray,
                 ts: tp.ArrayLike,
                 idx_field: str = 'end_idx',
                 **kwargs) -> None:
        Records.__init__(self,
                         wrapper,
                         records_arr,
                         idx_field=idx_field,
                         ts=ts,
                         **kwargs)
        self._ts = broadcast_to(ts, wrapper.dummy(group_by=False))

        if not all(field in records_arr.dtype.names
                   for field in drawdown_dt.names):
            raise TypeError("Records array must match drawdown_dt")
Exemplo n.º 3
0
    def __init__(self,
                 wrapper: ArrayWrapper,
                 records_arr: tp.RecordArray,
                 close: tp.ArrayLike,
                 idx_field: str = 'idx',
                 **kwargs) -> None:
        Records.__init__(self,
                         wrapper,
                         records_arr,
                         idx_field=idx_field,
                         close=close,
                         **kwargs)
        self._close = broadcast_to(close, wrapper.dummy(group_by=False))

        if not all(field in records_arr.dtype.names
                   for field in order_dt.names):
            raise TypeError("Records array must match order_dt")