Skip to main content

Library collection of algorithms to calculate supports and resistance of financial markets.

Project description

PKG-SUPPORT-RESISTANCE

Github Actions pdm-managed

Description

Collection of algorithms to calculate supports and resistances in financial markets.

[!IMPORTANT]

Supported Algorithms

Supported Algorithms Operational
Vanilla Clustering
KMeans ML Clustering
DBSCAN ML Clustering
KNN (DK-Nearest Neighbors) ML
RandomForest ML
...

Installation

pip install pkg-support-resistance

Quick usage

Here's an example to get the gist of using the package.

from pkg_support_resistance import VanillaSupportResistance, KMeansSupportResistance, DBSCANSupportResistance
from pkg_support_resistance.data_set import sr_input_example

# Example input type
# sr_input_example = {
#     "open": [42780, 42834.94, ...],
#     "close": [42834.94, 42961.84, ...],
#     "high": [42901.1, 42986.06, ...],
#     "low": [42730.03, 42795.41, ...],
#     "volume": [173.63661, 169.47648, ...]
# }


# Vanilla algorithms:
sr_result: list[dict] = VanillaSupportResistance.exec_pipeline(input_data=sr_input_example, cluster_threshold=1)
print(sr_result, len(sr_result))


# KMeans ML algorithms:
sr_result: list[dict] = KMeansSupportResistance.exec_pipeline(input_data=sr_input_example, n_clusters=9)
print(sr_result, len(sr_result))


# DBSCAN  ML algorithms:
sr_result: list[dict] = DBSCANSupportResistance.exec_pipeline(input_data=sr_input_example, eps=1000, min_samples=1)
print(sr_result, len(sr_result))

Input example:

To see in: "/src/pkg_support_resistance/data_set/example.json"

Output example (Using VanillaSupportResistance algorithm and dataset from '/dataset/example.json'):

[
   {
      "pivotPrice": 48184.0,
      "limitsUp": 48495.0,
      "limitsDown": 47347.53,
      "score": 67,
      "accumulatedVolume": 44687.15635
   },
   {
      "pivotPrice": 47534.34,
      "limitsUp": 47874.98,
      "limitsDown": 46763.68,
      "score": 41,
      "accumulatedVolume": 23864.294279999995
   },
   {
      "pivotPrice": 45000.0,
      "limitsUp": 45000.0,
      "limitsDown": 44700.0,
      "score": 8,
      "accumulatedVolume": 6010.54166
   },
   {
      "pivotPrice": 43996.5,
      "limitsUp": 44141.37,
      "limitsDown": 43100.0,
      "score": 40,
      "accumulatedVolume": 17909.42211
   },
   {
      "pivotPrice": 43473.45,
      "limitsUp": 43580.0,
      "limitsDown": 42697.01,
      "score": 37,
      "accumulatedVolume": 18501.36496
   },
   {
      "pivotPrice": 42819.86,
      "limitsUp": 42850.0,
      "limitsDown": 42041.7,
      "score": 15,
      "accumulatedVolume": 6355.429050000001
   },
   {
      "pivotPrice": 42259.58,
      "limitsUp": 42787.38,
      "limitsDown": 42017.33,
      "score": 24,
      "accumulatedVolume": 12506.830009999998
   },
   {
      "pivotPrice": 41619.99,
      "limitsUp": 42365.48,
      "limitsDown": 41115.0,
      "score": 91,
      "accumulatedVolume": 42944.990900000004
   },
   {
      "pivotPrice": 41071.29,
      "limitsUp": 41157.26,
      "limitsDown": 40753.88,
      "score": 8,
      "accumulatedVolume": 4474.11918
   }
]

pivotPrice:

Support/resistance line.

limitsUp/limitsDown:

Support/resistance zone.

Score, support/resistance score:

If the score is high it means that many candles have been traded in that area with a high volume being traded, on the other hand a low score may be due to the fact that it is not a highly traded area or that it belongs to a higher maximum or lower minimum (very important zones, but not surpassed in the short term and low negotiation).

accumulatedVolume:

Accumulated volume traded in the consolidated zone between limitsUp/limitsDown.

Graph of the 'pivotPrice' S/R (Using VanillaSupportResistance algorithm and dataset from '/dataset/example.json'):

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

pkg_support_resistance-0.4.2.tar.gz (515.8 kB view details)

Uploaded Source

Built Distribution

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

pkg_support_resistance-0.4.2-py3-none-any.whl (513.8 kB view details)

Uploaded Python 3

File details

Details for the file pkg_support_resistance-0.4.2.tar.gz.

File metadata

  • Download URL: pkg_support_resistance-0.4.2.tar.gz
  • Upload date:
  • Size: 515.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for pkg_support_resistance-0.4.2.tar.gz
Algorithm Hash digest
SHA256 9f444961556d7ba97e1b69cc53a929acbc7ea8ad31dcae9aed7330a76735abbb
MD5 7e830497a5902ee86487a17497c8f8f5
BLAKE2b-256 7368275eb7d87b77fcfba85808aac746f989feb0f8f5b805bd782265ed250b97

See more details on using hashes here.

File details

Details for the file pkg_support_resistance-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pkg_support_resistance-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 468675f2d41c3296eabcc26243fa8c5b7ea1885b517faa4c139c707f060ec78a
MD5 79d9537cf37deb57fa7493ed0b524563
BLAKE2b-256 714d8573bdca61261f9b501b51d46e75a8fe8c150f6acc9f1245caedfc51e9d8

See more details on using hashes here.

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