CAR #003: Median with Interquartile Range Filter (MEDIR) | Methodology

Community Approval Request #003: Median with Interquartile Range Filter
Date: Fri, 21 January 2022
Author: DIA Core Team
Status: Approved

In this third Community Approval Request (CAR), the DIA DAO community will discuss, improve and approve the Median with Interquartile Range Filter methodology, a very commonly used filter by DIA for its oracle price determination.

How does the filter work?

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 going through all trades in the block has been finalized, the median of these prices is calculated. This is done by accumulating prices and ordering them by price. After that, the trade in the middle of the ordered set is selected. Its price represents the median of the set.

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

Filter Application

The MEDIR filter is used in DIA’s price determination. Our API can display the latest MEDIR-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.

→ Link to the DIA Docs

Suggest your ideas and improvements proposals by replying to this entry below.

→ Head over to Snapshot to vote

Timeline:

  • Discussion: 21 Jan - 28 Jan
  • Vote: 28 Jan - 4 Feb
  • Approval: 4 Feb
1 Like