The mechanics of short selling: Cash inflow vs. balance sheet liability

In algorithmic trading, short selling is commonly treated as simply passing a negative integer to an order method (self.sell(size=100)). While this abstraction is conceptually clean, the underlying financial engineering is fundamentally distinct from buying long.

When a quantitative trader initiates a long position, cash leaves the brokerage account in exchange for an unencumbered asset. The transaction is intuitive: available cash decreases, position market value becomes positive, and net portfolio equity remains identical (ignoring execution slippage and commissions).

Code
Long Entry: Cash_new = Cash_old - (Size * Price) - Commission
Position Value = Size * Price  (where Size > 0)
Net Equity = Cash_new + Position Value = Cash_old - Commission

Short selling reverses this cash flow dynamic. To sell an equity you do not own, your prime broker borrows shares from a custodian or another margin client and sells them into the market on your behalf. This execution generates an immediate gross cash inflow credited to your account ledger. However, this cash does not belong to you as free purchasing power; it is accompanied by an open liability to return the borrowed shares in kind at an unspecified future date.

Code
Short Entry: Cash_new = Cash_old + (|Size| * Price) - Commission
Position Value = Size * Price  (where Size < 0)
Net Equity = Cash_new + Position Value = Cash_old - Commission
Code
flowchart TD
    subgraph ShortAccounting ["Short Sale Double-Entry Mechanics"]
        A["Borrow Shares from Prime Broker"] --> B["Sell Shares on Market at $P_0"]
        B --> C["Gross Cash Inflow: +(|Size| × $P_0)"]
        B --> D["Open Delivery Obligation: -|Size| Shares"]
        C --> E["Total Cash Balance Increases"]
        D --> F["Position Market Value is Negative Liability"]
        E & F --> G["Net Portfolio Equity = Cash + Position Value"]
    end

The mathematical identity governing the portfolio state is invariant:

Code
Net Equity = Cash + Position Market Value

Because Size is negative for a short position (Size &lt; 0), Position Market Value is a negative dollar quantity. When the price of the borrowed asset escalates, your liability expands, and total portfolio equity declines despite a massive nominal cash balance.

The windfall cash cognitive trap

A classic failure mode among novice quantitative researchers is inspecting the broker cash readout after entering a short position and assuming the strategy generated instant alpha.

Consider an account initialized with $10,000. The strategy executes a short sale of 100 shares of an asset trading at $100:

  1. Starting Account: Cash = $10,000, Position = 0, Net Equity = $10,000.
  2. Post-Short Ledger: Gross proceeds of $10,000 are delivered to the cash ledger. Cash registers $20,000.
  3. The Trap: An automated sizing heuristic querying self.broker.get_cash() sees $20,000 in spendable capital and attempts to deploy additional margin, believing the balance doubled.
  4. The Reality: The account holds $20,000 in cash offset by a -$10,000 open delivery obligation. Net equity is still $10,000 (less commissions). The extra $10,000 in cash is encumbered collateral held by the clearing broker.

Failing to reconcile cash versus net equity leads to corrupted position sizing algorithms, distorted margin calculations, and sudden margin calls when simulating margin-dependent strategies.


Backtrader shortcash parameter: Two divergent balance sheet paradigms

To accommodate different accounting philosophies and legacy codebases, Backtrader provides a broker configuration switch: broker.set_shortcash(True) versus broker.set_shortcash(False).

Configuring short cash handling in Backtrader
import backtrader as bt

cerebro = bt.Cerebro()

# Method 1: Mutating default broker instance
cerebro.broker.set_shortcash(True)  # Default behavior since release 1.9.7.105

# Method 2: Instantiating BackBroker directly
cerebro.broker = bt.brokers.BackBroker(shortcash=True)

This single boolean completely alters how Backtrader calculates internal cash balances, position market values, and order affordability during a short trade.

Paradigm A: shortcash = True (Modern Default)

Introduced in Backtrader version 1.9.7.105, shortcash=True aligns Backtrader with conventional double-entry brokerage accounting.

Under this setting:

  • Cash Account: Credited with the full notional proceeds of the short sale upon fill execution.
  • Position Market Value: Evaluated via comminfo.getvaluesize(position.size, price), which returns position.size * price. Because position.size &lt; 0, the position market value is strictly negative.
  • Mark-to-Market: As the asset price rises, the negative position value deepens (e.g., from -$10,000 to -$11,000), reducing net equity while nominal cash remains constant.
  • Cover Execution: Purchasing shares to cover deducts cash equal to abs(size) * cover_price + commission, closing the negative position back to zero.

