Skip to main content

A mechanical approach to determine the trend of a stock along with breakout and reversal levels.

Project description

SwingTrend

SwingTrend provides a mechanical approach to determine the stock trend, with breakout and reversal levels.

Python version: >= 3.8

  • Can track trends on historical as well as real-time OHLC data.
  • Use it as a trend indicator or screener.
  • Lightweight and serializable. The Class state can be saved/restored. Useful for day-to-day tracking of trends.
  • Timeframe agnostic - pass data from any timeframe to establish the current trend.
  • Linux, Windows, and Mac. No external dependencies.

If you ❤️ my work so far, please 🌟 this repo.

👽 Documentation

https://bennythadikaran.github.io/SwingTrend

Installation

pip install swingtrend

Basic Usage

from swingtrend import Swing`

# Initialise with default values
swing = Swing(retrace_threshold_pct=5, sideways_threshold=20, debug=False)

swing = swing.run(sym="HDFCBANK", df.iloc[-60:])

swing.trend # UP or DOWN or None

swing.is_sideways() # True or False.

swing.sph # if trend is UP and SPH is confirmed else None

swing.spl # if trend in DOWN and SPL is confirmed else None

swing.coc # Reversal price for the current trend.

swing.high # the current highest high within a swing.

swing.low # the current lowest low within a swing.

# Below represent datetime of the respective candles.
swing.sph_dt
swing.spl_dt
swing.coc_dt
swing.high_dt
swing.low_dt

See the documentation for more details.

Inspiration

This work was inspired by youtube Channel Matt Donlevey - Photon Trading.

You can watch their video How To Understand Market Structure to understand some of the concepts.

How the class works

See simple explanation of how the program works

To use the Photon method as explained in the video, instantiate the class as Swing(retrace_threshold_pct=None)

With the Photon method, both major or minor pivots can result in trend continuation or reversal. (including a single bar pullback).

I prefer avoiding the minor pivots by setting a minimum threshold percent. With an 8% threshold, the pullback must retrace atleast 8% or more to be considered a level for trend reversal or continuation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swingtrend-2.0.0.tar.gz (256.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swingtrend-2.0.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file swingtrend-2.0.0.tar.gz.

File metadata

  • Download URL: swingtrend-2.0.0.tar.gz
  • Upload date:
  • Size: 256.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for swingtrend-2.0.0.tar.gz
Algorithm Hash digest
SHA256 624e675130c25210e4448f9a5d3124ee3260325aaa62d7c0003e1d796d62c018
MD5 98be0d1615df2f1258ade20486341d11
BLAKE2b-256 e0523dec85452b94c87a32ad9c02a7827af61e6be3cf1bd37e1a38342651a2df

See more details on using hashes here.

Provenance

The following attestation bundles were made for swingtrend-2.0.0.tar.gz:

Publisher: publish-to-pypi.yml on BennyThadikaran/SwingTrend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swingtrend-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: swingtrend-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for swingtrend-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d72fe09c0448a09585a31ddfbca0d5362f1e71526916411aa2da5a7e48fd537e
MD5 9388b6f09fe5f5b52f03be0d243cc95c
BLAKE2b-256 cebe4a22cc619f2addab6724f33df0f8771af14129dec97bfb843978a4b1c3ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for swingtrend-2.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on BennyThadikaran/SwingTrend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page