I am new to the quant finance community...

I have a series of bond cash flows, its market prices and also the spot rates for the timing of those cash flows. How to find the Z-Spread that matches its market price in R?

I have written a brute force code starting the Z-spread from zero and increasing it until the price equals market price. Is there any easy method than this?

I have 2000 bonds and I have to calculate Z-Spreads for all them...and running this brute force code for all them.. It takes 10 hourss..

How to simplify this...

• So mathematically the problem is to find z such that $P=\sum_i C_i e^{-(r_i+z)t_i}$ ? – noob2 Sep 30 '16 at 19:23