Technical / Volume
SlippageVar(bars)
Full Description

Portfolio123 provides two functions for estimating transaction costs directly in screens, ranking systems, universes, buy/sell rules, and other formulas:

SlippageAdv() estimates slippage using Portfolio123's Advanced Slippage model, which takes trade size, liquidity, volatility, and bid/ask spread into account.

SlippageVar() returns the legacy Variable Slippage estimate, which is based primarily on the stock's price and liquidity.

Both functions return slippage as a percentage. For example, a returned value of 0.25 means 0.25% slippage, not 25%.

SlippageAdv()

Advanced Slippage estimates the expected slippage for trading a specified dollar amount of a security. Unlike Variable Slippage, it responds to the size of the trade. Larger orders relative to the stock's normal trading liquidity will therefore produce higher estimated transaction costs.

Syntax

SlippageAdv(amount [, spread = 0.5, impact = 2.0, offset = 0, bars = 20])

Parameters

  • amount – Dollar amount of the proposed trade. Portfolio123 uses the amount together with the previous close to determine the approximate number of shares being traded.
  • spread (L) – Multiplier applied to the estimated bid/ask spread cost. Default: 0.5.
  • impact (K) – Multiplier applied to the estimated market-impact cost. Default: 2.0.
  • offset – Number of bars ago at which to evaluate the calculation. Default: 0.
  • bars – Lookback period used by the calculation. Default: 20.

The model combines two sources of transaction cost:

Slippage = (K) × Impact_componenent% + (L) × Spread_component%

Market impact component increases with the stock's volatility and with the square root of the trade amount relative to its liquidity. The spread component estimates the cost of crossing some portion of the bid/ask spread.

Examples

SlippageAdv(100000, 0.25, 1.0)

Estimates the slippage for a $100,000 trade while assuming that execution incurs 25% of the estimated spread and using a market-impact multiplier of 1.0.

The optional multipliers make SlippageAdv() particularly useful for experimenting with assumptions before choosing the Advanced Slippage settings for a simulation.

For example, run a screen with the following rules:

@s1:SlippageAdv(50000,0.5,2.0)
@s2:SlippageAdv(50000,0.5,1.0)
@s3:SlippageAdv(50000,0.25,1.0)

You will see the values in the screen report for each combination of parameters. This makes it easy to see how different execution assumptions affect highly liquid and less-liquid stocks.


SlippageVar()

Returns Portfolio123's Variable Slippage estimate using the specified liquidity lookback period. Less-liquid stocks receive higher estimated slippage based on certain threshold. For example stocks that trade between $225,001 – $450,000 get a 0.5% slippage added to transaction costs.

Syntax

SlippageVar(bars)

Parameters

  • bars – Number of bars used to calculate average daily dollar liquidity.

Examples

SlippageVar(10)

Returns the same style of Variable Slippage calculation used by Portfolio123 simulations, where the liquidity lookback is fixed at 10 bars.

More information

For the formulas, liquidity fallbacks, spread calculation, Variable Slippage liquidity bands, and a more detailed discussion of Portfolio123's transaction-cost models, see the Transaction Cost Model (a.k.a. Slippage) Knowledge Base article. Transaction Cost Model (a.k.a. Slippage)