Git Product home page Git Product logo

support_resistance's Introduction

PriceLevels

Small package that helps to find support and resistance levels and plot them on chart

Levels on candlestick chart

Levels on zig zag chart

Requirements

  • python 3.6+
  • matplotlib, pandas, numpy, zigzag, scikit-learn

(For full dependency list check requirements.txt)

Installation

python setup.py install

How it works?

Algorithm uses AgglomerativeClustering to find levels from pivot points. There are 2 different implementations

  • ZigZagClusterLevels
  • RawPriceClusterLevels

First one use zigzag pivot points and the second one use all high/low prices as pivot points.

Usage example:

   data = get_quotes_from_fixture()
   pl.fit(data.iloc[-100:])
   levels = pl.levels

fit method expected to have pandas.DataFrame object with columns Open, High, Low, Close or 1d numpy.array of prices you want to use to generate levels

Please check examples first :)

ZigZagClusterLevels

Init args:

  • peak_percent_delta - Min change for new pivot in ZigZag
  • merge_distance/merge_percent - Max distance between pivots that can be merged into price level. Comes from AgglomerativeClustering. Only one of those args should be specified, another should be set to None
  • min_bars_between_peaks - filter pivots that occurs less than specified number of bars
  • peaks (default='All'). Specifies which pivot prices to take. All, High, Low values expected here.
  • level_selector(default='median') How to define level from pivots. Options: mean and median

RawPriceClusterLevels

Init args:

  • merge_distance/merge_percent - Max distance between pivots that can be merged into price level. Comes from AgglomerativeClustering. Only one of those args should be specified, another should be set to None
  • level_selector(default='median') How to define level from pivots. Options: mean and median
  • use_maximums(default=True) which prices to use.
  • bars_for_peak(default=21) take only bars that is high or low across specified number of bars

other stuff


Visualization

expected usage:

from pricelevels.visualization.levels_on_candlestick import plot_levels_on_candlestick
plot_levels_on_candlestick(df, levels, only_good=False, path=pth)

from pricelevels.visualization.levels_with_zigzag import plot_with_pivots
plot_with_pivots(df['Close'].values, levels, zig_zag_percent)

Level scoring

Put some score if price touch, cut or pivot near selected levels. Better levels have higher score. It works slowly, so probably you don't want to use it. This idea came from https://stackoverflow.com/questions/8587047/support-resistance-algorithm-technical-analysis

Many parameters, so please check source code.

Usage:

from pricelevels.scoring.touch_scorer import TouchScorer
scorer = TouchScorer()
scorer.fit(levels, df.copy())
print(scorer.scores)

support_resistance's People

Contributors

day0market avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.