Browse Source

feat: dumb indicator

pull/14/head
QuentinN42 1 year ago
parent
commit
ee0b6a88ad
Signed by: number42 GPG Key ID: 2CD7D563712B3A50
  1. 0
      auto_trading/indicators/__init__.py
  2. 26
      auto_trading/indicators/dumb.py
  3. 0
      tests/indicators/__init__.py
  4. 19
      tests/indicators/test_dumb.py

0
auto_trading/indicators/__init__.py

26
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

0
tests/indicators/__init__.py

19
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()
Loading…
Cancel
Save