Determine Buy-Sell Imbalance Using Cost Index

This example shows how to determine buy-sell imbalance using transaction cost analysis from the Kissell Research Group. Imbalance is the difference between buy-initiated and sell-initiated volume given actual market conditions on the day and over the specified trading period. A positive imbalance indicates buying pressure in the stock and a negative imbalance indicates selling pressure. The cost index helps investors to understand how the trading cost environment affects the order flow in the market. The index can be a performance-based index, such as the S&P 500, that shows market movement and value or a volatility index that shows market uncertainty.

The imbalance share quantity is the value ofxsuch that

0 = | M I C o s t | 10000 M I ( x ) ,

where

M I ( x ) = [ b 1 ( x V o l u m e ) a 4 + ( 1 b 1 ) ] [ a 1 ( x A D V ) a 2 σ a 3 P r i c e a 5 ] .

MIis the market-impact cost for a stock transaction. The estimated trading costs represent the incremental price movement of the stock in relation to the underlying index price movement.Volumeis the actual daily volume of a stock in the basket.ADVis the average daily volume of a stock in the basket.Priceis the price of a stock in the basket. The other variables in the equations are:

  • σ — Price volatility.

  • a 1 — Price sensitivity to order flow.

  • a 2 — Order size shape.

  • a 3 — Volatility shape.

  • a 4 — Percentage of volume rate shape.

  • a 5 — Price shape.

  • 1 b 1 — Percentage of permanent market impact. Permanent impact is the unavoidable impact cost that occurs because of the information content of the trade.

  • b 1 — Percentage of temporary market impact. Temporary impact is dependent upon the trading strategy. Temporary impact occurs because of the liquidity demands of the investor.

  • M I C o s t = T o t a l C o s t B e t a I n d e x C o s t , where:

    • TotalCost— Change in the volume-weighted average price compared to the open price for the stocks.

    • Beta— Beta.

    • IndexCost— Change in the volume-weighted average price compared to the open price for the index. Index cost adjusts the price for market movement using an underlying index and beta.

In this example, you can run this code using current or historical data. Current data includes prices starting from the open time through the current time. Historical data uses the prices over the entire day. Historical costs use market-impact parameters for the specified region and date. Therefore, historical costs change from record to record.

For a current cost index, you load the example tableTradeDataCurrentfrom the fileKRGExampleData.mat. For a historical cost index, you load the example tableTradeDataHistoricalfrom the fileKRGExampleData.mat. This example calculates a current cost index.

To access the example code, enteredit KRGCostIndexExample.mat the command line.

After running this code, you can submit an order for execution using Bloomberg®, for example.

This example requires an Optimization Toolbox™ license. For background information, seeOptimization Theory Overview(Optimization Toolbox).

Retrieve Market-Impact Parameters and Load Data

检索市场影响的数据Kissell Research Group FTP site. Connect to the FTP site using theftpfunction with a user name and password. Navigate to theMI_Parametersfolder and retrieve the market-impact data in theMI_Encrypted_Parameters.csvfile.miDatacontains the encrypted market-impact date, code, and parameters.

f = ftp('ftp.kissellresearch.com','username','pwd'); mget(f,'MI_Encrypted_Parameters.csv'); close(f) miData = readtable('MI_Encrypted_Parameters.csv','delimiter',...',','ReadRowNames',false,'ReadVariableNames',true);

Create a Kissell Research Group transaction cost analysis objectk. Specify initial settings for the date, market-impact code, and number of trading days.

k = krg(miData,datetime('today'),1,250);

Load the example dataTradeDataCurrent, which is included with the Trading Toolbox™. Calculate the number of stocks in the portfolio.

loadKRGExampleData.matTradeDataCurrentTradeData = TradeDataCurrent; numStocks = height(TradeData);

示例数据的描述,请参阅Kissell Research Group Data Sets.

Define Optimization Parameters

Define the maximum number of function iterations for optimization. Set'MaxIterations'to a large value so that the optimization can iterate many times to solve a system of nonlinear equations.

options = optimoptions('fsolve','MaxIterations',4000);

Estimate Trading Costs Using Cost Index

Determine the total cost and beta cost. Calculate the side of the initial market-impact cost estimate. Determine the initial volumex0.

