Skip to content

Commit 1354f43

Browse files
authored
Merge pull request #363 from QuantStrategyLab/codex/qpk-public-account-fixtures
security: make IBKR fixtures explicitly non-production
2 parents 9ae5f99 + 8511524 commit 1354f43

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

strategy_platform_config.example.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"accounts": {
1414
"schwab": {
1515
"account_scope": "default",
16-
"execution_mode": "live",
17-
"dry_run_only": false
16+
"execution_mode": "paper",
17+
"dry_run_only": true
1818
}
1919
}
2020
},
@@ -27,9 +27,9 @@
2727
},
2828
"accounts": {
2929
"ibkr": {
30-
"account_ids": ["U15998061"],
31-
"execution_mode": "live",
32-
"dry_run_only": false
30+
"account_ids": ["U00000000"],
31+
"execution_mode": "paper",
32+
"dry_run_only": true
3333
}
3434
}
3535
}

tests/test_ibkr_execution.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ def test_submit_order_intent_sets_account_when_provided(self) -> None:
110110
ib = FakeIB()
111111
report = submit_order_intent(
112112
ib,
113-
OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U18308207"),
113+
OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U00000001"),
114114
wait_seconds=0,
115115
stock_factory=FakeContract,
116116
market_order_factory=FakeMarketOrder,
117117
)
118118

119-
self.assertEqual(ib.orders[0][1].account, "U18308207")
120-
self.assertEqual(report.raw_payload["account_id"], "U18308207")
119+
self.assertEqual(ib.orders[0][1].account, "U00000001")
120+
self.assertEqual(report.raw_payload["account_id"], "U00000001")
121121

122122
def test_submit_order_intent_rejects_notional_equity_order(self) -> None:
123123
ib = FakeIB()
@@ -144,8 +144,8 @@ def test_submit_order_intent_rejects_conflicting_account_id(self) -> None:
144144
with self.assertRaises(ValueError):
145145
submit_order_intent(
146146
ib,
147-
OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U18308207"),
148-
account_id="U15998061",
147+
OrderIntent(symbol="SPY", side="buy", quantity=5, account_id="U00000001"),
148+
account_id="U00000000",
149149
wait_seconds=0,
150150
stock_factory=FakeContract,
151151
market_order_factory=FakeMarketOrder,

tests/test_ibkr_portfolio.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def reqPositions(self):
1616
def positions(self):
1717
return [
1818
SimpleNamespace(
19-
account="U18308207",
19+
account="U00000001",
2020
contract=SimpleNamespace(symbol="TQQQ"),
2121
position=3,
2222
avgCost=100.0,
2323
),
2424
SimpleNamespace(
25-
account="U18308207",
25+
account="U00000001",
2626
contract=SimpleNamespace(
2727
symbol="TQQQ",
2828
secType="OPT",
@@ -35,7 +35,7 @@ def positions(self):
3535
avgCost=3200.0,
3636
),
3737
SimpleNamespace(
38-
account="U15998061",
38+
account="U00000000",
3939
contract=SimpleNamespace(symbol="AAPL"),
4040
position=5,
4141
avgCost=200.0,
@@ -44,33 +44,33 @@ def positions(self):
4444

4545
def accountValues(self):
4646
return [
47-
SimpleNamespace(account="U18308207", tag="NetLiquidation", currency="USD", value="1000"),
48-
SimpleNamespace(account="U18308207", tag="AvailableFunds", currency="USD", value="250"),
49-
SimpleNamespace(account="U15998061", tag="NetLiquidation", currency="USD", value="2000"),
50-
SimpleNamespace(account="U15998061", tag="AvailableFunds", currency="USD", value="500"),
47+
SimpleNamespace(account="U00000001", tag="NetLiquidation", currency="USD", value="1000"),
48+
SimpleNamespace(account="U00000001", tag="AvailableFunds", currency="USD", value="250"),
49+
SimpleNamespace(account="U00000000", tag="NetLiquidation", currency="USD", value="2000"),
50+
SimpleNamespace(account="U00000000", tag="AvailableFunds", currency="USD", value="500"),
5151
]
5252

5353

5454
class IbkrPortfolioTests(unittest.TestCase):
5555
def test_fetch_portfolio_snapshot_filters_by_account_id(self) -> None:
5656
ib = FakeIB()
5757

58-
snapshot = fetch_portfolio_snapshot(ib, account_ids=("U18308207",), wait_seconds=0)
58+
snapshot = fetch_portfolio_snapshot(ib, account_ids=("U00000001",), wait_seconds=0)
5959

6060
self.assertTrue(ib.req_positions_called)
6161
self.assertEqual(snapshot.total_equity, 1000.0)
6262
self.assertEqual(snapshot.buying_power, 250.0)
6363
self.assertEqual(tuple(position.symbol for position in snapshot.positions), ("TQQQ",))
64-
self.assertEqual(snapshot.positions[0].account_id, "U18308207")
65-
self.assertEqual(snapshot.metadata["account_ids"], ("U18308207",))
64+
self.assertEqual(snapshot.positions[0].account_id, "U00000001")
65+
self.assertEqual(snapshot.metadata["account_ids"], ("U00000001",))
6666
self.assertEqual(snapshot.metadata["option_positions"][0]["underlier"], "TQQQ")
6767
self.assertEqual(snapshot.metadata["option_positions"][0]["right"], "C")
6868
self.assertEqual(snapshot.metadata["option_positions"][0]["strike"], 70.0)
6969

7070
def test_fetch_portfolio_snapshot_sums_selected_accounts(self) -> None:
7171
snapshot = fetch_portfolio_snapshot(
7272
FakeIB(),
73-
account_ids=("U18308207", "U15998061"),
73+
account_ids=("U00000001", "U00000000"),
7474
wait_seconds=0,
7575
)
7676

0 commit comments

Comments
 (0)