Skip to main content

Technical Indicator is a Python package for calculating technical indicators from financial time series datasets

Project description

Technical Indicator Python Package

This Python package provides methods to calculate various technical indicators from financial time series datasets. The indicators are organized into four categories: momentum indicators, trend indicators, volume indicators, and volatility indicators.

Installation

You can install the Technical Indicator package using pip:

pip install technical-indicator

Momentum Indicators

Relative Strength Index (RSI)

The RSI measures the ratio of upward price movements to downward price movements over a given period of time. To calculate the RSI using this package, initialize an instance of the RSI class with an array of close prices and an optional lookback period (default is 14), and call the calculate method:

from technical_indicator.momentum import RSI

# Example data
period = 12
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17, 18, 14, 20, 18]

# Initialize the RSI indicator with the prices and period
rsi = RSI(close_prices, period)

# Calculate the RSI values
rsi_values = rsi.calculate_rsi()

Moving Average Convergence Divergence (MACD)

The Moving Average Convergence Divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price. To calculate the MACD using this package, initialize an instance of the MACD class with an array of close prices and optional fast and slow lookback periods (default are 12 and 26, respectively), and call the calculate method:

from technical_indicator.momentum import MACD

# Example data
fast_period = 12
slow_period = 26
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17, 18, 14, 20, 18]

# Initialize the MACD indicator with the prices and periods
macd = MACD(close_prices, fast_period, slow_period)

# Calculate the MACD values
macd_values = macd.calculate_macd()

MACD Histogram

The MACD (Moving Average Convergence Divergence) Histogram is a momentum indicator that shows the difference between the MACD line and the signal line. It is derived from the MACD line and is used to identify potential trend reversals. To calculate the MACD Histogram using this package, import the MACDHistogram class from the momentum module, initialize an instance with an array of close prices and optional parameters, and call the calculate method:

from technical_indicator.momentum import MACDHistogram

# Example data
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17, 18, 14, 20, 18]
fast_period = 6
slow_period = 12
signal_period = 9

# Initialize the MACD Histogram indicator with the prices and periods
macd_histogram = MACDHistogram(close_prices, fast_period, slow_period, signal_period)

# Calculate the MACD Histogram values
macd_histogram_values = macd_histogram.calculate_macd_histogram()

Trend Indicators

Simple Moving Average (SMA)

The Simple Moving Average (SMA) is a widely used technical indicator that represents the average closing price of a security over a specified period of time. To calculate the SMA using this package, initialize an instance of the MovingAverage class with an array of close prices and an optional lookback period (default is 9), and call the calculate method:

from technical_indicator.trend import MovingAverage

# Example data
period = 20
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17, 18, 14, 20, 18]

# Initialize the MovingAverage instance with the prices and period
ma = MovingAverage(close_prices, period)

# Calculate the SMA values
sma_values = ma.calculate_sma()

Exponential Moving Average (EMA)

The Exponential Moving Average (EMA) is a type of moving average that gives more weight to recent prices. To calculate the EMA using this package, initialize an instance of the MovingAverage class with an array of close prices and an optional lookback period (default is 9), and call the calculate method:

from technical_indicator.trend import MovingAverage

# Example data
period = 20
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17, 18, 14, 20, 18]

# Initialize the MovingAverage instance with the prices and period
ma = MovingAverage(close_prices, period)

# Calculate the EMA values
ema_values = ma.calculate_ema()

Weighted Moving Average (WMA)

The Weighted Moving Average (WMA) is a type of moving average that gives more weight to recent prices while allowing the user to specify the exact weighting of each price in the calculation. To calculate the WMA using this package, initialize an instance of the MovingAverage class with an array of close prices and call the calculate_wma method:

from technical_indicator.trend import MovingAverage

# Example data
period = 20
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17 , 18, 14, 20, 18]

# Initialize the MovingAverage instance with the prices and period
ma = MovingAverage(close_prices, period)

# Calculate the WMA value
wma_value = ma.calculate_wma()

Hull Moving Average (HMA)

The Hull Moving Average (HMA) is a type of moving average that aims to reduce the lag and noise of traditional moving averages while maintaining smoothness. To calculate the HMA using this package, initialize an instance of the MovingAverage class with an array of close prices and an optional lookback period (default is 9), and call the calculate_hma method:

from technical_indicator.trend import MovingAverage

# Example data
period = 20
close_prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17, 16, 18, 20, 18, 16, 17, 15, 17, 19, 20, 16, 17 , 18, 14, 20, 18]

# Initialize the MovingAverage instance with the prices and period
ma = MovingAverage(close_prices, period)

# Calculate the HMA values
hma_values = ma.calculate_hma()

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

technical-indicator-1.0.3.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

technical_indicator-1.0.3-py2.py3-none-any.whl (22.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file technical-indicator-1.0.3.tar.gz.

File metadata

  • Download URL: technical-indicator-1.0.3.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for technical-indicator-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b800d5a31656f3ba64cd54b15b8341912473b6a2ba9e1239913ac4c4119b00f5
MD5 ea3e5ac565987cf7ea5493d6ed96382f
BLAKE2b-256 69ded9d7ae30cc3132e94dbf7c51deed2cbf28838a6cf33eae3baa4533701bf5

See more details on using hashes here.

File details

Details for the file technical_indicator-1.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for technical_indicator-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6c6170e2c6fb3d7849230c2f4a8d75136ea68ebe39bfa3a182ac72c23090aae7
MD5 24223728f7aec935dc4255c3be875ee2
BLAKE2b-256 03ccd2fc54e9ce75097ba39cccb3c5f6ab5281b816bd63897103a3b3f9ad1110

See more details on using hashes here.

Supported by

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