joosthoeks / jhTAlib

Technical Analysis Library Time-Series
https://joosthoeks.github.io/jhTAlib/
GNU General Public License v3.0
152 stars 44 forks source link

Harami Pattern detection is not working #7

Closed gregnwosu closed 4 years ago

gregnwosu commented 5 years ago

Describe the bug harami detection is failing for the following dataframe

To Reproduce

import pandas as pd
import jhtalib

def test_harami():
    date_format = "%Y-%m-%d %H:%M:%S"
    df = pd.DataFrame(
        {
            EnumStandardCandleColumn.datetime.name: [
                "2015-01-27 13:22:03",
                "2015-01-28 13:23:03",
                "2015-01-29 13:24:03",
                "2015-01-30 13:25:03",
                "2015-01-31 13:26:03",
            ],
            "Open": [28.0, 38.0, 35.0, 68.0, 66.0],
            "High": [45.0, 66.0, 150.0, 60.0, 15.0],
            "Low": [20.0, 31.0, 20.0, 72.0, 68.0],
            "Close": [38.0, 55.0, 127.0, 66.0, 22.0],
            "Volume": [38.0, 55.0, 127.0, 66.0, 22.0]
        }
    )
    df["datetime"] = pd.to_datetime(df["datetime"], format=date_format)
    result = jhtalib.CDLHARAMI(h)
    assert result is not None

Expected behavior A clear and concise description of what you expected to happen.

Screenshots The fourth candle from the left should be detected as harami image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

joosthoeks commented 5 years ago

The CDLHARAMI definition is not implemented yet.

gregnwosu commented 5 years ago

I can send a PR for this if you prefer

joosthoeks commented 5 years ago

Yes, you can do a pull request if it's only depends on the Python 3 standard library.

I would like to see an output for all pattern recognition definitions as follows:

If there is a bullish harami then output is 1 If there is a bearish harami then output is -1 Else (if no harami) output is 0

Also, if you can provide a source definition where we can check and validate the output would be very helpful. A source definition can be an online url with definition explanation or a book title where the source definition is defined.