patternpy

repository·main·Indexed 19 days ago

https://github.com/keithorange/patternpy

A high-performance Python package for automated trading pattern recognition in financial markets. Leveraging Pandas and Numpy, it identifies patterns such as head and shoulders, triangles, and wedges from OHLCV data.

Tokens
384
Snippets
2
Records
2
Agent score
17%

What's inside patternpy

  1. Identify Head and Shoulders patterns in OHLCV data

    main

    You can use the head_and_shoulders function from patternpy.tradingpatterns to scan a Pandas DataFrame containing OHLCV (Open, High, Low, Close, Volume) data.

    When applied, the function adds a new column named head_shoulder_pattern to your DataFrame. This column contains one of the following values:

    • NaN: No pattern detected.
    • 'Head and Shoulder': A standard head and shoulders pattern was identified.
    • 'Inverse Head and Shoulder': An inverse head and shoulders pattern was identified.
    from patternpy.tradingpatterns import head_and_shoulders
    import pandas as pd
    
    # Have price data (OCHLV dataframe)
    df = pd.DataFrame(stock_data)
    
    # Apply pattern indicator screener
    df = head_and_shoulders(df)
    
    # New column `head_shoulder_pattern` is created with entries containing either: NaN, 'Head and Shoulder' or 'Inverse Head and Shoulder'
    print(df)