From ee0b6a88ad1a18f88dbb8bc619952b82ab4b728a Mon Sep 17 00:00:00 2001 From: QuentinN42 Date: Thu, 27 Jan 2022 23:41:29 +0100 Subject: [PATCH] feat: dumb indicator --- auto_trading/indicators/__init__.py | 0 auto_trading/indicators/dumb.py | 26 ++++++++++++++++++++++++++ tests/indicators/__init__.py | 0 tests/indicators/test_dumb.py | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 auto_trading/indicators/__init__.py create mode 100644 auto_trading/indicators/dumb.py create mode 100644 tests/indicators/__init__.py create mode 100644 tests/indicators/test_dumb.py diff --git a/auto_trading/indicators/__init__.py b/auto_trading/indicators/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/auto_trading/indicators/dumb.py b/auto_trading/indicators/dumb.py new file mode 100644 index 0000000..82f08ba --- /dev/null +++ b/auto_trading/indicators/dumb.py @@ -0,0 +1,26 @@ +"""Dumb indicator, for testing purposes.""" +import pandas as pd # type: ignore + +from ..interfaces import Indicator + + +class Dumb(Indicator): + """Replay the value.""" + + def __init__(self, value: pd.DataFrame): + """Save the value.""" + super().__init__() + self.value = value + + def __call__(self, data: pd.DataFrame) -> pd.DataFrame: + """Return a dataframe of valuation of each stock from the input data. + + Args: + data (DataFrame): Time-Stock valuated candlestick data. + For each time and each stock give (high, low, open, close). + + Returns: + DataFrame: Stock valuated float. + For each stock give -1 if realy bad and +1 if realy good. + """ + return self.value diff --git a/tests/indicators/__init__.py b/tests/indicators/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/indicators/test_dumb.py b/tests/indicators/test_dumb.py new file mode 100644 index 0000000..11ad78e --- /dev/null +++ b/tests/indicators/test_dumb.py @@ -0,0 +1,19 @@ +"""Realy basic tests.""" +import pytest + +from pandas import DataFrame # type: ignore + +from auto_trading.indicators.dumb import Dumb + + +@pytest.mark.parametrize( + "value", + [ + (DataFrame()), + (DataFrame({"AAPL": [0], "GOOG": [1], "GOOGL": [2]})), + ], +) +def test_dumb(value: DataFrame) -> None: + """Test the dumb indicator.""" + dumb = Dumb(value) + assert (dumb(DataFrame()) == value).all().all()