Psychological Line (PSL)

Calculate the Psychological Line (PSL): the share of periods in a window that closed higher, which shows whether buyers or sellers have the upper hand.

The Psychological Line is the percentage of the last window periods that closed higher, a measure of the mood of the market: after many periods up in a row buyers may be exhausted (overbought above 75) and after many down sellers (oversold below 25). The open-based form counts the periods that closed above their own open instead.

The formula is as follows:

\[\text{PSL} = \frac{100 \cdot \operatorname{Count}(\operatorname{Close}(t) > \operatorname{Close}(t - 1),\; \text{window})}{\text{window}}\]

or in the open-based form, 100 × Count(Close > Open, window) / window.

Also known as: PSL, PSY, psychological line, psychological index.

Example · AAPL, MSFT · 2024 to 2025

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

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2024-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_psychological_line()

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

On what share of recent days did Apple and Microsoft close higher in 2025, measured by the Psychological Line?

Which returns:

Parameters

get_psychological_line 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”."Close"
windowintThe number of periods counted. Defaults to 12.20
methodstrWhat counts as an up period. Options are: “close” (a close above the previous close), “open” (a close above the period’s open). Defaults to “close”."close"
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 PSL. 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

  • Library Referenced against pandas-ta-classic’s psl
Share