CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-ta-lib

Python wrapper for TA-LIB providing 175+ technical analysis indicators for financial market data

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

price-transform.mddocs/

Price Transform

Functions that transform OHLC data into standardized price representations for further analysis. These transformations combine multiple price points into single representative values, providing different perspectives on price action.

Capabilities

Average Price

Calculates the arithmetic mean of open, high, low, and close prices, providing a balanced representation of price activity.

def AVGPRICE(open, high, low, close):
    """
    Average Price
    
    Formula: (open + high + low + close) / 4
    
    Parameters:
    - open: array-like, open prices
    - high: array-like, high prices
    - low: array-like, low prices
    - close: array-like, close prices
    
    Returns:
    numpy.ndarray: Average price values
    """

Median Price

Calculates the midpoint between high and low prices, representing the middle of the trading range.

def MEDPRICE(high, low):
    """
    Median Price
    
    Formula: (high + low) / 2
    
    Parameters:
    - high: array-like, high prices
    - low: array-like, low prices
    
    Returns:
    numpy.ndarray: Median price values (midpoint of range)
    """

Typical Price

Calculates the average of high, low, and close prices, giving equal weight to the three key price points.

def TYPPRICE(high, low, close):
    """
    Typical Price
    
    Formula: (high + low + close) / 3
    
    Parameters:
    - high: array-like, high prices
    - low: array-like, low prices
    - close: array-like, close prices
    
    Returns:
    numpy.ndarray: Typical price values
    """

Weighted Close Price

Calculates a weighted average emphasizing the close price, which is often considered the most important price of the period.

def WCLPRICE(high, low, close):
    """
    Weighted Close Price
    
    Formula: (high + low + 2*close) / 4
    
    Parameters:
    - high: array-like, high prices
    - low: array-like, low prices
    - close: array-like, close prices
    
    Returns:
    numpy.ndarray: Weighted close price values
    """

Usage Examples

import talib
import numpy as np

# Sample OHLC data
open_prices = np.array([100.0, 101.0, 102.0, 101.5, 103.0])
high_prices = np.array([100.8, 102.2, 102.5, 102.0, 103.5])
low_prices = np.array([99.2, 100.5, 101.0, 100.8, 102.5])
close_prices = np.array([100.5, 101.8, 101.2, 102.2, 103.2])

# Calculate different price transforms
avg_price = talib.AVGPRICE(open_prices, high_prices, low_prices, close_prices)
med_price = talib.MEDPRICE(high_prices, low_prices)
typ_price = talib.TYPPRICE(high_prices, low_prices, close_prices)
wcl_price = talib.WCLPRICE(high_prices, low_prices, close_prices)

print("Latest prices:")
print(f"Average Price: {avg_price[-1]:.2f}")
print(f"Median Price: {med_price[-1]:.2f}")
print(f"Typical Price: {typ_price[-1]:.2f}")
print(f"Weighted Close Price: {wcl_price[-1]:.2f}")

# These transformed prices are commonly used as:
# - Input to other technical indicators instead of close price
# - Basis for pivot point calculations
# - Representative price for volume-weighted calculations
# - Smoothed price series for trend analysis

Common Use Cases

  • Indicator Input: Many traders use typical price or weighted close price as input to moving averages and other indicators instead of just close price
  • Pivot Points: Average price and typical price are often used in pivot point calculations
  • Volume Analysis: Typical price is commonly used in volume-weighted price calculations
  • Price Smoothing: These transforms can help reduce noise in price data while preserving important characteristics

Install with Tessl CLI

npx tessl i tessl/pypi-ta-lib

docs

abstract-streaming.md

cycle-indicators.md

index.md

math-operations.md

momentum-indicators.md

overlap-studies.md

pattern-recognition.md

price-transform.md

statistical-functions.md

volatility-indicators.md

volume-indicators.md

tile.json