This commit is contained in:
2026-09-05 00:23:55 +08:00
parent 9f01eb8dc5
commit 6c2eca8fdc
18 changed files with 59 additions and 51 deletions

View File

@@ -13,7 +13,7 @@ from strategy.trend.order import OrderBook, PlaceOrderRequest
from strategy.trend.open import do_open
from strategy.trend.positions import LOSS_TIERS, handle_loss, manage_positions
from strategy.trend.boot import RunOnce
from strategy.trend.state import STATUS_OK, STATUS_UNKNOWN, State, StateItem
from strategy.trend.state import STATUS_OK, State, StateItem
class FakeClient:
@@ -238,6 +238,13 @@ class TrendTests(unittest.TestCase):
)
self.assertEqual(state.get("A").base_status, STATUS_OK)
canceled = OrderItem("2", "A", "BUY", "", "54", None, 50, "local-1")
item = state.get("A")
item.base_status = "ING"
state.set(item)
state.reconcile([position], [completed, canceled])
self.assertEqual(state.get("A").base_status, "")
def test_low_cash_still_runs_position_management(self):
client = SimpleNamespace(
portfolio=lambda: Portfolio(
@@ -276,7 +283,7 @@ class TrendTests(unittest.TestCase):
"A",
base_order_id="missing-order",
base_qty=100,
base_status=STATUS_UNKNOWN,
base_status="ING",
))
state.save()
client = SimpleNamespace(