Risk per trade and daily loss limit

Per-trade risk (chapters 71-72) controls one position's downside. A daily loss limit controls the compounding failure mode: a strategy having a genuinely bad day, or a bug causing repeated bad trades, and your bot just... continuing to trade through it.

The two numbers you need, decided in advance, not in the moment

MAX_RISK_PER_TRADE_PCT = 1.0     # per-trade, from chapters 71-72
MAX_DAILY_LOSS_PCT = 3.0          # total realized+unrealized loss that halts trading for the day

MAX_DAILY_LOSS_PCT should be a small multiple of MAX_RISK_PER_TRADE_PCT (e.g. 3x means you can absorb ~3 consecutive full-stop losses before halting) — not an arbitrary separate number picked without reference to per-trade risk.

Enforcement — check before every new entry, not just at end of day

def check_daily_loss_limit(account_start_equity: float, current_equity: float, max_loss_pct: float) -> bool:
    """Returns True if trading should continue, False if the daily limit is breached."""
    loss_pct = (account_start_equity - current_equity) / account_start_equity * 100
    return loss_pct < max_loss_pct

def get_current_equity(kite) -> float:
    margins = kite.margins(segment="equity")
    return margins["net"]   # cash + unrealized MTM, chapter 12
def guarded_entry(kite, order_manager, account_start_equity, **order_params):
    current_equity = get_current_equity(kite)
    if not check_daily_loss_limit(account_start_equity, current_equity, MAX_DAILY_LOSS_PCT):
        logging.warning("Daily loss limit breached — refusing new entry")
        return {"success": False, "reason": "daily_loss_limit"}
    return order_manager.place(**order_params)

When the limit is hit: halt new entries, don't force-close existing ones

Breaching a daily loss limit should stop your bot from opening *new* risk — it should generally not automatically force-close existing positions at whatever price is available (that's a separate, more severe action — see chapter 90's kill switch for when full liquidation is warranted). Distinguish "stop digging" from "sell everything now," they're different severities of response.

Record account_start_equity at a fixed point, not a moving target

Capture it once at the start of the trading day (e.g. right after market open) and hold it fixed for that day's loss calculation — don't recompute it from a fluctuating current value, or the limit becomes meaningless (a losing account's "start" would keep drifting down with it).

account_start_equity = get_current_equity(kite)   # captured once, at session start

Next: 074 — Portfolio-level exposure limits