Park partial hedge plans for manual leg complete instead of auto-close.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""半腿失败:手动补开 vs 自动平."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from lib.hedge_plan.hedge_plan_orders_lib import (
|
||||
manual_complete_on_partial,
|
||||
partial_auto_close_enabled,
|
||||
)
|
||||
|
||||
|
||||
class PartialManualTests(unittest.TestCase):
|
||||
def test_manual_default_forces_auto_close_off(self):
|
||||
with mock.patch.dict(os.environ, {}, clear=False):
|
||||
os.environ.pop("HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL", None)
|
||||
os.environ["HEDGE_PLAN_PARTIAL_AUTO_CLOSE_OPTION"] = "true"
|
||||
self.assertTrue(manual_complete_on_partial())
|
||||
self.assertFalse(partial_auto_close_enabled())
|
||||
|
||||
def test_manual_off_allows_auto_close(self):
|
||||
with mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL": "false",
|
||||
"HEDGE_PLAN_PARTIAL_AUTO_CLOSE_OPTION": "true",
|
||||
},
|
||||
):
|
||||
self.assertFalse(manual_complete_on_partial())
|
||||
self.assertTrue(partial_auto_close_enabled())
|
||||
|
||||
def test_both_off(self):
|
||||
with mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL": "false",
|
||||
"HEDGE_PLAN_PARTIAL_AUTO_CLOSE_OPTION": "false",
|
||||
},
|
||||
):
|
||||
self.assertFalse(partial_auto_close_enabled())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user