Deduct round-trip taker fees from estimated perp PnL.

Unify hub/instance TP profit, calc_pnl, and push/accounting to net of 0.05% per side; leave exchange floating PnL unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 15:12:52 +08:00
parent d5e6132b13
commit 2269bc51ff
13 changed files with 307 additions and 20 deletions
+2 -1
View File
@@ -88,7 +88,8 @@ class HubCalculatorLibTests(unittest.TestCase):
self.assertEqual(data["first_contracts"], 10.0)
self.assertEqual(len(data["rows"]), 1)
self.assertEqual(data["rows"][0]["loss_at_sl_u"], 50.0)
self.assertEqual(data["rows"][0]["profit_at_tp_u"], 200.0)
# 毛利 200 双边费 (1000+1200)*0.0005=1.1 → 198.9
self.assertEqual(data["rows"][0]["profit_at_tp_u"], 198.9)
@patch("lib.hub.hub_calculator_lib._resolve_market", return_value=_mock_resolve())
def test_roll_calculator_chain_two_legs(self, _mock):