Paradigm B: shortcash = False (Legacy Collateral-Deduction Mode)

Prior to version 1.9.7.105, Backtrader treated all position openings symmetrically as capital expenditures. Under shortcash=False:

  • Cash Account: Debited as an "operation cost" equal to abs(size) * price + commission. The broker removes cash from your account as if you bought the asset, effectively locking up 100% notional collateral upfront.
  • Position Market Value: Calculated as positive equity through comminfo.getvalue(position, price). The broker models the short position as an asset that gains value when the underlying market price drops:
    Code
    Value = (Position Price * Size) + (Position Price - Market Price) * Size
    Backtrader wraps this figure in abs() within BackBroker.getvalue(), producing a positive asset value.
  • Cover Execution: When the trade is covered, the initial locked collateral is returned to cash alongside realized profit or loss.
Accounting Dimensionshortcash = True (Default)shortcash = False (Legacy)
Cash on Short FillCredited: Cash += Proceeds - CommDebited: Cash -= Notional - Comm
Position ValuationNegative: Size * Price (&lt; 0)Positive: abs(Cost + Unrealized PnL)
Cash Balance SemanticsGross liquidity (free cash + borrow collateral)Unencumbered free cash remaining
broker.get_cash() RiskHigh risk of over-sizing if treated as spendableSafe from over-sizing; reflects free buffer
Net Portfolio EquityCash + Position ValueCash + Position Value
Final Net ReturnMathematically identicalMathematically identical

Both modes produce the exact same bottom-line net equity curve. However, because their intermediate cash readings diverge radically, any custom strategy indicator, risk gate, or dynamic sizer querying self.broker.get_cash() will behave unpredictably if written without explicit knowledge of this setting.


End-to-end ledger audit: A multi-bar lifecycle of a short position

To eliminate ambiguity, let us construct a deterministic, bar-by-bar audit of a short trade. We will track a 50-share short position through entry, an adverse price move (floating drawdown), a favorable price reversal (floating profit), daily borrow interest accrual, and final cover execution.

Backtrader simulation parameters

  • Initial Cash: $10,000.00
  • Bar 1 (2026-01-01): Close = $100.00. Strategy submits sell(size=50).
  • Bar 2 (2026-01-02): Open = $105.00, Close = $105.00. Order executes at $105.00.
  • Bar 3 (2026-01-03): Open = $110.00, Close = $110.00. Floating loss (adverse price climb).
  • Bar 4 (2026-01-04): Open = $95.00, Close = $95.00. Floating profit (market dump). Strategy submits close().
  • Bar 5 (2026-01-05): Open = $90.00, Close = $90.00. Order executes to buy 50 shares at $90.00. Position flat.
  • Commission: 0.1% proportional commission (commission=0.001).
  • Short Borrow Fee: 5.0% annual borrow interest (interest=0.05).

Here is the fully reproducible Python audit script:

short_selling_ledger_audit.py
import backtrader as bt
import pandas as pd
import datetime

# Construct synthetic deterministic price history
dates = pd.date_range("2026-01-01", periods=5, freq="D")
data_df = pd.DataFrame(
    {
        "open": [100.0, 105.0, 110.0, 95.0, 90.0],
        "high": [102.0, 107.0, 112.0, 97.0, 92.0],
        "low": [98.0, 103.0, 108.0, 93.0, 88.0],
        "close": [100.0, 105.0, 110.0, 95.0, 90.0],
        "volume": [10000, 10000, 10000, 10000, 10000],
    },
    index=dates,
)


