Futures conversion factors in Mathematica

Sovereign debt futures in the U.S. and elsewhere are designed to accept multiple different bonds for delivery. The exchange specifies a delivery factor algorithm to normalize the prices of these bonds (or notes) to make them roughly of equal value upon delivery. Since they’re not precisely of equal value, traders can make money trading around the cheapest to deliver bond.

The conversion factor in the U.S. is designed to convert the yield on any bond or note to 6%. Considering the semi-annual or monthly coupon payments on bonds and notes, the formula to do this looks as follows.

Options[conversionfactor] = {type -> "bond"};
(* versus "10yr note", "5yr note", or "2yr note" *)

conversionfactor[coupon_Real, wholeYearsToMaturity_Integer,
stubMonthsToMatury_Integer, OptionsPattern[]] :=
Module[{v, a, b, c, d},
v = If[stubMonthsToMatury < 7, stubMonthsToMatury, If[OptionValue[type] == "bond" || OptionValue[type] == "10yr note", 3, stubMonthsToMatury - 6]](* for 10 year, other options possible for other instruments *); a = 1/1.03^(v/6); b = coupon/2*(6 - v)/6; c = If[stubMonthsToMatury < 7, 1/1.03^(2*wholeYearsToMaturity), 1/ 1.03^(2*wholeYearsToMaturity + 1)]; d = coupon/.06*(1 - c); a*(coupon/2 + c + d) - b]

wholeYearsToMaturity represents the number of whole years from the first day of the delivery month to the maturity (or call) date of the bond or note.

stubMonthsToMatury represents the number of whole months between wholeYearsToMaturity and the maturity (or call) date rounded down to the nearest quarter for Treasury Bonds and 10 Year Note futures, or to the nearest month for 5-year and 2-year note futures.

For a 2 year note with 1 year, 10 months remaining and a coupon of .015,

In[]:= conversionfactor[.015, 1, 10, type -> "2yr note"]
Out[]= 0.922939

For a 5 year note with 4 years, 10 months remaining and a coupon of .0275

In[]:= conversionfactor[.0275, 4, 10, type -> "5yr note"]
Out[]= 0.86533

Memory conformity

There was a nice article in Science this week about Memory Conformity, the phenomenon whereby people will alter their own memories to conform with versions of events claimed by others. In the study, even people who correctly remembered a test event would persuade themselves that they had seen something different if their peers claimed to have seen it.

The study used brain imaging to try to figure out how this happens, and their results seem so vague as to be of little use. However the phenomenon itself is fascinating, and I wonder if it explains anomalies like the Angel of Mons, a fairy tale about angels appearing in the sky over British troops in WWI, subsequently believed by some of the people who were there.

The theory seems to me relevant to the financial markets, as the number of opinions in the market tend to collapse to a much narrower range than the breadth of experience and knowledge present would seem to justify. Most people abandon their own memory of precedents, and their own intuitive or formal models, and buy into the consensus narrative for why housing prices should be high, or internet stocks, or whatever.

A line of bicycles at work this morning

The building in which I work requires bicycles to use the freight elevator during business hours. I have been following this rule for several months. Today, I arrived later than usual and for the first time found a line.

There was a fixed gear, a beater, a Brompton folding bike, a hardtail mountain bike with slicks. None of it casual, though. These were all bikes that saw a lot of use.

Thought Pattern

I am among the millions of users of Evernote, and I have been struck by its many similarities to a software package from the early 1990s called Thought Pattern™. This was a note-taking package that made little impact on the market but which I found very useful at the time.

As with Evernote, a Thought Pattern user can enter notes with text and pictures, and assign keywords to each note. This makes it possible to search later by the terms in the card, or by themes that the cards have in common, even if the name of the theme appears nowhere in the text of the card itself. Unstructured data can be challenging to manage. With a large unstructured database used by many people, communal usage patterns can train the system about related content even in the absence of identical terms. However, for smaller datasets and user bases, explicit tagging of the sort used by Evernote and Thought Pattern is much better. Highly structured data can be handled in a traditional database management system, but a lot of information in the real world doesn’t conform to any simple rigid system of fields and records.

Thought Pattern also allowed the user to link content from other applications to cards, where it was represented by icons and would open if double-clicked. The program had one major feature that Evernote lacks — it was possible to attach an alarm to each card. Thought Pattern also had a better logo.

thought pattern logo

I rode a bicycle across most of the United States in 1993 wearing a Thought Pattern t-shirt.

Thought Pattern lacked of course the networked ubiquity that makes Evernote so useful. Nonetheless, it was a great program that I found useful. Credit to Stephen Zagerman of Bananafish Software for being ahead of his time.

in action

box back