Merge branch 'pr/427' into development

This commit is contained in:
Kevin Johnson
2021-11-27 14:57:50 -08:00
2 changed files with 5 additions and 2 deletions
+2
View File
@@ -77,6 +77,8 @@ def cross(series_a: Series, series_b: Series, above: bool = True, asint: bool =
previous = series_a.shift(1) < series_b.shift(1) # previous is below
# above if both are true, below if both are false
cross = current & previous if above else ~current & ~previous
# ensure there is no cross on the first entry
cross[0] = False
if asint:
cross = cross.astype(int)
+3 -2
View File
@@ -2,7 +2,6 @@ from .config import sample_data
from .context import pandas_ta
from unittest import skip, TestCase
from unittest.mock import patch
import numpy as np
import numpy.testing as npt
@@ -139,6 +138,9 @@ class TestUtilities(TestCase):
self.assertIsInstance(result, Series)
npt.assert_array_equal(result, self.crosseddf["crossed"])
result = self.utils.cross(self.crosseddf["a"], self.crosseddf["b"], above=False)
self.assertFalse(result[0])
def test_df_dates(self):
result = self.utils.df_dates(self.data)
self.assertEqual(None, result)
@@ -184,7 +186,6 @@ class TestUtilities(TestCase):
npt.assert_allclose(self.utils.fibonacci(n=5, zero=True, weighted=True), np.array([0, 1 / 12, 1 / 12, 1 / 6, 1 / 4, 5 / 12]))
npt.assert_allclose(self.utils.fibonacci(n=5, zero=False, weighted=True), np.array([1 / 12, 1 / 12, 1 / 6, 1 / 4, 5 / 12]))
def test_geometric_mean(self):
returns = pandas_ta.percent_return(self.data.close)
result = self.utils.geometric_mean(returns)