class LedgerAuditStrategy(bt.Strategy):
    params = (("shortcash", True),)

    def __init__(self):
        self.step = 0

    def notify_order(self, order):
        if order.status == order.Completed:
            action = "BUY (COVER)" if order.isbuy() else "SELL (SHORT)"
            print(
                f"  >>> EXECUTION: {action} {abs(order.executed.size)} units @ "
                f"${order.executed.price:.2f} | Comm: ${order.executed.comm:.2f}"
            )
        elif order.status in [order.Canceled, order.Margin, order.Rejected]:
            print(f"  >>> ORDER REJECTED / MARGIN CALL: {order.getstatusname()}")

    def notify_trade(self, trade):
        if trade.isclosed:
            print(
                f"  >>> TRADE CLOSED: Gross PnL=${trade.pnl:.2f} | "
                f"Net PnL (after comm & interest)=${trade.pnlcomm:.2f}"
            )

    def next(self):
        dt = self.data.datetime.date(0)
        close_price = self.data.close[0]
        pos = self.getposition()
        cash = self.broker.get_cash()
        net_value = self.broker.get_value()
        position_market_value = net_value - cash

        print(
            f"{dt} | Close: ${close_price:6.2f} | Pos: {pos.size:4d} | "
            f"Cash: ${cash:9.2f} | PosVal: ${position_market_value:9.2f} | "
            f"Net Equity: ${net_value:9.2f}"
        )

        if self.step == 0:
            # Day 1: Trigger short entry on Bar 2 open
            self.sell(size=50)
        elif self.step == 3:
            # Day 4: Trigger cover on Bar 5 open
            self.close()

        self.step += 1


def run_audit(shortcash_flag: bool):
    label = "shortcash=True (Modern Default)" if shortcash_flag else "shortcash=False (Legacy Collateral)"
    print(f"\n=======================================================")
    print(f" AUDIT RUN: {label}")
    print(f"=======================================================")

    cerebro = bt.Cerebro()
    data = bt.feeds.PandasData(dataname=data_df)
    cerebro.adddata(data)
    cerebro.addstrategy(LedgerAuditStrategy, shortcash=shortcash_flag)

    cerebro.broker.set_cash(10000.0)
    cerebro.broker.set_shortcash(shortcash_flag)
    
    # 0.1% commission, 5% annual borrow rate
    cerebro.broker.setcommission(commission=0.001, interest=0.05)

    cerebro.run()


if __name__ == "__main__":
    run_audit(shortcash_flag=True)
    run_audit(shortcash_flag=False)

Execution console output

Running the above audit yields exact, unedited ledger statements:

Code
=======================================================
 AUDIT RUN: shortcash=True (Modern Default)
=======================================================
2026-01-01 | Close: $100.00 | Pos:    0 | Cash: $ 10000.00 | PosVal: $     0.00 | Net Equity: $ 10000.00
  >>> EXECUTION: SELL (SHORT) 50 units @ $105.00 | Comm: $5.25
2026-01-02 | Close: $105.00 | Pos:  -50 | Cash: $ 15244.75 | PosVal: $ -5250.00 | Net Equity: $  9994.75
2026-01-03 | Close: $110.00 | Pos:  -50 | Cash: $ 15244.03 | PosVal: $ -5500.00 | Net Equity: $  9744.03
2026-01-04 | Close: $ 95.00 | Pos:  -50 | Cash: $ 15243.31 | PosVal: $ -4750.00 | Net Equity: $ 10493.31
  >>> EXECUTION: BUY (COVER) 50 units @ $90.00 | Comm: $6.66
  >>> TRADE CLOSED: Gross PnL=$750.00 | Net PnL (after comm & interest)=$738.09
2026-01-05 | Close: $ 90.00 | Pos:    0 | Cash: $ 10738.09 | PosVal: $     0.00 | Net Equity: $ 10738.09

=======================================================
 AUDIT RUN: shortcash=False (Legacy Collateral)
=======================================================
2026-01-01 | Close: $100.00 | Pos:    0 | Cash: $ 10000.00 | PosVal: $     0.00 | Net Equity: $ 10000.00
  >>> EXECUTION: SELL (SHORT) 50 units @ $105.00 | Comm: $5.25
2026-01-02 | Close: $105.00 | Pos:  -50 | Cash: $  4744.75 | PosVal: $  5250.00 | Net Equity: $  9994.75
2026-01-03 | Close: $110.00 | Pos:  -50 | Cash: $  4744.03 | PosVal: $  5000.00 | Net Equity: $  9744.03
2026-01-04 | Close: $ 95.00 | Pos:  -50 | Cash: $  4743.31 | PosVal: $  5750.00 | Net Equity: $ 10493.31
  >>> EXECUTION: BUY (COVER) 50 units @ $90.00 | Comm: $6.66
  >>> TRADE CLOSED: Gross PnL=$750.00 | Net PnL (after comm & interest)=$738.09
