Ahmer Nadeem Khan
Return to project

Trading cost models

Since the goal in this project is to investigate a statistical arbitrage trading strategy, we will need a more involved cost model than in previous projects. The cost model will be broken into 4 distinct parts: execution friction, explicit regulatory fees, short-borrow carry, and dividends/corporate actions.

Execution friction

This represents bid–ask spread, slippage, and small market impact. To estimate this accurately, much higher frequency data would be needed (e.g. minute quotes) and we would have to model limit order book effects, which is not feasible here. Therefore, we will roll these frictions into a constant per dollar traded cost, and test various stress levels for this cost. The model is

$$\text{execution cost}_t = \sum_i \left| \text{target notional}_{i,t} - \text{current notional}_{i,t} \right| \times \frac{\text{cost bps}}{10{,}000}$$

where notional is the dollar exposure of a position, $\text{notional}_{i,t} = \text{shares}_{i,t} \times \text{price}_{i,t}$, with shares signed negative when short, so that a reversal is charged for both sides.

Aggregating across legs gives gross and net capital, $\text{gross}_t = \sum_i \left| \text{notional}_{i,t} \right|$ and $\text{net}_t = \sum_i \text{notional}_{i,t}$. Gross counts exposure regardless of direction; net is the signed sum, and is 0 for a dollar-neutral pair. Costs and turnover are therefore quoted against gross.

The cost per dollar (bps) stress levels we test will be the set $\{0.0,\, 2.5,\, 5,\, 10,\, 20\}$. It is charged one way, meaning a round trip charges double relative to the gross capital.

As previously, 10 bps will be the primary burden here. In large caps and liquid stocks the true friction might be smaller, but since we will be executing relative to next-day open (which is not necessarily the fill price), we continue with 10 bps as the standard. We will also report the break-even cost, the one-way cost at which net performance is 0.

Example. Imagine a $200k dollar-neutral long/short, i.e. the gross is $200k (the total absolute value of the positions) and the net is 0. At 20 bps, a round trip (open and close) for this trade would cost $200k × 40/10,000 = $800. In terms of the rate, a friction rate of 40/10,000 = 0.4% would consume a gross annual return of 6% in 6%/0.4% = 15 full round trips.

Explicit regulatory fees

Since our data is sourced from the Alpaca API, and this is where I have opened a paper trading account for eventual, planned paper trading projects, we will use Alpaca as our assumed primary broker, meaning we will consider explicit regulatory fees associated with a direct Alpaca brokerage account. The primary commission assumption will be 0 (as per the current Alpaca brokerage fee schedule, July 20, 2026). The schedule also lists three pass-through regulatory and exchange fee rates for equities, which agree with the SEC Section 31 rate and the FINRA 2026 TAF schedule.

Fee Charged on Rate
SEC Transaction Fee Sells only $0.0000206 × trade value
FINRA Trading Activity Fee (TAF) Sells only $0.000195 per share, capped at $9.79 per trade (50,205 shares or more)
FINRA Consolidated Audit Trail Fee (CAT) Buys and sells $0.000003 per executed equivalent share

For NMS equities, 1 share = 1 executed equivalent share; for OTC equities, 1 share = 0.01 executed equivalent shares.

These fees will not be hard to implement in the model. For the CAT fee, since our universe is the S&P 500, all of the relevant securities are NMS equities, so 1 share counts as 1 executed equivalent share throughout. Refer to the project log entry on regulatory fees for some more information on the fees (and some history).

Short-borrow carry

Keeping in with Alpaca convention, we follow its margin and short-selling rules. It currently states that Easy-to-Borrow (ETB) securities have $0 locate and borrow fees. This means that we will assume zero short-selling fees as our base and standard case, since ETB status covers 5,000+ approved securities (which includes the tradeable securities in our universe) under normal market conditions. This status was also verified using the locate workflow in the Alpaca API. We will also assume that short proceeds generate no rebates and no cash interest. Since the backtester runs on a fully funded account, no overnight debit balance arises and margin interest does not apply either.

