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
63
/// `PnL` struct holds various statistical measures about trading strategy performance.
///
/// # Fields
///
/// - `net_profit`: Total returns of the strategy subtracting losses and commissions.
/// - `gross_profit`: The sum of all profitable trades.
/// - `gross_loss`: The sum of all losing trades.
/// - `buy_and_hold_return`: The return if we just bought and held the asset without trading.
/// - `profit_factor`: The ratio of gross profit to gross loss. A value greater than 1 indicates a profitable system.
/// - `commission_paid`: Total commission paid for all trades.
/// - `total_closed_trades`: Total number of closed trades.
/// - `num_winning_trades`: Number of trades that resulted in profit.
/// - `num_losing_trades`: Number of trades that resulted in loss.
/// - `percent_profitable`: Percentage of trades that were profitable.
/// - `avg_winning_trade`: Average profit for winning trades.
/// - `avg_losing_trade`: Average loss for losing trades.
/// - `ratio_avg_win_loss`: Ratio of the average win to the average loss.
/// - `largest_winning_trade`: The largest profit from a single trade.
/// - `largest_losing_trade`: The largest loss from a single trade.
/// - `avg_ticks_in_winning_trades`: Average number of ticks (time periods) that winning trades were held.
/// - `avg_ticks_in_losing_trades`: Average number of ticks (time periods) that losing trades were held.
///
/// `TriggerSignal` struct holds data used for calculating PnL analysis
///
/// # Fields
/// - `signal_in` : Higher value over `signal_out` triggers entry
/// - `signal_out` : Higher value over `signal_in` triggers exit
/// - `time_open` : The time that the kline/candlestick open, represented as a Unix timestamp.
/// - `time_close` : The time that the kline/candlestick closed, represented as a Unix timestamp.
/// - `price_open` : The price at the opening of the kline/candlestick.
/// - `price_close` : The price at the closing of the kline/candlestick.
///