Mattheus Public Preview

Join Waitlist

Mattheus Public Preview

Current Blog

How to Model Short-Selling Costs in a Trading Backtest

A short-selling backtest needs dated borrow availability, changing fee rates, dividend payments, margin rules, and recall handling before it can estimate an executable return.

A short-selling backtest is executable only when the simulated strategy could borrow the shares at the time of each order. The return must then include the daily cost of that borrow, any interest credited on short-sale proceeds, payments owed when the issuer makes a distribution, and the possibility that the position is bought in after a recall.

A fixed annual fee applied to every short position misses most of this structure. Borrow availability and rates can change by security and day. Hard-to-borrow names are often the trades most affected by an availability filter, so a simple fee adjustment cannot repair an impossible order after the fact.

Check whether the shares were available

A short sale generally requires borrowed shares for delivery. The SEC guidance on Regulation SHO states that a broker-dealer must generally borrow the security, arrange to borrow it, or have reasonable grounds to believe it can be borrowed before accepting or effecting a short sale. The locate must be performed before the sale.

Give the backtest a dated availability record. At minimum, store the security identifier, observation timestamp, shares available, indicative fee rate, source, and any hard-to-borrow status. Join that record to the order timestamp without using a later update. If availability is zero or missing, reject the order or apply a documented fallback that does not assume a fill.

An easy-to-borrow list can change. SEC staff notes that such a list may support a locate only when the broker has a reasonable basis for relying on it. A security with delivery failures may no longer qualify. The simulation should therefore treat availability as time-varying data rather than a permanent property of a ticker.

Record every rejected short order. A backtest that drops rejected orders silently can hide how much of the signal depends on scarce shares. Report the requested quantity, available quantity, rejected quantity, and the return of the trade that could not be opened.

Accrue the borrow fee each day

FINRA describes short selling as borrowing shares, selling them, and later buying equivalent shares to return to the firm. Its investor guidance notes that transaction fees and interest paid on borrowed shares reduce the result.

Calculate the fee from the short market value and the rate that applied on each accrual date. The Schwab pricing guide describes a stock borrow fee calculated from end-of-day short market value multiplied by the quoted annual rate and divided by 360. It also states that the rate can change daily. That formula is one broker's disclosed convention, not a universal market rule. Use the convention of the broker and account simulated by the test.

The daily calculation should revalue the open short position before applying the rate. If the stock price rises, both the mark-to-market loss and the fee base may rise. If the rate changes, use the new rate from that date forward. Do not spread the entry-day quote evenly across the entire holding period unless the agreement actually fixes it.

Interactive Brokers separates the borrow fee from interest paid on short-sale proceeds. Its short sale cost page presents both components in the daily calculation. A research record should keep them separate so the result can be rebuilt under another account schedule.

How to Model Trading Costs in a Backtest covers commissions, spread, slippage, funding, and fill assumptions. Short borrow belongs inside that same order-level ledger, but it needs its own dated inputs because its availability and price come from the lending market.

Charge distributions to the short position

A short seller does not keep the economic benefit of a distribution paid on borrowed shares. The SEC explains that when borrowed stock pays a dividend, the borrower must pay the dividend to the lender. The Schwab account agreement likewise states that a customer is liable for dividends paid on securities borrowed for a short sale.

Store the ex-date, record date, pay date, amount, distribution type, and the broker's treatment. Apply the payment according to the account convention simulated by the test. Do not rely only on an adjusted price series. A price adjustment can reflect the market move while omitting the cash obligation in the short account.

Corporate actions need explicit handling. Splits change the share count and price basis. Mergers, tenders, spin-offs, and special distributions can change the deliverable. If the backtest cannot model the resulting obligation, close the position at a stated date or mark the run incomplete rather than inventing a neutral cash flow.

Apply price tests and margin rules

Regulation SHO Rule 201 can restrict the price of a short sale after a covered security falls by at least 10 percent in one day. SEC guidance says the restriction generally applies for the remainder of that day and the next day unless an exception applies. A signal generated during that period is not automatically an executable market sell.

Model the order type and permitted execution price. If the historical data cannot show whether the order could satisfy the rule, reject it or use a conservative assumption that is stated beside the result. Do not shift the fill to a better later price without preserving the delay and missed exposure.

Short positions also consume margin. FINRA notes that short selling requires a margin account. Broker agreements can impose house requirements above regulatory minimums and can change those requirements. The portfolio simulation should reserve collateral, mark positions daily, and block new orders when available equity is insufficient.

A margin breach can force a sale of other assets or a buy-to-cover order. The engine should apply a deterministic liquidation rule instead of allowing negative collateral to persist. Store the trigger, the selected position, the execution assumption, and the remaining account equity.

Represent recalls and forced buy-ins

A lender can recall shares. The Schwab account agreement states that the firm may cover a short position when the lender recalls the securities or when the firm expects that it cannot borrow or re-borrow them. The price of that purchase can be higher than the original short-sale price.

Historical recall data is often incomplete. That limitation should remain visible. If recall events are available, close the position using the documented notice and execution timing. If they are not, run a prespecified stress test with forced closures after borrow availability disappears or the fee rises past a fixed threshold. Label the stress result as an assumption rather than observed history.

Do not let an unavailable borrow remain open indefinitely at the last known fee. That treatment gives the strategy a right to hold scarce inventory that it may not have had. Compare the base case with a conservative availability case and show how much return comes from positions affected by the rule.

Keep the data point in time

Borrow files are revised throughout the day. Joining an end-of-day availability snapshot to an order placed that morning can introduce future information. How to Prevent Look-Ahead Bias in a Trading Backtest explains why the availability timestamp must precede the decision and simulated execution.

Use stable security identifiers because tickers can change or be reused. Keep the lending record linked to the same security history used for prices, corporate actions, and delistings. How to Prevent Survivorship Bias in a Trading Backtest covers the need to retain securities that later disappear.

Attach the raw file version, provider, ingestion time, time zone, and transformation code to each availability and rate observation. Data Lineage for Trading Research describes the wider record needed to reproduce a result after source data changes.

Store a short-sale execution record

For each attempted short order, keep the decision time, locate source, available quantity, requested quantity, filled quantity, fee-rate timestamp, daily fee accruals, proceeds interest, distributions, margin usage, price-test state, recall state, and exit reason. Preserve rejected orders as first-class results.

Report gross return beside each deduction. Show how many signals were rejected for unavailable shares, how many positions became hard to borrow, how much was paid in distributions, and how many exits were forced. A profitable result that depends on orders the borrow file rejected is not an executable estimate.

Broker rules, fee schedules, and lending supply differ across accounts and dates. The backtest should identify the broker convention it uses and avoid presenting that convention as universal. After the research logic is frozen, collect forward availability, rates, rejected orders, and recalls. Paper-first evaluation can then compare the historical assumptions with decisions recorded after the test ended.

Invest and Earn Yield with Infinite Context.

Invest and Earn Yield with Infinite Context.

An AI harness that remembers how you trade.

An AI harness that remembers how you trade.

An AI harness that remembers how you trade.

Public preview · Join the waitlist

Dashboard interface preview
Dashboard interface preview