Main Content

getCosts

Obtain buy and sell transaction costs from portfolio object

Description

Use thegetCostsfunction with aPortfolio,PortfolioCVaR, orPortfolioMADobject to obtain buy and sell transaction costs from portfolio objects.

For details on the respective workflows when using these different objects, seePortfolio Object Workflow,PortfolioCVaR Object Workflow, andPortfolioMAD对象的工作流.

example

[BuyCost,SellCost] = getCosts(obj)obtains buy and sell transaction costs from portfolio objects.

Examples

collapse all

Given portfoliopwith the costs set, obtain the values forBuyCostandSellCost.

p = Portfolio; p = setCosts(p, 0.001, 0.001, 5); [BuyCost, SellCost] = getCosts(p)
BuyCost = 1.0000e-03
SellCost = 1.0000e-03

Given a PortfolioCVaR objectpwith the costs set, obtain the values forBuyCostandSellCost.

p = PortfolioCVaR; p = setCosts(p, 0.001, 0.001, 5); [BuyCost, SellCost] = getCosts(p)
BuyCost = 1.0000e-03
SellCost = 1.0000e-03

Given a PortfolioMAD objectpwith the costs set, obtain the values forBuyCostandSellCost.

p = PortfolioMAD; p = setCosts(p, 0.001, 0.001, 5); [BuyCost, SellCost] = getCosts(p)
BuyCost = 1.0000e-03
SellCost = 1.0000e-03

Input Arguments

collapse all

Object for portfolio, specified usingPortfolio,PortfolioCVaR, orPortfolioMADobject. For more information on creating a portfolio object, see

Data Types:object

Output Arguments

collapse all

Proportional transaction cost to purchase each asset, returned as a vector for aPortfolio,PortfolioCVaR, orPortfolioMADinput object (obj).

Proportional transaction cost to sell each asset, returned as a vector for aPortfolio,PortfolioCVaR, orPortfolioMADinput object (obj).

Tips

You can also use dot notation to obtain the buy and sell transaction costs from portfolio objects.

[BuyCost, SellCost] = obj.getCosts;

Version History

Introduced in R2011a