def test_shift_value_array(): array = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float64) np.testing.assert_array_equal( shift_value_array(array, shift_count=-1, fill_value=np.nan), np.array([2, 3, 4, 5, 6, 7, 8, 9, np.nan], dtype=np.float64)) array = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float64) np.testing.assert_array_equal( shift_value_array(array, shift_count=2, fill_value=np.nan), np.array([np.nan, np.nan, 1, 2, 3, 4, 5, 6, 7], dtype=np.float64))
def _add_in_construction_data(candles, symbol_data, time_frame, data_type): try: return np.array(data_util.shift_value_array( candles, fill_value=symbol_data.symbol_klines[time_frame].kline[data_type]), dtype=np.float64) except KeyError: return candles
def _change_current_candle(self): self.close_candles = data_util.shift_value_array( self.close_candles, -1, np.nan, np.float64) self.open_candles = data_util.shift_value_array( self.open_candles, -1, np.nan, np.float64) self.high_candles = data_util.shift_value_array( self.high_candles, -1, np.nan, np.float64) self.low_candles = data_util.shift_value_array(self.low_candles, -1, np.nan, np.float64) self.volume_candles = data_util.shift_value_array( self.volume_candles, -1, np.nan, np.float64) self.time_candles = data_util.shift_value_array( self.time_candles, -1, np.nan, np.float64)
def _change_current_candle(self): self.close_candles = shift_value_array(self.close_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64) self.open_candles = shift_value_array(self.open_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64) self.high_candles = shift_value_array(self.high_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64) self.low_candles = shift_value_array(self.low_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64) self.volume_candles = shift_value_array(self.volume_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64) self.time_candles = shift_value_array(self.time_candles, -1, self.MAX_CANDLES_COUNT, np.nan, np.float64)
def _add_in_construction_data(candles, symbol_data, time_frame, data_type): return np.array(shift_value_array( candles, fill_value=symbol_data.symbol_klines[time_frame].kline[data_type]), dtype=np.float64)