fix: Fix total realized/unrealized pnl calc

This commit is contained in:
John Colvin committed 2025-04-30 01:35:22 -04:00
1 parent 9f56abaa38
commit 7725ae33ef
1 file changed
+4 -2
@@ -164,8 +164,10 @@ namespace bts.shell.pnl {
day_short_pos.if_nan(0));
public double total_short_avg_pnl => new[] { sod_short_avg_pnl, day_short_avg_pnl }.sum_real();
public double total_net_pos => new[] { sod.long_pos, -sod.short_pos, day.long_pos, -day.short_pos }.Where(n => n.is_real()).Sum();
public double total_unrealized_pnl => new[] { sod_unrealized_pnl, day_unrealized_pnl }.sum_real();
public double total_realized_pnl => new[] { sod_realized_pnl, day_realized_pnl }.sum_real();
public double total_unrealized_pnl => total_long_pos > total_short_pos
? (total_long_pos - total_short_pos) * effective_cpp * (bid_price - total_long_avg_price)
: (total_short_pos - total_long_pos) * effective_cpp * (total_short_avg_price - ask_price);
public double total_realized_pnl => (total_short_avg_price - total_long_avg_price) * effective_cpp * Math.Min(total_long_pos, total_short_pos);
public double total_delta => sod.delta.add_real(day.delta);
public double total_gamma => sod.gamma.add_real(day.gamma);
public double total_vega => sod.vega.add_real(day.vega);