From 8511524d750930a619e39e6a30dbba39f8263af2 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Tue, 25 Aug 2026 18:09:46 +0800 Subject: [PATCH] security: make IBKR fixtures explicitly non-production Co-Authored-By: Codex --- strategy_platform_config.example.json | 10 +++++----- tests/test_ibkr_execution.py | 10 +++++----- tests/test_ibkr_portfolio.py | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/strategy_platform_config.example.json b/strategy_platform_config.example.json index 16c14b48..b2ab2598 100644 --- a/strategy_platform_config.example.json +++ b/strategy_platform_config.example.json @@ -13,8 +13,8 @@ "accounts": { "schwab": { "account_scope": "default", - "execution_mode": "live", - "dry_run_only": false + "execution_mode": "paper", + "dry_run_only": true } } }, @@ -27,9 +27,9 @@ }, "accounts": { "ibkr": { - "account_ids": ["U15998061"], - "execution_mode": "live", - "dry_run_only": false + "account_ids": ["U00000000"], + "execution_mode": "paper", + "dry_run_only": true } } } diff --git a/tests/test_ibkr_execution.py b/tests/test_ibkr_execution.py index d37def9f..93cfc796 100644 --- a/tests/test_ibkr_execution.py +++ b/tests/test_ibkr_execution.py @@ -110,14 +110,14 @@ def test_submit_order_intent_sets_account_when_provided(self) -> None: ib = FakeIB() report = submit_order_intent( ib, - OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U18308207"), + OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U00000001"), wait_seconds=0, stock_factory=FakeContract, market_order_factory=FakeMarketOrder, ) - self.assertEqual(ib.orders[0][1].account, "U18308207") - self.assertEqual(report.raw_payload["account_id"], "U18308207") + self.assertEqual(ib.orders[0][1].account, "U00000001") + self.assertEqual(report.raw_payload["account_id"], "U00000001") def test_submit_order_intent_rejects_notional_equity_order(self) -> None: ib = FakeIB() @@ -144,8 +144,8 @@ def test_submit_order_intent_rejects_conflicting_account_id(self) -> None: with self.assertRaises(ValueError): submit_order_intent( ib, - OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U18308207"), - account_id="U15998061", + OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U00000001"), + account_id="U00000000", wait_seconds=0, stock_factory=FakeContract, market_order_factory=FakeMarketOrder, diff --git a/tests/test_ibkr_portfolio.py b/tests/test_ibkr_portfolio.py index 21022526..3f3f5b43 100644 --- a/tests/test_ibkr_portfolio.py +++ b/tests/test_ibkr_portfolio.py @@ -16,13 +16,13 @@ def reqPositions(self): def positions(self): return [ SimpleNamespace( - account="U18308207", + account="U00000001", contract=SimpleNamespace(symbol="TQQQ"), position=3, avgCost=100.0, ), SimpleNamespace( - account="U18308207", + account="U00000001", contract=SimpleNamespace( symbol="TQQQ", secType="OPT", @@ -35,7 +35,7 @@ def positions(self): avgCost=3200.0, ), SimpleNamespace( - account="U15998061", + account="U00000000", contract=SimpleNamespace(symbol="AAPL"), position=5, avgCost=200.0, @@ -44,10 +44,10 @@ def positions(self): def accountValues(self): return [ - SimpleNamespace(account="U18308207", tag="NetLiquidation", currency="USD", value="1000"), - SimpleNamespace(account="U18308207", tag="AvailableFunds", currency="USD", value="250"), - SimpleNamespace(account="U15998061", tag="NetLiquidation", currency="USD", value="2000"), - SimpleNamespace(account="U15998061", tag="AvailableFunds", currency="USD", value="500"), + SimpleNamespace(account="U00000001", tag="NetLiquidation", currency="USD", value="1000"), + SimpleNamespace(account="U00000001", tag="AvailableFunds", currency="USD", value="250"), + SimpleNamespace(account="U00000000", tag="NetLiquidation", currency="USD", value="2000"), + SimpleNamespace(account="U00000000", tag="AvailableFunds", currency="USD", value="500"), ] @@ -55,14 +55,14 @@ class IbkrPortfolioTests(unittest.TestCase): def test_fetch_portfolio_snapshot_filters_by_account_id(self) -> None: ib = FakeIB() - snapshot = fetch_portfolio_snapshot(ib, account_ids=("U18308207",), wait_seconds=0) + snapshot = fetch_portfolio_snapshot(ib, account_ids=("U00000001",), wait_seconds=0) self.assertTrue(ib.req_positions_called) self.assertEqual(snapshot.total_equity, 1000.0) self.assertEqual(snapshot.buying_power, 250.0) self.assertEqual(tuple(position.symbol for position in snapshot.positions), ("TQQQ",)) - self.assertEqual(snapshot.positions[0].account_id, "U18308207") - self.assertEqual(snapshot.metadata["account_ids"], ("U18308207",)) + self.assertEqual(snapshot.positions[0].account_id, "U00000001") + self.assertEqual(snapshot.metadata["account_ids"], ("U00000001",)) self.assertEqual(snapshot.metadata["option_positions"][0]["underlier"], "TQQQ") self.assertEqual(snapshot.metadata["option_positions"][0]["right"], "C") self.assertEqual(snapshot.metadata["option_positions"][0]["strike"], 70.0) @@ -70,7 +70,7 @@ def test_fetch_portfolio_snapshot_filters_by_account_id(self) -> None: def test_fetch_portfolio_snapshot_sums_selected_accounts(self) -> None: snapshot = fetch_portfolio_snapshot( FakeIB(), - account_ids=("U18308207", "U15998061"), + account_ids=("U00000001", "U00000000"), wait_seconds=0, )