4 changed files with 45 additions and 0 deletions
@ -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,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…
Reference in new issue