> ## Documentation Index
> Fetch the complete documentation index at: https://www.diadata.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MAIR: Moving Average with Interquartile Range Filter

The MAIR (Moving Average with Interquartile Range Clearing) filter is the application of the Moving Average filter to data that was previously cleared by the [Interquartile Range](/docs/guides/methodologies/pricing-methodologies/ir-interquartile-range-filter) filtering system.

## Trade Collection

All trades from the queried time range are ordered by timestamp.

For each second in the time range, there exists a "slot" where trades are put into.

## Price Calculation

As soon as all trades in the block have been finalized (usually 120 seconds per block), for each 1 second slot the closing price is taken.

These slots are then weighted against the volume for each data point and the weighted average price is taken to arrive at the final price.

For a MAIR-120 window, with the closing price $c_t​$ and traded volume $v_t $of each 1-second slot $t$:

$MAIR = \frac{\sum_{t=1}^{120} c_t \cdot v_t}{\sum_{t=1}^{120} v_t}$

The result is then returned as the result of the filter operation.

## Filter Application

The MAIR filter is used in DIA's price determination. Our price quotations are the latest MAIR-120 filter values, i.e., the filter results from a 120 second interval of all recorded trades for an asset.

## Implementation

The filter is implemented as part of the FiltersBlockService [in this file in our Github repository](https://github.com/diadata-org/diadata/blob/master/internal/pkg/filtersBlockService/FilterMA.go).
