Calculate the Awesome Oscillator (AO) for a given price series.

The Awesome Oscillator measures market momentum by comparing a short-term and a long-term Simple Moving Average of the median price (the midpoint of each period’s high and low, rather than the closing price). It was developed by Bill Williams as part of his broader “Trading Chaos” collection of momentum indicators.

The formula is as follows:

\[\text{Median Price} = (\text{High} + \text{Low}) / 2\] \[\text{AO} = \operatorname{SMA}(\text{Median Price},\; \text{short\_window}) - \operatorname{SMA}(\text{Median Price},\; \text{long\_window})\]

Also known as: AO, Bill Williams Awesome Oscillator.

Awesome Oscillator (AO) in Python

get_awesome_oscillator is part of the Technicals module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_awesome_oscillator as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_awesome_oscillator()

Which returns:

Date AAPL MSFT Benchmark
2022-12-16 -3.5418 11.2131 2.3418
2022-12-19 -4.8628 9.3716 -0.5142
2022-12-20 -7.3604 5.5371 -5.2622
2022-12-21 -8.7804 1.9144 -8.5319
2022-12-22 -9.8319 -1.2635 -11.0124
2022-12-23 -10.5435 -3.8732 -11.8451
2022-12-27 -10.9665 -5.1579 -11.8737
2022-12-28 -11.2666 -6.1431 -11.8561
2022-12-29 -12.1821 -7.321 -12.6508
2022-12-30 -12.5038 -7.2199 -12.3585

Parameters

get_awesome_oscillator accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
  • short_window (int, optional): The number of periods for the short-term SMA of the median price. Defaults to 5.
  • long_window (int, optional): The number of periods for the long-term SMA of the median price. Defaults to 34.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the AO. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.
Share