Price Transform

Calculate a Price Transform: the average, median, typical or weighted close price of each period.

A price transform condenses the open, high, low and close of a period into one price. Indicators that should reflect the whole bar rather than only the close are built on them: the Commodity Channel Index, Money Flow Index and VWAP on the typical price, the Awesome Oscillator and FRAMA on the median price. The weighted close counts the close twice, as the price the period settled at.

The formula is as follows, per method:

\[\text{Average price:}\;\; \text{Average Price} = \frac{\text{Open} + \text{High} + \text{Low} + \text{Close}}{4}\] \[\text{Median price:}\;\; \text{Median Price} = \frac{\text{High} + \text{Low}}{2}\] \[\text{Typical price:}\;\; \text{Typical Price} = \frac{\text{High} + \text{Low} + \text{Close}}{3}\] \[\text{Weighted close price:}\;\; \text{Weighted Close Price} = \frac{\text{High} + \text{Low} + 2 \cdot \text{Close}}{4}\]

Also known as: AVGPRICE, average price, OHLC4, MEDPRICE, median price, HL2, TYPPRICE, typical price, HLC3, pivot price, WCLPRICE, weighted close price, HLCC4.

Example · NVDA · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_price_transform:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["NVDA"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_price_transform(method="weighted_close")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

What was Nvidia's weighted close on each day of 2025?

Which returns:

Parameters

get_price_transform accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
methodstrThe price. Options are: “average” (the average of the open, high, low and close), “median” (the average of the high and low), “typical” (the average of the high, low and close), “weighted_close” (the weighted close, (high + low + 2 × close) / 4). Defaults to “typical”."typical"
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the price. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Lambert, D.R. (1980). “Commodity Channel Index: Tool for Trading Cyclic Trends.” Commodities, October 1980, the typical price of the CCI.
  • Library Referenced against TA-Lib’s AVGPRICE
  • Library Referenced against TA-Lib’s MEDPRICE
  • Library Referenced against TA-Lib’s TYPPRICE
  • Library Referenced against TA-Lib’s WCLPRICE
  • Library Shares similar logic as pandas-ta-classic’s ohlc4
  • Library Shares similar logic as pandas-ta-classic’s hl2
  • Library Shares similar logic as pandas-ta-classic’s hlc3
  • Library Shares similar logic as pandas-ta-classic’s wcp
  • Library Shares similar logic as finta’s TP
  • Library Shares similar logic as Tulip Indicators’ avgprice
  • Library Shares similar logic as Tulip Indicators’ medprice
  • Library Shares similar logic as Tulip Indicators’ typprice
  • Library Shares similar logic as Tulip Indicators’ wcprice
Share