2026-01-05 | Close: $ 90.00 | Pos:    0 | Cash: $ 10738.09 | PosVal: $     0.00 | Net Equity: $ 10738.09

Step-by-step balance sheet reconciliation table

The following balance sheet matrix details every intermediate calculation across both accounting conventions:

Bar DateMarket EventBar ClosePos SizeCash (shortcash=True)Pos Value (True)Cash (shortcash=False)Pos Value (False)Accrued Borrow FeeNet Equity (Both)
2026-01-01Initial capital; short order placed$100.000$10,000.00$0.00$10,000.00$0.00$0.00$10,000.00
2026-01-02Short fill: 50 @ $105.00; Comm: $5.25$105.00-50$15,244.75-$5,250.00$4,744.75+$5,250.00$0.00$9,994.75
2026-01-03Adverse price jump to $110.00; 1d interest$110.00-50$15,244.03-$5,500.00$4,744.03+$5,000.00$0.72$9,744.03
2026-01-04Favorable drop to $95.00; 1d interest$95.00-50$15,243.31-$4,750.00$4,743.31+$5,750.00$0.72$10,493.31
2026-01-05Cover fill: 50 @ $90.00; Trade closed$90.000$10,738.09$0.00$10,738.09$0.00$0.72 (close)$10,738.09

Mathematical audit of the ledger transactions

Let us inspect the exact line-by-line mathematics implemented in Backtrader's bbroker.py:

1. Entry execution (2026-01-02)

  • Gross sale proceeds:
    Code
    Proceeds = Size * Fill_Price = 50 * $105.00 = $5,250.00
  • Commission on short entry:
    Code
    Commission_entry = $5,250.00 * 0.001 = $5.25
  • When shortcash = True:
    Code
    Cash = $10,000.00 + $5,250.00 - $5.25 = $15,244.75
    Position Value = -50 * $105.00 = -$5,250.00
    Net Equity = $15,244.75 + (-$5,250.00) = $9,994.75
  • When shortcash = False:
    Code
    Cash = $10,000.00 - $5,250.00 - $5.25 = $4,744.75
    Position Value = abs(-50 * $105.00) = +$5,250.00
    Net Equity = $4,744.75 + $5,250.00 = $9,994.75

2. Borrow interest fee deduction (2026-01-03 and 2026-01-04)

Backtrader checks open positions at the beginning of each bar and discounts credit interest from self.cash using the formula in CommInfoBase._get_credit_interest:

Code
Daily Borrow Fee = Days * Price_open * |Size| * (Interest_rate / 365)

For our short position:

Code
Daily Fee = 1 * $105.00 * 50 * (0.05 / 365) = $5,250.00 * 0.000136986 = $0.71918 ($0.72)

Notice that Backtrader deducts this interest fee from cash on both shortcash=True and shortcash=False:

  • shortcash=True: Cash drops from $15,244.75 to $15,244.03.
  • shortcash=False: Cash drops from $4,744.75 to $4,744.03.

3. Mark-to-market revaluation

On 2026-01-03, the close climbs to $110.00 (a $5.00 per share loss):

  • Under shortcash=True, position value becomes -50 * $110.00 = -$5,500.00. Total equity:
    Code
    Net Equity = $15,244.03 + (-$5,500.00) = $9,744.03
  • Under shortcash=False, the internal formula position.price * size + (position.price - price) * size calculates:
    Code
    Val = ($105 * -50) + ($105 - $110) * -50 = -$5,250 + $250 = -$5,000
    Taking abs(-$5,000) yields +$5,000.00. Total equity:
    Code
    Net Equity = $4,744.03 + $5,000.00 = $9,744.03

4. Exit execution and trade settlement (2026-01-05)

On Bar 5, 50 shares are bought to cover at $90.00.

  • Gross trade profit:
    Code
    Gross PnL = (Entry_Price - Exit_Price) * Shares = ($105.00 - $90.00) * 50 = +$750.00
  • Exit commission:
    Code
    Commission_exit = 50 * $90.00 * 0.001 = $4.50
  • Cumulative borrow interest across the 3-day holding period:
    Code
    Cumulative Interest = 3 * $0.71918 = $2.1575 ($2.16)
  • Note the console output: BUY (COVER) ... Comm: $6.66. Why did the cover order log a commission of $6.66 instead of $4.50? Because Backtrader has broker.p.int2pnl = True enabled by default! Under int2pnl=True, accumulated interest charges are consolidated into the closing trade's commission ledger:
    Code
    Reported Comm = Exit_Commission ($4.50) + Accrued_Interest ($2.16) = $6.66
  • Final Net Trade PnL:
    Code
    Net PnL = Gross PnL ($750.00) - Entry Comm ($5.25) - Exit Comm ($4.50) - Accrued Interest ($2.16) = $738.09
  • Final Account Cash & Equity:
    Code
    Final Equity = Starting Capital ($10,000.00) + Net PnL ($738.09) = $10,738.09

