<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="http://noelevans.co.uk/feed.xml" rel="self" type="application/atom+xml" /><link href="http://noelevans.co.uk/" rel="alternate" type="text/html" /><updated>2019-09-02T19:58:21+00:00</updated><id>http://noelevans.co.uk/feed.xml</id><title type="html">Noel Evans</title><subtitle>Python programmer living in London, UK.</subtitle><entry><title type="html">Mapping caps lock to escape in Windows 7</title><link href="http://noelevans.co.uk/mapping-caps-lock-to-escape-in-windows-7/" rel="alternate" type="text/html" title="Mapping caps lock to escape in Windows 7" /><published>2019-06-14T19:53:23+00:00</published><updated>2019-06-14T19:53:23+00:00</updated><id>http://noelevans.co.uk/mapping-caps-lock-to-escape-in-windows-7</id><content type="html" xml:base="http://noelevans.co.uk/mapping-caps-lock-to-escape-in-windows-7/">&lt;p&gt;&lt;!-- wp:paragraph --&gt;&lt;/p&gt;
&lt;p&gt;While working in a large organisation where all external software was forbidden, I wanted to map my caps lock to escape to improve my Vim experience. The route which finally worked was to use the reg instruction:&lt;/p&gt;
&lt;p&gt;&lt;!-- /wp:paragraph --&gt;&lt;/p&gt;
&lt;p&gt;&lt;!-- wp:paragraph --&gt;&lt;/p&gt;
&lt;p&gt;Windows Registry Editor Version 5.00&lt;/p&gt;
&lt;p&gt;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]&lt;br /&gt;&quot;Scancode Map&quot;=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00    &lt;/p&gt;
&lt;p&gt;&lt;!-- /wp:paragraph --&gt;&lt;/p&gt;
&lt;p&gt;&lt;!-- wp:paragraph --&gt;&lt;/p&gt;
&lt;p&gt;I found this on &lt;a href=&quot;https://vim.fandom.com/wiki/Map_caps_lock_to_escape_in_Windows&quot;&gt;vim.fandom.com&lt;/a&gt;. I first tried the &quot;current user&quot; method. This didn't work so I changed to using the &quot;all users&quot; option which was successful.&lt;/p&gt;
&lt;p&gt;&lt;!-- /wp:paragraph --&gt;&lt;/p&gt;</content><author><name>Noel</name></author><summary type="html">While working in a large organisation where all external software was forbidden, I wanted to map my caps lock to escape to improve my Vim experience. The route which finally worked was to use the reg instruction: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]&quot;Scancode Map&quot;=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00 I found this on vim.fandom.com. I first tried the &quot;current user&quot; method. This didn't work so I changed to using the &quot;all users&quot; option which was successful.</summary></entry><entry><title type="html">Setup Raspberry PI 3 with no (ethernet) cable, monitor, keyboard, etc.</title><link href="http://noelevans.co.uk/setup-raspberry-pi-3-with-no-ethernet-cable-monitor-keyboard-etc/" rel="alternate" type="text/html" title="Setup Raspberry PI 3 with no (ethernet) cable, monitor, keyboard, etc." /><published>2017-07-27T21:24:22+00:00</published><updated>2017-07-27T21:24:22+00:00</updated><id>http://noelevans.co.uk/setup-raspberry-pi-3-with-no-ethernet-cable-monitor-keyboard-etc</id><content type="html" xml:base="http://noelevans.co.uk/setup-raspberry-pi-3-with-no-ethernet-cable-monitor-keyboard-etc/">&lt;p&gt;A complete guide to setting up a Raspberry Pi 3 (RPi) to connect wirelessly. Everything is setup from your laptop, writing to a micro SD card before plugging the card in to the RPi. I'm doing this on an Ubuntu computer. I imagine it is very similar from a Mac.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download and unzip the &lt;a href=&quot;https://www.raspberrypi.org/downloads/raspbian/&quot;&gt;Raspbian Lite&lt;/a&gt; operating system (OS). You will now have an img file ready to write somewhere.&lt;/li&gt;
&lt;li&gt;Download, install and run &lt;a href=&quot;https://etcher.io/&quot;&gt;Etcher&lt;/a&gt; to write the raw operating system to the SD card. This is by far the easiest / safest way to write the OS to the card. (Note I have no liability for mistakes that may occur with this. Follow the instructions on Etcher's website)&lt;/li&gt;
&lt;li&gt;Open a command window and enter:
&lt;pre class=&quot;&quot;&gt;sudo touch /media/xyz/boot/ssh&lt;/pre&gt;
&lt;p&gt;where xyz is the path to the SD card and main_drive_abc will be some long text. One of these two is not necessary but I don't care which. This writes an empty file to these folders. They enable ssh so the RPi can be connected to using the SSH protocol from your laptop.&lt;/li&gt;
&lt;li&gt;Now to use WiFi you'll need to give the RPi your username and password. This command will open an editor on the file that stores this information:
&lt;pre class=&quot;&quot;&gt;sudo nano /media/xyz/main_drive_abc/etc/wpa_supplicant/wpa_supplicant.conf&lt;/pre&gt;
&lt;p&gt;At the bottom of the file add this:&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;network={
    ssid=&quot;wifi_name&quot;
    psk=&quot;wifi_password&quot;
}&lt;/pre&gt;
&lt;p&gt;Now press Ctrl+X to exit. Press &quot;y&quot; to save it as the correct filename.&lt;/li&gt;
&lt;li&gt;Put the SD card in the RPi. Plug in the USB power cable. You are ready to connect from your laptop.&lt;/li&gt;
&lt;li&gt;Find the RPi on your network using the command&lt;br /&gt;
&lt;span class=&quot;crayon-e&quot;&gt;sudo &lt;/span&gt;&lt;span class=&quot;crayon-v&quot;&gt;arp&lt;/span&gt;&lt;span class=&quot;crayon-o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;crayon-v&quot;&gt;scan&lt;/span&gt; &lt;span class=&quot;crayon-o&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;crayon-v&quot;&gt;localnet&lt;/span&gt;&lt;br /&gt;
Hopefully there will be an obvious choice. If not, try the following instruction changing the final number in the IP address below with each choice you see in arp-scan's output&lt;/li&gt;
&lt;li&gt;Connect to the RPi with the command (changing 192.168.0.18 for whatever number your RPi is allocated on your network)
&lt;pre class=&quot;&quot;&gt;ssh pi@192.168.0.18&lt;/pre&gt;
&lt;p&gt;The username you are using is pi. The password when prompted is &quot;raspberry&quot;&lt;/li&gt;
&lt;li&gt;It is a huge security whole leaving the password unchanged. Run
&lt;pre class=&quot;&quot;&gt;sudo raspi-config&lt;/pre&gt;
&lt;p&gt;This gives you an interactive menu. Change the password, update the system. You now have an operational Raspberry Pi to hack.&lt;/li&gt;
&lt;/ol&gt;</content><author><name>Noel</name></author><summary type="html">A complete guide to setting up a Raspberry Pi 3 (RPi) to connect wirelessly. Everything is setup from your laptop, writing to a micro SD card before plugging the card in to the RPi. I'm doing this on an Ubuntu computer. I imagine it is very similar from a Mac. Download and unzip the Raspbian Lite operating system (OS). You will now have an img file ready to write somewhere. Download, install and run Etcher to write the raw operating system to the SD card. This is by far the easiest / safest way to write the OS to the card. (Note I have no liability for mistakes that may occur with this. Follow the instructions on Etcher's website) Open a command window and enter: sudo touch /media/xyz/boot/ssh where xyz is the path to the SD card and main_drive_abc will be some long text. One of these two is not necessary but I don't care which. This writes an empty file to these folders. They enable ssh so the RPi can be connected to using the SSH protocol from your laptop. Now to use WiFi you'll need to give the RPi your username and password. This command will open an editor on the file that stores this information: sudo nano /media/xyz/main_drive_abc/etc/wpa_supplicant/wpa_supplicant.conf At the bottom of the file add this: network={ ssid=&quot;wifi_name&quot; psk=&quot;wifi_password&quot; } Now press Ctrl+X to exit. Press &quot;y&quot; to save it as the correct filename. Put the SD card in the RPi. Plug in the USB power cable. You are ready to connect from your laptop. Find the RPi on your network using the command sudo arp-scan --localnet Hopefully there will be an obvious choice. If not, try the following instruction changing the final number in the IP address below with each choice you see in arp-scan's output Connect to the RPi with the command (changing 192.168.0.18 for whatever number your RPi is allocated on your network) ssh pi@192.168.0.18 The username you are using is pi. The password when prompted is &quot;raspberry&quot; It is a huge security whole leaving the password unchanged. Run sudo raspi-config This gives you an interactive menu. Change the password, update the system. You now have an operational Raspberry Pi to hack.</summary></entry><entry><title type="html">Interview questions</title><link href="http://noelevans.co.uk/interview-questions/" rel="alternate" type="text/html" title="Interview questions" /><published>2016-02-23T21:51:25+00:00</published><updated>2016-02-23T21:51:25+00:00</updated><id>http://noelevans.co.uk/interview-questions</id><content type="html" xml:base="http://noelevans.co.uk/interview-questions/">&lt;ol&gt;
&lt;li&gt;Given a whole number, n return the sum of all the numbers from 1 to n inclusive&lt;/li&gt;
&lt;li&gt;Given a dictionary in the form {'year': '2016', 'month': '01', 'day': '27'} (noting the values are strings, return a datetime.date representation of the dict&lt;/li&gt;
&lt;li&gt;Count the number of troughs and peaks in a list eg.&lt;br /&gt;
ol = [2, 2, 5, 4, 1, 2, 1, 2, 2] (answer: 5, 1, 2, 1 = 4)&lt;/li&gt;
&lt;/ol&gt;</content><author><name>Noel</name></author><summary type="html">Given a whole number, n return the sum of all the numbers from 1 to n inclusive Given a dictionary in the form {'year': '2016', 'month': '01', 'day': '27'} (noting the values are strings, return a datetime.date representation of the dict Count the number of troughs and peaks in a list eg. ol = [2, 2, 5, 4, 1, 2, 1, 2, 2] (answer: 5, 1, 2, 1 = 4)</summary></entry><entry><title type="html">Swimming times</title><link href="http://noelevans.co.uk/swimming-times/" rel="alternate" type="text/html" title="Swimming times" /><published>2016-01-16T16:46:30+00:00</published><updated>2016-01-16T16:46:30+00:00</updated><id>http://noelevans.co.uk/swimming-times</id><content type="html" xml:base="http://noelevans.co.uk/swimming-times/">Options for lunchtime lane swimming near Canary Wharf (and NW London in the evening)


|.     |Tiller Road  |Burdett Road |St Georges   |Swiss Cottage |Northolt     |
|------|-------------|-------------|-------------|--------------|-------------|
|Mon   |12:15 - 13:30|12:15 - 21:30|12:30 - 13:30|.             |06:30 - 21:30|
|Tues  |12:15 - 13:30|12:00 - 21:30|12:30 - 13:30|2 lanes       |06:30 - 21:30|
|Wed   |12:00 - 13:30|12:00 - 21:30|12:30 - 13:30|.             |06:30 - 21:30|
|Thurs |12:15 - 13:30|12:00 - 19:00|.            |.             |06:30 - 21:30|
|Fri   |12:15 - 13:30|06:30 - 22:00|12:30 - 13:30|06:30 - 18:00 |06:30 - 21:30|

Pool hours rather than centre hours</content><author><name>Noel</name></author><summary type="html">Options for lunchtime lane swimming near Canary Wharf (and NW London in the evening)</summary></entry><entry><title type="html">RPi Tube status checker</title><link href="http://noelevans.co.uk/rpi-tube-status-checker/" rel="alternate" type="text/html" title="RPi Tube status checker" /><published>2016-01-16T16:39:34+00:00</published><updated>2016-01-16T16:39:34+00:00</updated><id>http://noelevans.co.uk/rpi-tube-status-checker</id><content type="html" xml:base="http://noelevans.co.uk/rpi-tube-status-checker/">Like most Londoners I depend on the Underground system to get to the office where I am on a contract. A delay or suspension can cause big problems for the morning commute so I decided to put my Raspberry Pi to use, alerting of problems on the tube network before heading out the door. I used TFL's API: status to check how the lines are running and put the Piglow I had to use – one arm for the Metropolitan line, one for the Jubilee line, the final arm for the other lines combined (I get to work using just the Met and Jubilee lines). A single light on an arm of the Piglow indicates good service, two lights - minor delays and the whole arm lit to indicate more serious problems.

&lt;a href=&quot;/assets/rpi.jpg&quot;&gt;&lt;img class=&quot;size-medium wp-image-533&quot; src=&quot;/assets/rpi-300x169.jpg&quot; alt=&quot;Raspberry Pi showing tube status&quot; width=&quot;300&quot; height=&quot;169&quot; /&gt;&lt;/a&gt;</content><author><name>Noel</name></author><summary type="html">Like most Londoners I depend on the Underground system to get to the office where I am on a contract. A delay or suspension can cause big problems for the morning commute so I decided to put my Raspberry Pi to use, alerting of problems on the tube network before heading out the door. I used TFL's API: status to check how the lines are running and put the Piglow I had to use – one arm for the Metropolitan line, one for the Jubilee line, the final arm for the other lines combined (I get to work using just the Met and Jubilee lines). A single light on an arm of the Piglow indicates good service, two lights - minor delays and the whole arm lit to indicate more serious problems.</summary></entry><entry><title type="html">defaultdict explained</title><link href="http://noelevans.co.uk/defaultdict-explained/" rel="alternate" type="text/html" title="defaultdict explained" /><published>2015-12-11T22:39:43+00:00</published><updated>2015-12-11T22:39:43+00:00</updated><id>http://noelevans.co.uk/defaultdict-explained</id><content type="html" xml:base="http://noelevans.co.uk/defaultdict-explained/">&lt;p&gt;If we wanted to count occurrences in a list (without collections.Counter) we could write this:&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;    res = {}
    for x in xs:
        res[x] = res.get(x, 0) + 1&lt;/pre&gt;
&lt;p&gt;Alternatively, we could use a defaultdict. The constructor of a defaultdict takes one arg – a function – what to do when a new key is added to the dict. So instead, you could write:&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;    from collections import defaultdict
    res = defaultdict(lambda: 0)
    for x in xs:
        d[x] += 1&lt;/pre&gt;
&lt;p&gt;But the final addition that makes it briefer but perhaps more confusing on first approach is that defaultdict understands int to mean the same as lambda: 0 and has the same effect. I.e.&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;    res = defaultdict(int)&lt;/pre&gt;</content><author><name>Noel</name></author><summary type="html">If we wanted to count occurrences in a list (without collections.Counter) we could write this:     res = {}     for x in xs:         res[x] = res.get(x, 0) + 1 Alternatively, we could use a defaultdict. The constructor of a defaultdict takes one arg – a function – what to do when a new key is added to the dict. So instead, you could write:     from collections import defaultdict     res = defaultdict(lambda: 0)     for x in xs:         d[x] += 1 But the final addition that makes it briefer but perhaps more confusing on first approach is that defaultdict understands int to mean the same as lambda: 0 and has the same effect. I.e.     res = defaultdict(int)</summary></entry><entry><title type="html">Github pull request</title><link href="http://noelevans.co.uk/github-pull-request/" rel="alternate" type="text/html" title="Github pull request" /><published>2015-09-28T21:15:40+00:00</published><updated>2015-09-28T21:15:40+00:00</updated><id>http://noelevans.co.uk/github-pull-request</id><content type="html" xml:base="http://noelevans.co.uk/github-pull-request/">&lt;p&gt;Best tutorial on doing a pull request for a Github repository: &lt;a href=&quot;https://www.thinkful.com/learn/github-pull-request-tutorial/Time-to-Submit-Your-First-PR#Time-to-Submit-Your-First-PR&quot;&gt;Thinkful&lt;/a&gt;. Skip to the bottom to &quot;Time to Submit Your First PR&quot;&lt;/p&gt;</content><author><name>Noel</name></author><summary type="html">Best tutorial on doing a pull request for a Github repository: Thinkful. Skip to the bottom to &quot;Time to Submit Your First PR&quot;</summary></entry><entry><title type="html">Undo a git commit</title><link href="http://noelevans.co.uk/undo-a-git-commit/" rel="alternate" type="text/html" title="Undo a git commit" /><published>2015-08-23T08:48:41+00:00</published><updated>2015-08-23T08:48:41+00:00</updated><id>http://noelevans.co.uk/undo-a-git-commit</id><content type="html" xml:base="http://noelevans.co.uk/undo-a-git-commit/">&lt;p class=&quot;&quot;&gt;When you haven't pushed the commit; you've just realised after running a commit and too many files have been included in the command.&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;git reset --soft HEAD~1&lt;/pre&gt;</content><author><name>Noel</name></author><summary type="html">When you haven't pushed the commit; you've just realised after running a commit and too many files have been included in the command. git reset --soft HEAD~1</summary></entry><entry><title type="html">Interesting libraries to tinker with</title><link href="http://noelevans.co.uk/interesting-libraries-to-tinker-with/" rel="alternate" type="text/html" title="Interesting libraries to tinker with" /><published>2015-08-15T08:53:08+00:00</published><updated>2015-08-15T08:53:08+00:00</updated><id>http://noelevans.co.uk/interesting-libraries-to-tinker-with</id><content type="html" xml:base="http://noelevans.co.uk/interesting-libraries-to-tinker-with/">&lt;p&gt;Luigi - a Python job scheduling library. Sounds a lot like Bob Jobs at well known IBs&lt;/p&gt;
&lt;p&gt;Lasagne / Keras / OpenDeep - deep learning libraries for Python&lt;/p&gt;
&lt;p&gt;Celery and Twisted to run functions asynchronously&lt;/p&gt;
&lt;p&gt;Maths tools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;statsmodels&lt;/li&gt;
&lt;li&gt;numexpr&lt;/li&gt;
&lt;li&gt;patsy&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;.&lt;/p&gt;</content><author><name>Noel</name></author><summary type="html">Luigi - a Python job scheduling library. Sounds a lot like Bob Jobs at well known IBs Lasagne / Keras / OpenDeep - deep learning libraries for Python Celery and Twisted to run functions asynchronously Maths tools: statsmodels numexpr patsy .</summary></entry><entry><title type="html">How to price a swap</title><link href="http://noelevans.co.uk/how-to-price-a-swap/" rel="alternate" type="text/html" title="How to price a swap" /><published>2015-08-13T19:46:20+00:00</published><updated>2015-08-13T19:46:20+00:00</updated><id>http://noelevans.co.uk/how-to-price-a-swap</id><content type="html" xml:base="http://noelevans.co.uk/how-to-price-a-swap/">&lt;p&gt;A vanilla interest rate swap is an agreement to swap a fixed rate coupons made on a large notional amount against floating rate coupons on the same notional. The floating rate used may be LIBOR, EURIBOR, EONIA, etc. At the conclusion of the agreement, the notional amount of the trade is not exchanged between the parties.&lt;/p&gt;
&lt;p&gt;Our example will be a five year swap where payments are made every 6 months using LIBOR for the floating leg and the fixed rate will be 3%. On the trade date the LIBOR rate will be recorded. This will dictate the floating payment payment to be made at the first payment date in 6 months time. At that time, the corresponding fixed payment will be 0.03 * notional_amount. For the other 9 payments, the fixed leg will continue to pay the same sum: 0.03 * notional_amount. For the floating leg, the rate to be paid will continue to be the LIBOR rate snapped at the previous payment date i.e.&lt;/p&gt;
&lt;pre class=&quot;&quot;&gt;Payment    Time (months)    Rate (as at month)
      1                6                     0
      2               12                     6
      3               18                    12

    ...              ...                   ...

&lt;/pre&gt;
&lt;p class=&quot;&quot;&gt;The price of each leg is as follows:&lt;/p&gt;
&lt;p class=&quot;&quot; style=&quot;padding-left: 30px;&quot;&gt;PV = ce&lt;sup&gt;- 0.5 R1&lt;/sup&gt; + ce&lt;sup&gt;- 1.0 R2&lt;/sup&gt;&lt;/p&gt;
&lt;p class=&quot;&quot;&gt;Where c (for coupon) is the notional amount&lt;/p&gt;
&lt;p class=&quot;&quot;&gt;So the value of the fixed leg is a straight forward calculation. The value of the floating leg is the same but uses rates taken from the swap curve which we need to build.&lt;/p&gt;
&lt;h2 class=&quot;&quot;&gt;Building a swap curve&lt;/h2&gt;
&lt;p class=&quot;&quot;&gt;When valuing the floating leg on the trade date, we need to take rates from the swap curve.&lt;a href=&quot;/assets/Drawing-2.png&quot;&gt;&lt;img class=&quot; size-medium wp-image-492 alignright&quot; src=&quot;/assets/Drawing-2-300x157.png&quot; alt=&quot;Swap curve&quot; width=&quot;300&quot; height=&quot;157&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
This is built from a variety of products taken from exchanges where the products are of similar credit worthiness.&lt;/p&gt;
&lt;p class=&quot;&quot;&gt;The rates that make the curve are &quot;n-year zero rates&quot;, often called zero rates. A zero rate is the rate an investment (like an IR bond) would pay when all of the interest was paid at maturity with the repayment of a principal amount. So we can see a 5 year investment should return at a rate of about 4.2% from our curve above. Where do these rates to make the curve come from:&lt;/p&gt;
&lt;h4 class=&quot;&quot;&gt;Short-end&lt;/h4&gt;
&lt;p&gt;These are the easy points of the swap curve. In the near future, there are many publicly quoted bonds that are nearing expiry where there are no remaining coupons to be paid. It can therefore be assumed that the rates offered are purely zero-rates. They just need to be converted in to continually compounding interest.&lt;/p&gt;
&lt;p&gt;A bond with a principal of $100, maturing in 3 months (0.25 years) has no more coupons to pay and in the market today is priced at $97.50. Therefore it will return $2.5 over the 3 months and so its quarterly compounding interest is&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;(4 x 2.5 / 97.5 = 0.10256 or 10.256% per annum&lt;/p&gt;
&lt;p&gt;Expressed in continually compounding interest, this is&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;R&lt;sub&gt;3m&lt;/sub&gt; = 4 ln (1 + (0.10256 / 4)) = 0.10127 or  10.127%&lt;/p&gt;
&lt;h4&gt;Long-end&lt;/h4&gt;
&lt;p&gt;Further out in the future, bonds will have coupons still to be paid midway through their lifecycle. These can make points on the swap curve but first have to be converted to a zero-rate IR products: adjusted to be a single bullet payment at maturity with the correct equivalent interest rate. This new interest rate is called the &quot;implied zero-coupon rate&quot; or just &quot;zero rate&quot;. Bonds are added to the curve one after another from the earlier maturing bonds to the last maturing, going out 30 - 50 years from now. To take an example:&lt;/p&gt;
&lt;p&gt;We have a bond expiring in 6 months (0.5 years). It pays 4 coupons annually of $8 ($2 each time) with a $100 principal. Today it is available on the market at $96.00. Therefore the payments on this bond will be:&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;3 months: $2&lt;br /&gt;
6 months: $102&lt;/p&gt;
&lt;p&gt;So for the zero rate at 6 months, this equation allows us to infer the 6m continuously compounding rate:&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;2 e&lt;sup&gt;0.10127 x 0.25&lt;/sup&gt; + 2 e&lt;sup&gt;0.5 R&lt;/sup&gt; = 96&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;∴  R&lt;sub&gt;6m&lt;/sub&gt; = 2ln(96 - 2 e&lt;sup&gt;0.10127 x 0.25&lt;/sup&gt; / 2)&lt;/p&gt;</content><author><name>Noel</name></author><summary type="html">A vanilla interest rate swap is an agreement to swap a fixed rate coupons made on a large notional amount against floating rate coupons on the same notional. The floating rate used may be LIBOR, EURIBOR, EONIA, etc. At the conclusion of the agreement, the notional amount of the trade is not exchanged between the parties. Our example will be a five year swap where payments are made every 6 months using LIBOR for the floating leg and the fixed rate will be 3%. On the trade date the LIBOR rate will be recorded. This will dictate the floating payment payment to be made at the first payment date in 6 months time. At that time, the corresponding fixed payment will be 0.03 * notional_amount. For the other 9 payments, the fixed leg will continue to pay the same sum: 0.03 * notional_amount. For the floating leg, the rate to be paid will continue to be the LIBOR rate snapped at the previous payment date i.e. Payment Time (months) Rate (as at month) 1 6 0 2 12 6 3 18 12 ... ... ... The price of each leg is as follows: PV = ce- 0.5 R1 + ce- 1.0 R2 Where c (for coupon) is the notional amount So the value of the fixed leg is a straight forward calculation. The value of the floating leg is the same but uses rates taken from the swap curve which we need to build. Building a swap curve When valuing the floating leg on the trade date, we need to take rates from the swap curve. This is built from a variety of products taken from exchanges where the products are of similar credit worthiness. The rates that make the curve are &quot;n-year zero rates&quot;, often called zero rates. A zero rate is the rate an investment (like an IR bond) would pay when all of the interest was paid at maturity with the repayment of a principal amount. So we can see a 5 year investment should return at a rate of about 4.2% from our curve above. Where do these rates to make the curve come from: Short-end These are the easy points of the swap curve. In the near future, there are many publicly quoted bonds that are nearing expiry where there are no remaining coupons to be paid. It can therefore be assumed that the rates offered are purely zero-rates. They just need to be converted in to continually compounding interest. A bond with a principal of $100, maturing in 3 months (0.25 years) has no more coupons to pay and in the market today is priced at $97.50. Therefore it will return $2.5 over the 3 months and so its quarterly compounding interest is (4 x 2.5 / 97.5 = 0.10256 or 10.256% per annum Expressed in continually compounding interest, this is R3m = 4 ln (1 + (0.10256 / 4)) = 0.10127 or  10.127% Long-end Further out in the future, bonds will have coupons still to be paid midway through their lifecycle. These can make points on the swap curve but first have to be converted to a zero-rate IR products: adjusted to be a single bullet payment at maturity with the correct equivalent interest rate. This new interest rate is called the &quot;implied zero-coupon rate&quot; or just &quot;zero rate&quot;. Bonds are added to the curve one after another from the earlier maturing bonds to the last maturing, going out 30 - 50 years from now. To take an example: We have a bond expiring in 6 months (0.5 years). It pays 4 coupons annually of $8 ($2 each time) with a $100 principal. Today it is available on the market at $96.00. Therefore the payments on this bond will be: 3 months: $2 6 months: $102 So for the zero rate at 6 months, this equation allows us to infer the 6m continuously compounding rate: 2 e0.10127 x 0.25 + 2 e0.5 R = 96 ∴  R6m = 2ln(96 - 2 e0.10127 x 0.25 / 2)</summary></entry></feed>