Fix Gate mark/PnL/TP-SL snapshot and intraday order UI

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-06 22:04:19 +08:00
parent 5e4f885f80
commit d4a76f05d2
10 changed files with 315 additions and 50 deletions
+35
View File
@@ -0,0 +1,35 @@
import unittest
from lib.hub.price_snapshot_lib import resolve_order_snapshot_price
class TestPriceSnapshotLib(unittest.TestCase):
def test_resolve_from_cached_prices(self):
px = resolve_order_snapshot_price("ETH/USDT", {"ETH/USDT": 1750.5})
self.assertEqual(px, 1750.5)
def test_resolve_from_position_mark(self):
prow = {"info": {"mark_price": 1760.0}, "contracts": 1}
px = resolve_order_snapshot_price("ETH/USDT", {}, position_row=prow)
self.assertEqual(px, 1760.0)
def test_resolve_mark_fn_before_entry(self):
px = resolve_order_snapshot_price(
"ETH/USDT",
{},
get_mark_price_fn=lambda s: 1755.0,
fallback_entry=1700.0,
)
self.assertEqual(px, 1755.0)
def test_resolve_fallback_entry(self):
px = resolve_order_snapshot_price(
"ETH/USDT",
{},
fallback_entry=1700.0,
)
self.assertEqual(px, 1700.0)
if __name__ == "__main__":
unittest.main()