The silent killers of short strategies: Hard-to-borrow, locates, and squeezes

While Backtrader faithfully models math and ledger debits, relying solely on standard backtest results for short strategies creates dangerous complacency. Real-world short selling operates under severe operational constraints that zero-friction simulators omit.

Code
flowchart TD
    subgraph OperationalFrictions ["Real-World Short Selling Frictions"]
        L["Reg SHO Rule 203(b)(1)\nMandatory Locate Requirement"] --> E{"Locate Available?"}
        E -- "No (HTB / Hard-to-Borrow)" --> R["Order Rejected\nBacktest Execution Fails"]
        E -- "Yes" --> B["Borrow Rate Applied\n(GC: 0.3% vs HTB: 20% to 100%+ APR)"]
        B --> S{"Market Squeeze / Recall?"}
        S -- "Lender Recalls Shares" --> F["Forced Buy-In at Market Ask\nInstant Liquidation"]
        S -- "No Recall" --> M["Margin Maintenance Check\n(130% to 150% Collateral)"]
    end

1. The locate requirement and borrow availability

Under SEC Regulation SHO Rule 203(b)(1), a broker cannot accept a short sale order from a customer unless the broker has borrowed the security, arranged to borrow the security, or has reasonable grounds to believe the security can be borrowed ("located").

In Backtrader, every self.sell() executes seamlessly as long as cash margin allows. In live markets:

  • General Collateral (GC): Highly liquid, large-cap equities (e.g., Apple, Microsoft) have abundant borrow supply with borrow fees hovering between 0.25% and 0.50% annualized.
  • Hard-to-Borrow (HTB): Small-cap equities, heavily shorted stocks, and recent IPOs frequently lack locates. If your strategy identifies an overvalued stock with 90% short interest, the backtest will assume a clean entry, whereas a live execution router will reject the order immediately with NO LOCATE AVAILABLE.

2. Variable and surging borrow fees

Backtrader accepts a static interest parameter in setcommission(). However, live borrow rates fluctuate dynamically. During meme-stock episodes or liquidity crunches, borrow rates can skyrocket from 2% to over 150% APR within 48 hours. Holding an HTB short position across a 10-day consolidation can erase months of alpha through borrow fees alone.

3. Forced buy-ins and recall risk

When you short an asset, the underlying share owner retains the right to sell their shares at any time. If the owner sells and the prime broker cannot locate replacement shares from another lender, the broker issues a mandatory buy-in. Your short position is covered forcefully at the prevailing market ask price, regardless of your strategy's stop-loss or profit target.

4. Asymmetric mathematical payoff

The payoff distribution of a short sale is inherently unfavorable:

  • Maximum Profit: Capped at 100% (if the asset drops to zero).
  • Maximum Loss: Mathematically infinite (\infty), as there is no theoretical ceiling on how high an asset can climb.

This structural asymmetry heavily skews strategy return distributions, producing severe negative skewness and fat left tails that ruin conventional risk-adjusted metrics like the Backtrader Sharpe Ratio.


Position sizing traps when shorting in Backtrader

Because broker.set_shortcash(True) inflates the cash readout with sale proceeds, quantitative developers frequently introduce severe bugs into their sizing algorithms.

Anti-pattern: Sizing short trades with get_cash()

Consider a strategy that calculates unit sizing based on available cash:

Naive Cash-Based Sizing (CRITICAL DEFECT)
def next(self):
    # DANGEROUS: get_cash() includes proceeds from prior short sales!
    available_cash = self.broker.get_cash()
    target_allocation = available_cash * 0.20
    shares = int(target_allocation / self.data.close[0])
    
    if self.signal < 0:
        self.sell(size=shares)

If the account holds open short positions, get_cash() reports free cash plus the collateral liabilities of existing shorts. Using this figure causes the algorithm to over-leverage itself dramatically on consecutive orders, exceeding margin thresholds and triggering unexpected order cancellations.

