def get_chart_data_params(self, period, window): window_end = int(time.time()) seconds = convert_period_into_seconds(period) optimum_period = int(PoloniexHttpAPI.optimum_period(seconds)) window_start = int( np.ceil( (window_end - seconds * (window + self.offset)) / optimum_period) * optimum_period) return optimum_period, window_start, window_end
def test_optimum_period_for_5m(self): sec = convert_period_into_seconds('5m') optimum = PoloniexHttpAPI.optimum_period(sec) self.assertEqual(optimum, 300)
def test_convert_period_into_seconds_is_never_zero(self): sec = convert_period_into_seconds('155d') self.assertIsNot(sec, 0)
def test_convert_invalid_value_into_seconds(self): with self.assertRaises(ValueError): sec = convert_period_into_seconds('abc')
def test_convert_2d_into_seconds(self): sec = convert_period_into_seconds('2d') self.assertEqual(sec, 172800)
def test_convert_2h_into_seconds(self): sec = convert_period_into_seconds('2h') self.assertEqual(sec, 7200)
def test_convert_25_minutes_into_seconds(self): sec = convert_period_into_seconds('25m') self.assertEqual(sec, 1500)
def test_convert_raises_value_error_if_minutes_not_multiple_of_5(self): with self.assertRaises(ValueError): convert_period_into_seconds('7m')