Files
crypto_monitor_user/tests/test_price_snapshot_lib.py
T
dekun 53863559f4 Initialize crypto_monitor_user (user edition) from monitor codebase.
Retarget git remote, install path, and deploy docs from crypto_monitor to crypto_monitor_user.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:18:13 +08:00

36 lines
1.0 KiB
Python

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()