Robust pattern: Sizing relative to net portfolio value

As emphasized in our comprehensive guide on backtrader-position-sizing, production sizing algorithms should always size allocations against net portfolio liquidation value (self.broker.get_value()):

Equity-Based Safe Sizing Implementation
def next(self):
    # ROBUST: get_value() represents true net liquidation equity
    total_equity = self.broker.get_value()
    risk_capital = total_equity * 0.10  # Allocate exactly 10% of portfolio equity
    
    current_price = self.data.close[0]
    safe_units = int(risk_capital / current_price)
    
    if not self.position and self.signal < 0:
        # Protect against short squeezes with a strict stop loss
        stop_price = current_price * 1.05  # 5% hard stop
        self.sell(size=safe_units)

Pairing equity-based sizing with strict stop protection via a Backtrader stop loss is essential to mitigate the unbounded tail risk inherent in short positions.


Clean short accounting in OpenBacktesting

Managing dual accounting flags like shortcash=True versus shortcash=False highlights the friction of retrofitted legacy backtesting frameworks. When simulation tools obscure the distinction between cash collateral and net equity, quantitative researchers waste days debugging phantom capital anomalies.

In modern quantitative architectures like OpenBacktesting (v0.2.1), accounting for single-asset short positions is built on strict, transparent double-entry ledgers:

Code
                  OpenBacktesting Bar Ledger State
┌──────────────────────────────────────────────────────────────┐
│  Cash Balance (Unencumbered Liquidity)                       │
│  Asset Units (Negative for Short: e.g., -50)                 │
│  Mark-to-Market Asset Price                                  │
│  Open Liability = Units × Price                              │
│  Net Equity = Cash + Liability                               │
└──────────────────────────────────────────────────────────────┘

1. Zero-ambiguity balance sheet tracking

OpenBacktesting does not require manual toggling between confusing shortcash modes. Every bar calculates the exact mark-to-market liability of open short positions alongside true unencumbered cash. The engine never inflates spendable cash with borrow proceeds, ensuring automated risk engines cannot over-allocate.

2. Immutable SQLite trial persistence

Every short order lifecycle—from submission and fill execution to daily borrow fee accrual and cover buy-in—is persisted in local SQLite tables (trials.db). Researchers can inspect the complete time series of cash, margin requirements, and equity curves bar-by-bar using standard SQL queries or Python scripts.

3. Visual ledger inspection in Studio UI

Rather than manually calculating floating liabilities from console printouts, researchers can open the OpenBacktesting local Studio UI to visualize the equity curve overlaid against trade execution markers. When an adverse price move occurs, the Studio interface displays the exact drawdown impact on portfolio equity, allowing researchers to evaluate drawdown recovery without accounting artifacts.


Checklist for short strategy backtesting

Before deploying any algorithmic strategy that incorporates short selling, run through this pre-flight verification checklist:

Code
[ ] Accounting Mode Verification
    - Verify whether cerebro.broker.set_shortcash(True) or False is configured.
    - Confirm all Sizers and position managers query broker.get_value(), never get_cash().

[ ] Realistic Friction Modeling
    - Set realistic commission rates (e.g., 0.1% or $0.005/share).
    - Configure annual borrow interest via setcommission(interest=0.03 to 0.10).
    - Verify whether interest charges are assigned to trade PnL (int2pnl=True).

[ ] Liquidity and Locate Filtering
    - Filter universe to exclude micro-caps, penny stocks, or securities with < $5M daily volume.
    - Ensure strategy does not enter short positions on stocks undergoing extreme borrow fee spikes.

[ ] Downside Risk Controls
    - Implement mandatory hard stops (bracket orders or stop-loss orders) on every short entry.
    - Restrict maximum short allocation per position to &lt; 5-10% of total portfolio equity.
    - Test strategy resilience against rapid 20%+ gap-up open events (short squeeze simulation).

[ ] Persistence and Verification
    - Export bar-by-bar ledger to inspect Cash, Position Size, Market Value, and Net Equity.
    - Reconcile Gross PnL vs Net PnL after all financing and execution costs.

By decoupling nominal cash movements from net liquidation equity, quantitative researchers can eliminate simulation illusions, protect capital from catastrophic squeezes, and construct resilient, market-neutral algorithmic systems.