修复全仓复利关闭后仍无法开仓:前端不再残留选中全仓,后端强制改指定张数。
审计:开关关闭时隐藏全仓芯片并自动勾选指定张数;报价/余额热同步 compound_full_enabled;API 将 compound_full 归一为 sheets(缺张数默认1);单测覆盖开关开关两种归一路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,6 +64,35 @@ class TestOptionsBudgetModes(unittest.TestCase):
|
||||
self.assertIsNone(msg)
|
||||
self.assertEqual(count_live_option_positions([]), 0)
|
||||
|
||||
def test_normalize_size_mode_when_compound_off(self):
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
from lib.options import options_register as reg
|
||||
|
||||
with patch.dict(os.environ, {"OKX_OPTIONS_COMPOUND_FULL_ENABLED": "false"}):
|
||||
mode, note = reg._normalize_size_mode("compound_full")
|
||||
self.assertEqual(mode, "sheets")
|
||||
self.assertIsNotNone(note)
|
||||
mode2, note2 = reg._normalize_size_mode("budget_full")
|
||||
self.assertEqual(mode2, "budget_full")
|
||||
self.assertIsNone(note2)
|
||||
mode3, _ = reg._normalize_size_mode("sheets")
|
||||
self.assertEqual(mode3, "sheets")
|
||||
|
||||
def test_normalize_size_mode_when_compound_on(self):
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
from lib.options import options_register as reg
|
||||
|
||||
with patch.dict(os.environ, {"OKX_OPTIONS_COMPOUND_FULL_ENABLED": "true"}):
|
||||
mode, note = reg._normalize_size_mode("budget_full")
|
||||
self.assertEqual(mode, "compound_full")
|
||||
self.assertIsNone(note)
|
||||
mode2, _ = reg._normalize_size_mode("compound_full")
|
||||
self.assertEqual(mode2, "compound_full")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user