# Valuing Total Return Swaps

In my quest for simulated data, I am trying to generate prices for Total Return Swaps by calculating the NPVs of the fixed and floating leg. My problem: Given the fixed leg, how do I set the spread on the floating leg so that the value of the swap at the beginning equals Zero?

On a more technical side: Using RQuantLib, I use FloatingRateBond to calculate the NPV. How exactly do I set the spread there? The documentation is a bit unclear at that point.

-
Not sure I understand your question. If I have a fixed stream of payments it has some value $V_{fixed}$ I can always solve for a spread to LIBOR by simply adding the spread $S$ to my calculated stream of LIBOR.
$$V_{LIBOR}(S) = \sum_{n=1}^{N} D(t_{n}) \alpha(t_{n-1},t_{n}) [L(t_{n-1},t_{n}) + S]$$ where $D(t_{n})$ is the discount factor, $\alpha$ is the day count fraction, and $L$ is the LIBOR rate. I just solve $$V_{LIBOR}(S) = V_{fixed}$$ for S.