pull/12760/head
vijay sharma 3 months ago
parent 003fc5ba2d
commit 0da3d80720

@ -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"

@ -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

@ -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

@ -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}},
}

@ -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

@ -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(

Loading…
Cancel
Save