July 7th, 2016, 3:57 pm
Hmm, complex numbers have their use in math finance, but this is probably not where you want them. I am not familiar with the particular Matlab function, but most likely it is taking the log of a number that ought to be positive, but which is in fact negative due to some numerical precision issue. I see no easy way out short of stepping into the code to find the offending line. Once you know where it is going wrong you can start thinking about how to fix it, or at least code around it. Of course, names on the verge of default (where the problem arises) really should not be quoted in spread terms, but I know for a fact that it has happened, so that is neither here nor there. For names quoted in up-front terms, there is the separate problem when you encounter an up-front premium greater than (1-R), in which case you are forced to change R...