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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use Side;
use Decimal;
/// Calculates the notional value in quote asset given the quantity, price and contract_size.
///
/// The notional value represents the total value of a position.
///
/// Returns None if overflow has occurred.
///
/// # Arguments
/// * `quantity` - The number of contracts or units
/// * `price` - The price per contract/unit
/// - For standard instruments, this is typically the current market price
/// - For option instruments, this should be the strike price
/// * `contract_size` - Multiplier that determines the actual exposure per contract
/// Calculates the absolute percentage difference between two values (eg/ prices).
///
/// Returns a `Decimal` that represents the percentage (eg/ 0.05 for a 5% difference). Will be
/// None if overflow has occurred.
/// Calculate the total delta for some quantity of "in kind" units.
///
/// Delta is a measure of how an instruments price changes relative to the underlying asset.
///
/// A positive return value indicates long exposure to the underlying, while negative values
/// indicate short exposure.
///
/// # Arguments
/// * `instrument_delta` - Delta of the instrument
/// - For Spot, Perpetual, and Futures, this is 1.0.
/// - For Options, this is between -1.0 and 1.0.
/// * `contract_size` - Multiplier that determines the actual exposure per contract
/// * `side` - Quantity direction, `Side::Buy` (LONG) or `Side::Sell` (SHORT)
/// * `quantity_in_kind` - In kind quantity