Optimize Trade Time Trading Strategy
This example shows how to optimize the strategy for a single stock by minimizing trading costs using transaction cost analysis from the Kissell Research Group. The optimization minimizes trading costs associated with the trade time trading strategy and a specified risk aversion parameter Lambda. The trading cost minimization is expressed as
where trading costs are market impact MI,
                price appreciation PA, and timing risk TR. For
                details, see marketImpact, priceAppreciation, and timingRisk. This example finds a
                local minimum for this expression. For details about searching for the global
                minimum, see Optimization Troubleshooting and Tips.
Here, you can optimize the trade time trade strategy. To optimize percentage of volume and trade schedule strategies, see Optimize Percentage of Volume Trading Strategy and Optimize Trade Schedule Trading Strategy.
To access the example code, enter edit
                    KRGSingleStockOptimizationExample.m at the command line.
Retrieve Market-Impact Parameters and Create Example Data
Retrieve the market-impact data from the Kissell Research Group FTP site.
                    Connect to the FTP site using the ftp function with a user
                    name and password. Navigate to the MI_Parameters folder and
                    retrieve the market-impact data in the
                        MI_Encrypted_Parameters.csv file.
                        miData contains 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 object
                        k.
k = krg(miData);
Create Single Stock Data
The structure tradeData contains data for a single stock.
                    Use a structure or table to define this data. The fields are:
- Number of shares 
- Average daily volume 
- Volatility 
- Stock price 
- Initial trade time trade strategy 
- Alpha estimate 
tradeData.Shares = 100000; tradeData.ADV = 1000000; tradeData.Volatility = 0.25; tradeData.Price = 35; tradeData.TradeTime = 0.5; tradeData.Alpha_bp = 50;
Define Optimization Parameters
Define risk aversion level Lambda. Set
                        Lambda from 0 to Inf.
Lambda = 1;
Define lower LB and upper UB bounds of
                    strategy input for optimization.
LB = 0; UB = 1;
Define the function handle fun for the objective function.
                    To access the code for this function, enter edit
                        krgSingleStockOptimizer.m.
fun = @(tradetime)krgSingleStockOptimizer(tradetime,k,tradeData,Lambda);
Minimize Trading Costs for Trade Strategy
Minimize the trading costs for the trade time trade strategy.
                        fminbnd finds the optimal value for the trade time
                    trade strategy based on the lower and upper bound values.
                        fminbnd finds a local minimum for the trading cost
                    minimization expression.
[tradeData.TradeTime,totalcost] = fminbnd(fun,LB,UB);
Display the optimized trade strategy
                    tradeData.TradeTime.
tradeData.TradeTime
ans =
    0.19Estimate Trading Costs for Optimized Strategy
Estimate the trading costs tradeTimeCosts using the
                    optimized trade strategy.
mi = marketImpact(k,tradeData); tr = timingRisk(k,tradeData); pa = priceAppreciation(k,tradeData); tradeTimeCosts = [totalcost mi pa tr];
Display trading costs.
tradeTimeCosts
tradeTimeCosts =
        100.04         56.15          4.63         39.27The trading costs are:
- Total cost 
- Market impact 
- Price appreciation 
- Timing risk 
For details about the preceding calculations, contact the Kissell Research Group.
References
[1] Kissell, Robert. “Algorithmic Trading Strategies.” Ph.D. Thesis. Fordham University, May 2006.
[2] Kissell, Robert. The Science of Algorithmic Trading and Portfolio Management. Cambridge, MA: Elsevier/Academic Press, 2013.
[3] Glantz, Morton, and Robert Kissell. Multi-Asset Risk Modeling. Cambridge, MA: Elsevier/Academic Press, 2013.
[4] Kissell, Robert, and Morton Glantz. Optimal Trading Strategies. New York, NY: AMACOM, Inc., 2003.
See Also
fminbnd | marketImpact | priceAppreciation | timingRisk | krg