1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// The difference between the best bid and best ask quotes divided by their sum.
///
/// Volume Imbalance = (Best Bid Volume - Best Ask Volume) / (Best Bid Volume + Best Ask Volume)
///
/// # Input
/// - best_bid_volume: Volume of the best bid price on the bid side of the order book
/// - best_ask_volume: Volume of the best ask price on the ask side of the order book
///
/// # Output
/// - Volume imbalance of the order book
///
/// # LaTeX Formula
/// - Imb_{t} = \\frac{V^{b}_{t}-V^{a}_{t}}{V^{b}_{t}+V^{a}_{t}}
///
/// # Links
/// - Wikipedia: N/A
/// - Original Source: <https://davidsevangelista.github.io/post/basic_statistics_order_imbalance/#:~:text=The%20Order%20Book%20Imbalance%20is,at%20the%20best%20ask%2C%20respectively>
///
/// # Examples
///
/// ```rust
/// use digifi::market_making::volume_imbalance;
///
/// let volume_imbalance = volume_imbalance(10_000, 10_100);
///
/// assert_eq!(volume_imbalance, -100.0 / 20_100.0);
/// ```
// TODO: Add order book algorithm