API Docs

Manual, tutorials and complete function reference

Transactional Costs


These settings provide a framework for adding variable and fixed transactional costs into return, expected return and profit calculations. All metrics based on expected return like Sharpe Ratio, VaR (with drift term enabled) would reflect transactional costsin their computations.


Cost Per Share

Amount of transaction costs per share. Default value is 0.

require(PortfolioEffectHFT)
portfolio=portfolio_create(fromTime="2014-10-01 09:30:00", toTime="2014-10-02 16:00:00")
portfolio_addPosition(portfolio,c('C','SPY'),c(500,600))

# Transactional costs per share are 0.5 cent 
portfolio_settings(portfolio, txnCostPerShare=0.005)
portfolio_return(portfolio)

# Transactional costs per share are 0.1 cent 
portfolio_settings(portfolio, txnCostPerShare=0.001)
portfolio_return(portfolio)
portfolio=portfolio_create('index','SPY','fromTime','2014-10-01 09:30:00','toTime','2014-10-02 16:00:00')
portfolio_addPosition(portfolio,['GOOG';'AAPL'],[200;100])

% Transactional costs per share are 0.5 cent 
portfolio_settings(portfolio, 'txnCostPerShare', 0.005)
portfolio_return(portfolio)

% Transactional costs per share are 0.1 cent 
portfolio_settings(portfolio, 'txnCostPerShare', 0.001)
portfolio_return(portfolio)

Cost Per Transaction

Amount of fixed costs per transaction. Defaults to 0.

require(PortfolioEffectHFT)
portfolio=portfolio_create(fromTime="2014-10-01 09:30:00", toTime="2014-10-02 16:00:00")
portfolio_addPosition(portfolio,c('C','SPY'),c(500,600))

# Fixed costs per transaction are 9 dollars
portfolio_settings(portfolio, txnCostFixed=9.0)
portfolio_return(portfolio)

# Fixed costs per transaction are 1 dollar
portfolio_settings(portfolio, txnCostFixed=1.0)
portfolio_return(portfolio)
portfolio=portfolio_create('index','SPY','fromTime','2014-10-01 09:30:00','toTime','2014-10-02 16:00:00')
portfolio_addPosition(portfolio,['C';'SPY'],[500;600])

% Fixed costs per transaction are 9 dollars
portfolio_settings(portfolio, 'txnCostFixed', 9.0)
portfolio_return(portfolio)

% Fixed costs per transaction are 1 dollar
portfolio_settings(portfolio, 'txnCostFixed', 1.0)
portfolio_return(portfolio)