mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-06-27 16:10:07 +08:00
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from unittest import TestCase
|
|
from pandas import DataFrame
|
|
|
|
from .config import sample_data
|
|
from .context import pandas_ta
|
|
|
|
|
|
class TestPerformaceExtension(TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.data = sample_data
|
|
cls.islong = cls.data["close"] > pandas_ta.sma(cls.data["close"], length=50)
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
del cls.data
|
|
del cls.islong
|
|
|
|
def setUp(self): pass
|
|
def tearDown(self): pass
|
|
|
|
|
|
def test_log_return_ext(self):
|
|
self.data.ta.log_return(append=True)
|
|
self.assertIsInstance(self.data, DataFrame)
|
|
self.assertEqual(self.data.columns[-1], "LOGRET_1")
|
|
|
|
def test_cum_log_return_ext(self):
|
|
self.data.ta.log_return(append=True, cumulative=True)
|
|
self.assertIsInstance(self.data, DataFrame)
|
|
self.assertEqual(self.data.columns[-1], "CUMLOGRET_1")
|
|
|
|
def test_percent_return_ext(self):
|
|
self.data.ta.percent_return(append=True)
|
|
self.assertIsInstance(self.data, DataFrame)
|
|
self.assertEqual(self.data.columns[-1], "PCTRET_1")
|
|
|
|
def test_cum_percent_return_ext(self):
|
|
self.data.ta.percent_return(append=True, cumulative=True)
|
|
self.assertIsInstance(self.data, DataFrame)
|
|
self.assertEqual(self.data.columns[-1], "CUMPCTRET_1")
|