test for buy signal
This commit is contained in:
parent
2f3fd1de8a
commit
4069e73039
@ -1,7 +1,9 @@
|
||||
# pragma pylint: disable=missing-docstring
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from pandas import DataFrame
|
||||
import arrow
|
||||
from analyze import parse_ticker_dataframe, populate_buy_trend, populate_indicators
|
||||
from analyze import parse_ticker_dataframe, populate_buy_trend, populate_indicators, analyze_ticker, get_buy_signal
|
||||
|
||||
RESULT_BITTREX = {
|
||||
'success': True,
|
||||
@ -34,5 +36,14 @@ class TestAnalyze(unittest.TestCase):
|
||||
self.assertTrue('buy' in dataframe.columns)
|
||||
self.assertTrue('buy_price' in dataframe.columns)
|
||||
|
||||
def test_4_returns_latest_buy_signal(self):
|
||||
buydf = DataFrame([{'buy': 1, 'date': arrow.utcnow()}])
|
||||
with patch('analyze.analyze_ticker', return_value=buydf):
|
||||
self.assertEqual(get_buy_signal('BTC-ETH'), True)
|
||||
buydf = DataFrame([{'buy': 0, 'date': arrow.utcnow()}])
|
||||
with patch('analyze.analyze_ticker', return_value=buydf):
|
||||
self.assertEqual(get_buy_signal('BTC-ETH'), False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user