Align hedge-plan perp contract precision with exchange and show TP/SL USDT PnL.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-14 12:49:03 +08:00
parent 036501b70c
commit 9e0d89bd01
8 changed files with 148 additions and 19 deletions
+6
View File
@@ -4,6 +4,7 @@ import unittest
from lib.hedge_plan.hedge_plan_calc_lib import (
build_options_options_preview,
build_perp_options_preview,
floor_contracts_to_precision,
gate_status,
option_expiry_pnl,
option_premium_total,
@@ -81,6 +82,11 @@ class TestHedgePlanCalc(unittest.TestCase):
10,
)
def test_floor_contracts_to_precision(self):
self.assertEqual(floor_contracts_to_precision(4.569713, 4), 4.5697)
self.assertEqual(floor_contracts_to_precision(4.569713, 0), 4.0)
self.assertEqual(floor_contracts_to_precision(0, 4), 0.0)
if __name__ == "__main__":
unittest.main()