The metric is designed to estimate the market sentiment

The buyer/seller prevalence is a metric based on the side of trades during the selected period. The metric belongs to $[-2, 2]$ interval. The more trades with ‘buy’ side available, the more positive the buyer/seller prevalence is.

The algorithm is as follows:

1. get all trades for the selected period

4. apply the following logic where $buy$ and $sell$ are the sum of buy and sell trade amounts
$prevalence = \left\{ \begin{array}{ll} 0 & \textrm{if sell=buy}\\ (buy-sell)/buy & \textrm{buy>sell and buy \leq 2 \cdot sell}\\ 2-buy/(buy-sell) & \textrm{buy > 2 \cdot sell}\\ -(sell-buy)/sell & \textrm{sell>buy and sell \leq 2 \cdot buy}\\ -2+sell/(sell-buy) & \textrm{sell > 2 \cdot buy}\\ \end{array} \right.$