Skip to content

Commit

Permalink
update parabolic sar tests in a more efficient way
Browse files Browse the repository at this point in the history
  • Loading branch information
bukosabino committed Nov 28, 2019
1 parent b3eddeb commit d11107c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ta/tests/trend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import unittest

import pandas as pd

from ta.tests.utils import TestIndicator
Expand Down Expand Up @@ -143,33 +145,37 @@ def test_vortex_indicator_neg2(self):
pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)


class TestPSARIndicator(TestIndicator):
class TestPSARIndicator(unittest.TestCase):
"""
https://school.stockcharts.com/doku.php?id=technical_indicators:parabolic_sar
"""

_filename = 'ta/tests/data/cs-psar.csv'

def setUp(self):
self._df = pd.read_csv(self._filename, sep=',')
self._indicator = PSARIndicator(high=self._df['High'], low=self._df['Low'], close=self._df['Close'],
fillna=False)

def tearDown(self):
del(self._df)

def test_psar_up(self):
target = 'psar_up'
result = psar_up(high=self._df['High'], low=self._df['Low'],
close=self._df['Close'])
result = self._indicator.psar_up()
pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)

def test_psar_down(self):
target = 'psar_down'
result = psar_down(high=self._df['High'], low=self._df['Low'],
close=self._df['Close'])
result = self._indicator.psar_down()
pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)

def test_psar_up_indicator(self):
target = 'psar_up_ind'
result = psar_up_indicator(high=self._df['High'], low=self._df['Low'],
close=self._df['Close'])
result = self._indicator.psar_up_indicator()
pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)

def test_psar_down_indicator(self):
target = 'psar_down_ind'
result = psar_down_indicator(high=self._df['High'], low=self._df['Low'],
close=self._df['Close'])
result = self._indicator.psar_down_indicator()
pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)

0 comments on commit d11107c

Please sign in to comment.