For details on how the actual cost for HTB securities is computed, see the project log entry on short-selling. The fee itself is computed as

$$\text{borrow fee} = \sum_i \text{short market value}_i \times \frac{\text{annual rate}_i}{360} \times \text{calendar days}$$

With regards to HTB securities, since the locate fee or borrow rate is not known, specific to each security and dynamic, it is impossible to model precisely. However, we will use a modest non-zero proxy of 1% for this rate, to remove some of the lookahead this causes, i.e. we know beforehand that the securities are ETB. Furthermore, it may be the case that the stocks are HTB in the precise market conditions that require us to have liquidity, which introduces some risk associated with short-selling, especially for our backtest horizon (back to 2016).

In terms of the dynamic margin requirements associated with a long short portfolio, we will assume that funding to post for these requirements is always available (in real life, this would mean lower returns per the initial gross or dynamic investment required to deploy the strategy, but we don't model these complications). However, I will ex-post completely characterize the utilization, unused equity in the entire lifetime of the strategy, and also whether things like Reg SHO 201 ever get triggered etc. I think this is a nice balance. See this log entry for more details on margin requirements. We will however model the short dividend obligations associated with a short position, as discussed below.

Dividends and corporate actions

This is the most involved part of the costs and also plugs directly into the backtester design and how the pairs signals will be implemented and also executed. By dividends, we mean the real cash flows associated with the ownership of company stock (equity, positive or negative), and by corporate actions we primarily mean stock splits. Note that there are many complications this introduces, and much of the discussion of some of these issues is left aside here, e.g. entitlement schedules and the clearing and settlement process, how adjusted time-series are formed from raw prices etc. This section will simply contain a summary and actionable decisions i.e. the relevant information to how we are handling dividends and splits.

The first decision we make is that we explicitly handle dividends and stock splits, and use the raw price series for the stocks. We do not reverse engineer the adjustment factors from the adjusted and raw series (which is also a hard if not impossible task to do precisely, since these factors accumulate in the adjusted series), but use the Alpaca corporate-actions endpoint, which supplies cash dividends, splits, mergers, spin-offs, name changes and other event types (this data is incomplete and has many issues that need to be handled explicitly as well e.g. missing values, deduplication, ticker symbol changes and assignment etc.).

We first determine entitlement for the signed position held at close before ex-date, and then compute

$$\text{dividend cash flow}_t = q_{t-1} D_t$$

where $q_{t-1}$ is the shares held and $D_t$ is the dividend received or owed per share, so positive signed shares receive cash and negative signed shares produce a liability (pay cash in lieu). We will use ex-date settlement across the sample as it 1) simplifies the clearing and settlement process and 2) removes the data discrepancy between periods with different payment-date treatment and changes. This is also possible here since we assume no cash interest and no binding inter-period cash constraint.

For splits, before an ex-date open, we apply

$$q_t = q_{t-1} \frac{\text{new rate}}{\text{old rate}}$$

and then process open orders so a split produces no P&L. This works uniformly for forward and reverse splits.

All complex events like a simultaneous reverse stock split plus a spin-off, or ticker renamings and assignments interrupting the data feeds, will be handled independently and not automated in the backtester; I will also thoroughly document these, treat the Alpaca data as a raw dataset, and verify discrepancies through issuers.

The messy details of handling the dividends and other corporate actions dataset is covered in the log entries on the data page, so we refer the reader to that page here.

Project log

Entries covering explicit regulatory fees and short-borrow carry.

2026-08-06

Short-selling and borrow fees

The primary model we use for short-selling and borrow costs is covered on the main page under trading costs. Since pairs require shorts, I wanted to add a note explaining short-selling, margin accounts and borrowing, especially the rules that Alpaca uses since we use this as our model. The actual documentation is here.

