Indicator divergence library for python

Overview

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)

:mag_right: :chart_with_upwards_trend: :snake: :moneybag: Backtest trading strategies in Python.

Backtesting.py Backtest trading strategies with Python. Project website Documentation the project if you use it. Installation $ pip install backtestin

3.1k Dec 31, 2022
Portfolio and risk analytics in Python

pyfolio pyfolio is a Python library for performance and risk analysis of financial portfolios developed by Quantopian Inc. It works well with the Zipl

Quantopian, Inc. 4.8k Jan 08, 2023
A proper portfolio tracker. Featuring historical allocation, cash flows and real returns.

Python Portfolio Analytics A portfolio tracker featuring account transactions, historical allocation, dividends and splits management and endless perf

Simone Precicchiani 13 Aug 13, 2022
ARCH models in Python

arch Autoregressive Conditional Heteroskedasticity (ARCH) and other tools for financial econometrics, written in Python (with Cython and/or Numba used

Kevin Sheppard 1k Jan 04, 2023
Software for quick purchase of mystery boxes on Binance.

english | русский язык Software for quick purchase of mystery boxes on Binance. Purpose Installation & setup Motivation Specification Disclaimer Purpo

Ellis 5 Mar 08, 2022
Fourth and final milestone project

Milestone Project 4: Pound Dog Click link to visit "Pound Dog" Aim of the project The aim of this project is to provide access to a website informing

Jamie Wilson 1 Oct 31, 2021
Python Backtesting library for trading strategies

backtrader Yahoo API Note: [2018-11-16] After some testing it would seem that data downloads can be again relied upon over the web interface (or API v

DRo 9.8k Dec 30, 2022
High-performance TensorFlow library for quantitative finance.

TF Quant Finance: TensorFlow based Quant Finance Library Table of contents Introduction Installation TensorFlow training Development roadmap Examples

Google 3.5k Jan 01, 2023
'Personal Finance' is a project where people can manage and track their expenses

Personal Finance by Abhiram Rishi Pratitpati 'Personal Finance' is a project where people can manage and track their expenses. It is hard to keep trac

Abhiram Rishi Prattipati 1 Dec 21, 2021
Common financial technical indicators implemented in Pandas.

FinTA (Financial Technical Analysis) Common financial technical indicators implemented in Pandas. This is work in progress, bugs are expected and resu

1.8k Dec 31, 2022
Supply a wrapper ``StockDataFrame`` based on the ``pandas.DataFrame`` with inline stock statistics/indicators support.

Stock Statistics/Indicators Calculation Helper VERSION: 0.3.2 Introduction Supply a wrapper StockDataFrame based on the pandas.DataFrame with inline s

Cedric Zhuang 1.1k Dec 28, 2022
Python library for backtesting trading strategies & analyzing financial markets (formerly pythalesians)

finmarketpy (formerly pythalesians) finmarketpy is a Python based library that enables you to analyze market data and also to backtest trading strateg

Cuemacro 3k Dec 30, 2022
Indicator divergence library for python

Indicator divergence library This module aims to help to find bullish/bearish divergences (regular or hidden) between two indicators using argrelextre

8 Dec 13, 2022
ffn - a financial function library for Python

ffn - Financial Functions for Python Alpha release - please let me know if you find any bugs! If you are looking for a full backtesting framework, ple

Philippe Morissette 1.4k Jan 01, 2023
Technical Analysis Library using Pandas and Numpy

Technical Analysis Library in Python It is a Technical Analysis library useful to do feature engineering from financial time series datasets (Open, Cl

Darío López Padial 3.4k Jan 02, 2023
personal finance tracker, written in python 3 and using the wxPython GUI toolkit.

personal finance tracker, written in python 3 and using the wxPython GUI toolkit.

wenbin wu 23 Oct 30, 2022
Python Algorithmic Trading Library

PyAlgoTrade PyAlgoTrade is an event driven algorithmic trading Python library. Although the initial focus was on backtesting, paper trading is now pos

Gabriel Becedillas 3.9k Jan 01, 2023
scrilla: A Financial Optimization Application

A python application that wraps around AlphaVantage, Quandl and IEX APIs, calculates financial statistics and optimizes portfolio allocations.

Grant Moore 6 Dec 17, 2022
Beibo is a Python library that uses several AI prediction models to predict stocks returns over a defined period of time.

Beibo is a Python library that uses several AI prediction models to predict stocks returns over a defined period of time.

Santosh 54 Dec 10, 2022