Tag Archives: Portfolio
Construction Bond Portfolio Management in a Object-Oriented R Way
Posted by Shawn Zhang
on July 8, 2012
No comments
I've been read a lot of articles, blogs and other online resources about programming R, most of them discuss a lot about it's powerful statistic features. But there are less topics about it's Object-Oriented features, I'm going to navigate these features to construct a Portfolio Management. (PS: all following R code will be in a S4 Style)
Define a Bond Class
A portfolio means a collection of assets, asset could be different financial products ,like Bond, Future, Stock or other derivatives . We Read more [...]
Implement Portfolio Variance Calculation in R
Posted by Shawn Zhang
on May 31, 2012
No comments
It is critical to calculate total variance of portfolio given inputs of variance of assets within the portfolio . There is a little hardship in dealing with the correlation of the assets . Interaction for each pair of assets should be calculated separately. (See second term in below )
if we construct a function with input two vector, (weight vector and volatility vector) it is quite easy to implement first term with R by above:
sum(w^2 * s^2)
for the second term , we need a correlation Read more [...]