Shorting requires a margin account with at least $2,000 of equity. Securities are split into easy-to-borrow and hard-to-borrow as explained on the main page and we basically assume the entire universe we trade is ETB, at least at a baseline level, and only in certain periods do they potentially become HTB. The modelling issue is we have no historical data on which securities were ever HTB, if they were at all, in what periods, for how long etc. (This data is also basically impossible to estimate with any reasonable accuracy, and I also don't have intuition for this; I assume stocks can become HTB in periods of high volatility, extreme downturn or shocks etc.) The additional difficulty is that even in these cases, a security may not be shortable at all, if a short cannot be located; the locate fee is also non-refundable, and locates and borrow-fees are handled in 100-share round lots.

ChargeRateBasis
Borrow fee, easy-to-borrownone-
Borrow fee, hard-to-borrowper-name rate(short market value x rate) / 360, accruing daily, and a Friday settlement date incurs three days (Fri/Sat/Sun)
Margin interest6.25%, or 4.75% for elite(overnight debit balance x rate) / 360
Initial margin50%Regulation T
Maintenance, short under $5greater of $2.50/share or 100%end-of-day market value
Maintenance, short $5 and abovegreater of $5.00/share or 30%end-of-day market value

In our model, we will not allow any leverage so the margin interest constraints don't enter the backtest. Another thing missing from Alpaca is Reg SHO Rule 201 (alternative uptick rule), which is a short circuit-breaker that goes off if a stock drops 10% or more compared to the previous day's close within a day; it stays in effect the remainder of the day and the next trading day. It limits shorts at a price lower than the current National Best Bid (NBB). I am probably not going to model these complexities.

Another possible complication we won't model is the recall risk, i.e. a situation where the lender calls the share back early and we have to exit the position early; this could also potentially be rolled into the borrow fee by increasing or stress testing the rate.

2026-08-05

Explicit regulatory fees

I took this opportunity to learn more about explicit regulatory fees, to understand more realistic trading fees. For the project, it might be more sensible to also roll this into a bps number. But since one of the fees (TAF) is per share, it is actually simpler to charge these as stated in the backtester, especially since it will already compute shares and notional per fill. Here is the breakdown.

  • SEC Section 31: mandated by Section 31 of the Securities Exchange Act of 1934. Exchanges and FINRA (Financial Industry Regulatory Authority) pay it to the SEC, which remits to the Treasury; it offsets the SEC's appropriation, i.e. the industry funds its own regulator. The rate is reset periodically to hit a target dollar collection, which is why it carries a date. Charged on the value of sales only.
  • FINRA TAF (Trading Activity Fee): FINRA's own operating revenue, charged to member firms on covered sales. Per share, not per dollar. It is one of FINRA's three member assessments, alongside the Gross Income Assessment and the Personnel Assessment.
  • CAT: funds the Consolidated Audit Trail, the market-wide order-tracking system mandated by SEC Rule 613 in 2012 in response to the May 2010 flash crash. Reconstructing that event took months, because order records sat across venues in incompatible formats with no common identifier tying an order to its lifecycle or to the customer behind it. CAT records every order in NMS securities end to end, from origination through routing, modification, cancellation and execution, with timestamps and customer identity. It replaced FINRA's older OATS (Order Audit Trail System), retired in 2021, and is operated by CAT NMS LLC, owned jointly by the SROs. Charged on both sides.

SROs (self-regulatory organizations) are entities granted statutory authority to write and enforce rules binding on their members, with the SEC supervising rather than regulating them directly. In US equities that means FINRA, the national securities exchanges (NYSE, Nasdaq, Cboe, IEX, MEMX, MIAX), and the clearing agencies (NSCC for clearing, DTC for settlement and custody). Their rule changes must be filed with the SEC and published for public comment before taking effect, which is why the TAF citation above is filing SR-FINRA-2024-019, where SR denotes a self-regulatory organization rule filing.

All three are levied on the broker, who passes them through; the rates used here are those in the Alpaca brokerage fee schedule.

Note that since we use the current rates for the entire period, our model is anachronistic, especially since Section 31 resets periodically. That rate is reset to hit a target dollar collection rather than drifting in one direction, so it has been both higher and lower than today's over our sample. This means we sometimes overstate and sometimes understate the fees we may have been charged, and the error should roughly offset over the horizon rather than bias us one way.