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)

Common financial risk and performance metrics. Used by zipline and pyfolio.

empyrical Common financial risk metrics. Table of Contents Installation Usage Support Contributing Testing Installation pip install empyrical Usage S

Quantopian, Inc. 1k Dec 26, 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
A python wrapper for Alpha Vantage API for financial data.

alpha_vantage Python module to get stock data/cryptocurrencies from the Alpha Vantage API Alpha Vantage delivers a free API for real time financial da

Romel Torres 3.8k Jan 07, 2023
Python sync/async framework for Interactive Brokers API

Introduction The goal of the IB-insync library is to make working with the Trader Workstation API from Interactive Brokers as easy as possible. The ma

Ewald de Wit 2k Dec 30, 2022
This repository contains a set of plugins for Volatility 3

volatility_plugins This repository contains a set of plugins for Volatility 3 These plugins are not compatible with Volatility 2 To use these plugins

Immersive-Labs-Sec 10 Nov 30, 2022
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
Find big moving stocks before they move using machine learning and anomaly detection

Surpriver - Find High Moving Stocks before they Move Find high moving stocks before they move using anomaly detection and machine learning. Surpriver

Tradytics 1.5k Dec 31, 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
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
Q-Fin: A Python library for mathematical finance.

Q-Fin A Python library for mathematical finance. Installation https://pypi.org/project/QFin/ pip install qfin Bond Pricing Option Pricing Black-Schol

Roman Paolucci 247 Jan 01, 2023
Yahoo! Finance market data downloader (+faster Pandas Datareader)

Yahoo! Finance market data downloader Ever since Yahoo! finance decommissioned their historical data API, many programs that relied on it to stop work

Ran Aroussi 8.4k Jan 01, 2023
A banking system is a group or network of institutions that provide financial services for us

A banking system is a group or network of institutions that provide financial services for us. These institutions are responsible for operating a payment system, providing loans, taking deposits, and

UTTKARSH PARMAR 1 Oct 24, 2021
bt - flexible backtesting for Python

bt - Flexible Backtesting for Python bt is currently in alpha stage - if you find a bug, please submit an issue. Read the docs here: http://pmorissett

Philippe Morissette 1.6k Jan 05, 2023
stock data on eink with raspberry

small python skript to display tradegate data on a waveshare e-ink important you need locale "de_AT.UTF-8 UTF-8" installed. do so in raspi-config's Lo

Simon Oberhammer 24 Feb 22, 2022
rotki is an open source portfolio tracking, analytics, accounting and tax reporting tool that respects your privacy.

rotki is an open source portfolio tracking, analytics, accounting and tax reporting tool that respects your privacy. The mission of rotki is to bring transparency into the crypto and financial sector

Rotki 2k Dec 30, 2022
Github.com/CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 2,100 + stars, 580 + forks

CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 2,100 + stars, 580 + forks https://github.com/CryptoSignal/Crypto-Signal Development state:

Github.com/Signal - 2,100 + stars, 580 + forks 4.2k Jan 01, 2023
Zipline, a Pythonic Algorithmic Trading Library

Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backte

Quantopian, Inc. 15.7k Jan 02, 2023
Performance analysis of predictive (alpha) stock factors

Alphalens Alphalens is a Python Library for performance analysis of predictive (alpha) stock factors. Alphalens works great with the Zipline open sour

Quantopian, Inc. 2.5k 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