totalCost = TradeData.VWAP ./ TradeData.Open - 1; indexCost = TradeData.Beta .*...(TradeData.IndexVWAP ./ TradeData.IndexOpen - 1); miCost = totalCost - indexCost; sideIndicator = sign(miCost); x0 = 0.5 * TradeData.Volume;

Create a table that stores all output data. First, add these variables:

  • Symbol— Stock symbol

  • Date— Transaction date

  • Side— Side

  • TotalVolume— Transaction volume

  • TotalCost— Total transaction cost

  • IndexCost— Index cost

costIndexTable = table; costIndexTable.Symbol = TradeData.Symbol; costIndexTable.Date = TradeData.Date; costIndexTable.Side = sideIndicator; costIndexTable.TotalVolume = TradeData.Volume; costIndexTable.TotalCost = totalCost; costIndexTable.IndexCost = indexCost;

Use afor-loop to calculate the cost index for each stock in the portfolio. Each stock might have different market-impact codes and dates. Use thecostIndexExampleEqfunction that contains the nonlinear equation to solve. To access the code for thecostIndexExampleEqfunction, enteredit KRGCostIndexExample.m.

Add these variables to the output table:

  • Imbalance— Imbalance

  • ImbalancePctADV— Imbalance as percentage of average daily volume

  • ImbalancePctDayVolume— Imbalance as percentage of the daily volume

  • BuyVolume— Buy volume

  • SellVolume— Sell volume

  • MI— Market-impact cost

  • ExcessCost— Excess cost

fori = 1:numStocks% Set the MiCode and MiDate of the object for each stockk.MiCode = TradeData.MICode(i); k.MiDate = TradeData.Date(i);% Solve for Shares for each stock that results in the target market% impact cost.% In this example, x is the number of shares (imbalance) that causes% the MI impact cost, the number of shares that result in a market% impact cost of MI. Here use abs(MI) since market-impact% cost is always positive. If the market-impact cost is 0.0050 then% fsolve tries to find the number of shares x so that the market% impact formula returns 0.0050.% Note that fsolve is using the cost in basis points.x = fsolve(@(x) costIndexExampleEq(x,miCost(i),TradeData(i,:),k),...x0(i),options);% The imbalance must be between 0 and the actual traded volume.x = max(min(x,TradeData.Volume(i)),0);% Recalculate the percentage of volume and shares based on x.TradeData.POV(i) = x/TradeData.Volume(i); TradeData.Shares(i) = x;% Calculate the new cost as a decimal value.mi = marketImpact(k,TradeData(i,:))/10000;% imbalance is the share amount specified as buy or sell by the% sideIndicator.imbalance = sideIndicator(i) * x;% Calculate the buy and sell volumes.% Knowing that:%% Volume = buyVolume + sellVolume;% = buyVolume - sellVolume失衡;%% Solve for buyVolume and sellVolumebuyVolume = (TradeData.Volume(i) + imbalance) / 2; sellVolume = (TradeData.Volume(i) - imbalance) / 2;% Fill output tablecostIndexTable.Imbalance(i,1) = imbalance; costIndexTable.ImbalancePctADV(i,1) = imbalance/TradeData.ADV(i); costIndexTable.ImbalancePctDayVolume(i,1) = imbalance/TradeData.Volume(i); costIndexTable.BuyVolume(i,1) = buyVolume; costIndexTable.SellVolume(i,1) = sellVolume; costIndexTable.MI(i,1) = mi * sideIndicator(i); costIndexTable.ExcessCost(i,1) = totalCost(i) - mi - indexCost(i);end

Display the imbalance amount for the first stock in the output data.

costIndexTable.Imbalance(1)
ans = -8.7894e+04

The negative imbalance amount indicates selling pressure. Decide whether to buy, hold, or sell shares of this stock in the portfolio.

For details about the preceding calculations, contact the Kissell Research Group.

References

[1] Kissell, Robert.The Science of Algorithmic Trading and Portfolio Management. Cambridge, MA: Elsevier/Academic Press, 2013.

[2] Malamut, Roberto. “Multi-Period Optimization Techniques for Trade Scheduling.” Presentation at the QWAFAFEW New York Conference, April 2002.

[3] Kissell, Robert, and Morton Glantz.Optimal Trading Strategies. New York, NY: AMACOM, Inc., 2003.

See Also

|||

Related Topics