diff --git a/scripts/gates/p16_order_router.sh b/scripts/gates/p16_order_router.sh index 0d3e80d25..eaf397980 100644 --- a/scripts/gates/p16_order_router.sh +++ b/scripts/gates/p16_order_router.sh @@ -8,6 +8,7 @@ source scripts/gates/common.sh "p16" "$@" # Determinism export BREEZE_MOCK=1 export FT_FORCE_MARKET_OPEN=1 +export FT_ENABLE_LIVE_ORDERS=1 unset BREEZE_API_KEY BREEZE_API_SECRET BREEZE_SESSION_TOKEN # Paths @@ -18,8 +19,8 @@ if [ ! -f "$BASE_CFG" ]; then echo "ERROR: Config missing: $BASE_CFG" finish_gate 1 fi -# Relax RiskGuard for P16 tests (disable intraday cutoff/max trades) -jq '.risk_guard.enabled = false' "$BASE_CFG" > "$GATE_CFG" +# Relax RiskGuard for P16 tests (disable intraday cutoff/max trades) and Enable Live Trading +jq '.risk_guard.enabled = false | .icicibreeze.live_trading.enabled = true' "$BASE_CFG" > "$GATE_CFG" PY_SCRIPT="$ARTIFACT_DIR/run_p16_test.py" diff --git a/tests/exchange/test_icicibreeze_integration_degraded.py b/tests/exchange/test_icicibreeze_integration_degraded.py index 3c04ebe5c..caca1e7f5 100644 --- a/tests/exchange/test_icicibreeze_integration_degraded.py +++ b/tests/exchange/test_icicibreeze_integration_degraded.py @@ -14,9 +14,13 @@ def degraded_exchange_forced(): "FT_DEGRADED_MODE": "1", "FT_DEGRADED_BLOCK_ENTRIES": "1", "FT_RATE_LIMIT_DISABLE": "1", # Disable limit to isolate degraded + "FT_ENABLE_LIVE_ORDERS": "1", }, ): - exposure = {"risk_guard": {"enabled": False}} + exposure = { + "risk_guard": {"enabled": False}, + "icicibreeze": {"live_trading": {"enabled": True}}, + } exchange = BreezeCCXT(config=exposure) yield exchange diff --git a/tests/exchange/test_icicibreeze_market_hours_block.py b/tests/exchange/test_icicibreeze_market_hours_block.py index 2a4df1bc3..0aefffaa4 100644 --- a/tests/exchange/test_icicibreeze_market_hours_block.py +++ b/tests/exchange/test_icicibreeze_market_hours_block.py @@ -12,10 +12,19 @@ def exchange_forced_closed(): """Fixture providing BreezeCCXT instance with market forced closed.""" with mock.patch.dict( os.environ, - {"FT_FORCE_MARKET_CLOSED": "1", "BREEZE_MOCK": "1", "RISK_GUARD_ENABLED": "false"}, + { + "FT_FORCE_MARKET_CLOSED": "1", + "BREEZE_MOCK": "1", + "RISK_GUARD_ENABLED": "false", + "FT_ENABLE_LIVE_ORDERS": "1", # Pass Live Guard + }, ): # Initialize exchange after env var set to ensure guard picks it up - config = {"dry_run": True, "risk_guard": {"enabled": False}} + config = { + "dry_run": True, + "risk_guard": {"enabled": False}, + "icicibreeze": {"live_trading": {"enabled": True}}, + } exchange = BreezeCCXT(config) yield exchange @@ -24,9 +33,19 @@ def exchange_forced_closed(): def exchange_forced_open(): """Fixture providing BreezeCCXT instance with market forced open.""" with mock.patch.dict( - os.environ, {"FT_FORCE_MARKET_OPEN": "1", "BREEZE_MOCK": "1", "RISK_GUARD_ENABLED": "false"} + os.environ, + { + "FT_FORCE_MARKET_OPEN": "1", + "BREEZE_MOCK": "1", + "RISK_GUARD_ENABLED": "false", + "FT_ENABLE_LIVE_ORDERS": "1", # Pass Live Guard + }, ): - config = {"dry_run": True, "risk_guard": {"enabled": False}} + config = { + "dry_run": True, + "risk_guard": {"enabled": False}, + "icicibreeze": {"live_trading": {"enabled": True}}, + } exchange = BreezeCCXT(config) yield exchange diff --git a/tests/exchange/test_icicibreeze_paper.py b/tests/exchange/test_icicibreeze_paper.py index 7edefdb9d..e29631cae 100644 --- a/tests/exchange/test_icicibreeze_paper.py +++ b/tests/exchange/test_icicibreeze_paper.py @@ -17,6 +17,7 @@ def paper_config(tmp_path): "key": "mock_key", "secret": "mock_secret", "icici_mode": "mock", # To fetch mock prices for execution + "icicibreeze": {"live_trading": {"enabled": True}}, } diff --git a/tests/exchange/test_icicibreeze_rate_limit_applied.py b/tests/exchange/test_icicibreeze_rate_limit_applied.py index 8b2955349..317739c99 100644 --- a/tests/exchange/test_icicibreeze_rate_limit_applied.py +++ b/tests/exchange/test_icicibreeze_rate_limit_applied.py @@ -17,9 +17,13 @@ def rate_limited_exchange(): "FT_RATE_LIMIT_PER_MINUTE": "10", "FT_RATE_LIMIT_MODE": "block", "FT_RATE_LIMIT_DISABLE": "0", + "FT_ENABLE_LIVE_ORDERS": "1", }, ): - exposure = {"risk_guard": {"enabled": False}} # Disable risk guard to isolate rate limit + exposure = { + "risk_guard": {"enabled": False}, + "icicibreeze": {"live_trading": {"enabled": True}}, + } exchange = BreezeCCXT(config=exposure) yield exchange diff --git a/tests/exchange/test_icicibreeze_risk_block_mock.py b/tests/exchange/test_icicibreeze_risk_block_mock.py index 45d796154..fad6a73fe 100644 --- a/tests/exchange/test_icicibreeze_risk_block_mock.py +++ b/tests/exchange/test_icicibreeze_risk_block_mock.py @@ -16,6 +16,7 @@ def mock_exchange(): "allow_exits_when_blocked": True, }, "options": {"key": "mock_key", "secret": "mock_secret", "session_token": "mock_token"}, + "icicibreeze": {"live_trading": {"enabled": True}}, } exchange = BreezeCCXT(config) # exchange._set_mock_mode(True) # Not needed/doesn't exist, api_key="mock_key" triggers it @@ -26,7 +27,7 @@ def mock_exchange(): async def test_risk_block_buy_entry(mock_exchange): # Should raise OperationalException with risk_block prefix # Must force market open to reach risk check - with patch.dict(os.environ, {"FT_FORCE_MARKET_OPEN": "1"}): + with patch.dict(os.environ, {"FT_FORCE_MARKET_OPEN": "1", "FT_ENABLE_LIVE_ORDERS": "1"}): with pytest.raises(OperationalException, match="risk_block:max_trades_per_day"): # Try await, if fails catch type error? No, better to detect. if hasattr(mock_exchange, "create_order") and asyncio.iscoroutinefunction(