Giter Site home page Giter Site logo

jesse-extra-indicators's Introduction

Indicator divergence library

This module aims to help to find bullish/bearish divergences (regular or hidden) between two indicators using argrelextrema from scipy.signal.

Code based on higher-highs-lower-lows-and-calculating-price-trends-in-python article on medium.

This package is mean to use in conjunction with jesse ai but is generic enough to be used on its own.

Install

poetry build
pip install dist/jesse_extra_indicators-0.1.0-py3-none-any.whl

Example usage

import jesse_extra_indicators as xta

# Loopback window
w = 2

# this indicators has lower highs
ind1 = np.array([0, 10, 0, 9, 0]) # ex df.close
ind1_hl = xta.hl.HighLow(ind1, order=1)

# this indicators has higher highs
ind2 = np.array([0, 10, 0, 11, 0]) # ex ta.rsi(df.close)
ind2_hl = xta.hl.HighLow(ind2, order=1)

# build indicator divergence object
ind_div = xta.hl.IndicatorDivergence(ind1_hl, ind2_hl)

# Check regular or hidden bearish divergence
assert ind_div.regular_divergence(w, "bearish")
assert ind_div.hidden_divergence(w, "bearish")

# Check bearish confirmation 
assert ind_div.confirmation(w, "bearish")


# Check regular or hidden bullish divergence
assert ind_div.regular_divergence(w, "bullish")
assert ind_div.hidden_divergence(w, "bullish")

# Check bearish confirmation 
assert ind_div.confirmation(w, "bullish")

Example jesse strategy

from jesse.strategies import Strategy, cached
import jesse.indicators as ta
import jesse_extra_indicators as xta

class Example(Strategy):

    @property
    @cached
    def close_rsi_div(self):
        # no need to have the full data, this will speed up processing
        w = 100 

        close_hl = xta.hl.HighLow(self.candles[-w:, 2])
        rsi_hl = xta.hl.HighLow(self.rsi)

        # build indicator divergence object
        return xta.hl.IndicatorDivergence(close_hl, close_hl)


    def should_long(self) -> bool:
        w = 2 # you may wan to tweak the loopback window
        return (
            self.close_rsi_div.regular_divergence(w, "bullish")
            or self.close_rsi_div.hidden_divergence(w, "bullish")
        )


    def should_short(self) -> bool:
        w = 2 # you may wan to tweak the loopback window
        return (
            self.close_rsi_div.regular_divergence(w, "bearish")
            or self.close_rsi_div.hidden_divergence(w, "bearish")
        )

    def should_cancel(self) -> bool:
        ...

    def go_long(self):
        ...

    def go_short(self):
        ...

Find this usefull and want to buy me a coffee ?

send tips to

33w68oGuotfpJy59fPP5fUDk2fT3EzGkmS (btc)

D8zxqb2Fzm7Kqkn7QcKrcQjBPwbEBmMbRE (dogecoin)

jesse-extra-indicators's People

Contributors

jcsaaddupuy avatar

Stargazers

 avatar Alexey Dugnist avatar SIV4K avatar  avatar  avatar  avatar  avatar  avatar B1nh M1nh avatar  avatar

Watchers

 avatar James Cloos avatar

jesse-extra-indicators's Issues

Error in Example Strategy

return xta.hl.IndicatorDivergence(close_hl, close_hl)

close_hl is passed twice.

I think it should be:
return xta.hl.IndicatorDivergence(close_hl, rsi_hl)

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.