fix: 箱体/收敛突破标记价反向越界时自动撤销监控

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-29 10:54:36 +08:00
parent 5b3448b52b
commit a0d57fc65e
12 changed files with 204 additions and 45 deletions
+34
View File
@@ -0,0 +1,34 @@
import unittest
from key_monitor_lib import (
BOX_BREAKOUT_CLOSE_OPPOSITE,
box_breakout_invalidate_by_mark,
box_breakout_invalidate_edge_label,
)
class BoxBreakoutInvalidateTests(unittest.TestCase):
def test_short_invalidates_above_upper(self):
self.assertTrue(box_breakout_invalidate_by_mark("short", 62.511, 61.746, 60.569))
def test_short_stays_valid_inside_or_below(self):
self.assertFalse(box_breakout_invalidate_by_mark("short", 61.0, 61.746, 60.569))
self.assertFalse(box_breakout_invalidate_by_mark("short", 60.0, 61.746, 60.569))
def test_long_invalidates_below_lower(self):
self.assertTrue(box_breakout_invalidate_by_mark("long", 94.0, 100.0, 95.0))
def test_long_stays_valid_inside_or_above(self):
self.assertFalse(box_breakout_invalidate_by_mark("long", 98.0, 100.0, 95.0))
self.assertFalse(box_breakout_invalidate_by_mark("long", 101.0, 100.0, 95.0))
def test_edge_label(self):
self.assertEqual(box_breakout_invalidate_edge_label("long"), "下沿")
self.assertEqual(box_breakout_invalidate_edge_label("short"), "上沿")
def test_close_reason_constant(self):
self.assertEqual(BOX_BREAKOUT_CLOSE_OPPOSITE, "box_opposite_break")
if __name__ == "__main__":
unittest.main()