Treasury Zero Coupon Bonds

A model for the price structure of zero coupon Treasury bonds is based on the survival function of a probability distribution arising from the sum of an exponential distribution random variable and a gamma distribution random variable. The three-parameter function is used to fit prices of zero coupon treasury bonds with respect to their time to maturity with excellent results.

The data are obtained from the Wall Street Journal web page below which lists bid and ask quotes for zero coupon Treasury bonds as of 3 PM ET each day for trades of one million dollars or more.  The program imports the data from the page and fits it to the model, which is presented in detail.  All the code to reproduce what follows is contained in the notebook.

http://online.wsj.com/mdc/public/page/2_ 3020-tstrips.html

Here is a plot of the average yield to maturity curve versus maturity date provided in the data.

(*Extract Date*)
str=Import["http://online.wsj.com/mdc/public/page/2_3020-tstrips.html","Plaintext"];
pos=StringPosition[str,DatePattern[{"DayName",", ","MonthName"," ","Day",", ","Year"}]];
dataDate=DateList[StringTake[str,pos][[1]]]+{0,0,0,15,0,0};
(*Get Data*)
quotes0=Import["http://online.wsj.com/mdc/public/page/2_3020-tstrips.html","Data"];
quotes=SplitBy[Rest[Drop[quotes0,1][[1]][[1]]],Head[#]==String&];
DateListPlot[quotes[[6]][[All,{1,5}]],,FrameLabel->{"Year", "Percent"},PlotLabel->quotes[[5]][[1]]<>": Ask Yield\n"<>DateString[dataDate,"DateTime"]]

Below is the plot of the ask price versus the maturity date on a logarithmic scale.  Note that it is nearly perfectly linear on this plot as time goes on.  This suggests a pure exponential model could be used to fit the long term data.

g1=DateListLogPlot[Tooltip@quotes[[6]][[All,{1,3}]],PlotLabel->quotes[[5]][[1]]<>" Ask Price\n"<>DateString[dataDate,"DateTime"],FrameLabel->{"Year", "Price Percent"}]

The function can be adjusted from price based on maturity date to price versus time to maturity.  In this way the curve can be compared to previous and future curves, as starting at time zero.  Plots of both the bid and ask prices are shown below on a log scale plot.  Note that the price structures are identical and the linearity suggests a exponential decay model for the longer maturities.

askPrice={DateDifference[dataDate,#1,"Year"][[1]],#2}&@@@quotes[[6]][[All,{1,3}]];
bidPrice={DateDifference[dataDate,#1,"Year"][[1]],#2}&@@@quotes[[6]][[All,{1,2}]];
ListLogPlot[{bidPrice,askPrice},Frame->True,FrameLabel->{"Time in Years to Maturity", "Price Percent"},PlotLabel->"Bid Price - Blue\nAsk Price - Red"]

The plots below show ΔLog[price]/Δt, since all the prices should be declining as time to maturity increases, the values (which are essentially annualized log returns) theoretically should be negative.  There is a lot of variation in the maturities below 10 years, but the general trend is declining.  After 10 to 12 years, the rate of change becomes nearly constant consistent with an exponential decay model.

diffAsk=Differences[{#1,Log[#2]}&@@@(Last/@Split[askPrice,#1[[1]]==#2[[1]]&])];
ga=ListPlot[Transpose[{Accumulate[diffAsk[[All,1]]],diffAsk[[All,2]]/diffAsk[[All,1]]}],Frame->True,FrameLabel->{"Time in Years to Maturity", "Log Decay Rate "},PlotRange->All,PlotLabel-> "ΔLog[askPrice]/Δt"];
diffBid=Differences[{#1,Log[#2]}&@@@(Last/@Split[bidPrice,#1[[1]]==#2[[1]]&])];
gb=ListPlot[Transpose[{Accumulate[diffBid[[All,1]]],diffBid[[All,2]]/diffBid[[All,1]]}],Frame->True,FrameLabel->{"Time in Years to Maturity", "Log Decay Rate "},PlotRange->All,PlotLabel-> "ΔLog[bidPrice]/Δt"];
GraphicsRow[{gb,ga},ImageSize->600]

If the price percent is converted to decimal price, the shape of the curve has the properties of a survival function.  A rational assumption is that the price function, p(t) is always decreasing, i.e. the longer an investor has to wait for maturity of a bond, the greater the return he expects.  This further requires the first derivative, p’(t) always be negative.  The linearity of the distal part of the curve on the log plot is consistent with an exponential decay function:

p(t)=exp(-r t)

where r is the logarithmic rate of return and t is time.  This also happens to be the survival function of an exponential distribution with parameter, r.  The initial part of the price curve, however, is not at all like an exponential distribution survival function.  But it is a little like the survival function of a gamma distribution.  A better fit comes from the convolution of the gamma distribution and an exponential distribution; this is the distribution of the sum of an exponential distribution random variable and a gamma distribution random variable.

To visualize the convolution process the graph below shows the density of a gamma distribution, in red, convolved with the distribution function of an exponential distribution, the rising blue curve.  The result of the convolution is the rising yellow curve.  The survival function of the original exponential distribution is the declining blue curve, and the declining yellow curve is the survival function of the convolved distribution, which is our priceModel equation shown below.  In fitting the prices we multiply the model by 100 to be consistent with bond prices in percent.

Plot[{CDF[ExponentialDistribution[0.04786],t],PDF[GammaDistribution[4.583,1/1.223],t],1+(1/(t Gamma[k]))(((-r0+r1))^(-1-k)) ((E^(-r1 t)) (r1^k) ((((-r0+r1) t))^k)+(E^(-r0 t)) (r0-r1) t ((r1^k) (Gamma[k]-(-1+k) Gamma[-1+k,(-r0+r1) t])+(E^(r0 t)) (((-r0+r1))^k) Gamma[k,r1 t]))/.{k->4.583,r0->0.04786,r1->1.223},-(1/(t Gamma[k]))(((-r0+r1))^(-1-k)) ((E^(-r1 t)) (r1^k) ((((-r0+r1) t))^k)+(E^(-r0 t)) (r0-r1) t ((r1^k) (Gamma[k]-(-1+k) Gamma[-1+k,(-r0+r1) t])+(E^(r0 t)) (((-r0+r1))^k) Gamma[k,r1 t]))/.{k->4.583,r0->0.04786,r1->1.223},1-CDF[ExponentialDistribution[0.04786],t]},{t,0,30},PlotStyle->{{Thick,Darker[Blue]},{Thick,Darker[Red]},{Thick,Darker[Yellow]},{Thick,Darker[Yellow]},{Thick,Darker[Blue]}},Frame->True]

priceModel =({{{, ({{((r0 (e^(-r1 t))-r1 (e^(-r0 t)))/(r0-r1)), t>0∧r0<r1∧k==1}, {(e^(-r0 t)), t>0∧k==0}, {1-(((r1^k) (e^(-r0 t)) (((r1-r0))^(-k)) ((Gamma2[k, (r1-r0) t])-(Gamma[k]))-(Gamma2[k, r1 t])+(Gamma[k]))/(Gamma[k])), t>0∧r0<r1}, {1, True}})}})

Where Γ is the gamma function.

The plot below shows the model fit in red to the data points on a log scale plot.

ZBondPrice[t_,{r0_,r1_,k_}]:=Piecewise[{
{(((E^(-r1 t)) r0-(E^(-r0 t)) r1)/(r0-r1)),t>0&&r0<r1&&k==1},
{(E^(-r0 t)),t>0&&k==0},
{1-((Gamma[k]-Gamma[k,r1 t]+(E^(-r0 t)) (r1^k) (((-r0+r1))^(-k)) (-Gamma[k]+Gamma[k,(-r0+r1) t]))/(Gamma[k])),t>0&&r0<r1}},
1];
zbondParameters={{r0,0.045},{r1,3.0},{k,1.2}};

askFit=NonlinearModelFit[askPrice,{100ZBondPrice[t,{r0,r1,k}],r0<r1&&r0>0&&k≥1},zbondParameters,t,Method->Automatic];
bidFit=NonlinearModelFit[bidPrice,{100ZBondPrice[t,{r0,r1,k}],r0<r1&&r0>0&&k≥ 1},zbondParameters,t,Method->Automatic];

Show[LogPlot[askFit[t],{t,0,30},PlotStyle->{Thickness[0.01],Red}],ListLogPlot[askPrice,PlotStyle->Blue],Frame->True,FrameLabel-> {"Time to Maturity","Price Percent"}, PlotLabel->"Ask Price Fit\nLog Scale"]

The coefficient of determination is rather good, meaning that all the prices line up with the model well at an instant of time.  But the model parameters change significantly with time, even through the course of a day.

CellPrint[TextCell["Coefficient of determination, R Squared: "<>ToString[askFit["RSquared"]]<>".",TextAlignment->Center,FontSize->14]]

The fit residuals are shown below.

ListPlot[Transpose[{askPrice[[All,1]],askFit["FitResiduals"]}],PlotRange->All,Frame->True,FrameLabel->{"Time to Maturity","Δ Price Percent"},PlotLabel->"Fit Residuals"]

The formula and parameter set for the fit to the ask price are shown below.

CellPrint[ExpressionCell[Normal[askFit],"DisplayFormula",TextAlignment->Center]];
CellPrint[ExpressionCell[askFit["BestFitParameters"],"DisplayFormula",TextAlignment->Center]];

100 (({{{, ({{1-0.12171238682940864` (8.21609062191504` +1.1663654961270666` (e^(-0.047464729320643884` t)) (-8.21609062191504`+Gamma[4.243683231432393`,1.28528106372434` t])-Gamma[4.243683231432393`,1.3327457930449838` t]), t>0}, {1, True}})}}))

{r0->0.047464729320643884`,r1->1.3327457930449838`,k->4.243683231432393`}

The parameter statistics are below.  The dominant rate, r0, from the exponential distribution component, determines the long maturity schedule.  The interpretation of the other two parameters is more difficult; they are the parameters from the gamma distribution component.  But it should be remembered that a gamma distribution parameterized as in this notebook represents the distribution of the sum of k exponential distribution random variables with parameter, r1.  k is not an integer here, but the distribution should be able to represent fractional random variables.

Quiet@CellPrint[ExpressionCell[askFit["ParameterTable"],TextAlignment->Center]]

The 95% confidence intervals of the parameters are shown below.

Quiet@CellPrint[ExpressionCell[askFit["ParameterConfidenceIntervalTable"],TextAlignment->Center]]

We can create a log price function, take the first derivative negative of that, to create an instantaneous yield curve.  This function asymptotically approaches r0.

lnf=Function[{t},-Log[askFit[t]]];
Plot[lnf'[t],{t,0,30},PlotRange->All,Frame->True,FrameLabel-> {"Time in Years", "Logarithmic  Rate "},PlotLabel->"First Derivative of -Log[askPrice]"]

Another interesting feature of the model is that if you divide the price by 100, it is a survival distribution function; if you take the derivative of 1 - SurvivalFunction(.), you get a picture of the underlying probability density function, which integrates to 1 as t goes from 0 -> ∞.  This appears to be a density of times to maturity, but it is not clear how to interpret this--there isn’t any Treasury debt over 30 years duration.  But it would be interesting to compare to the maturity of outstanding available debt, and perhaps compare that to a truncated distribution.  It probably should be influenced by the maturities of debt issued by the Treasury and by the Federal Reserve Bank activity of taking securities out of the market place; the Fed now owns more than 17% of the public debt.

Plot[-askFit'[t]/100,{t,0,100},PlotLabel->"Density Function",Frame->True]

The program can also easily be used with data copied from a brokerage account web interface, even though the web security won’t allow you to gather the data directly.  Below is a fit obtained from data from set of Schwab Brokerage web pages to obtain a price curve for Treasuries offered on their site on 4 December 2013.  Four web pages of data were pasted into a Mathematica string then imported into a table for analysis, using the function, ImportString[].  The full code for the example is included in the down-loadable notebook.

schwdata="Buy   US Treasury STRIP 0% 11/15/2014  912833KD1  11/15/2014  50  99.96800  1  4000  0.034  $49,984.00  
 Buy   US Treasury STRIP 0% 11/15/2014  912820KZ9  11/15/2014  50  99.97700  1  4000  0.024  $49,988.50  
 Buy   US Treasury STRIP 0% 11/30/2014  912834DX3  11/30/2014  50  99.99600  1  66  0.004  $49,998.00  
 Buy   US Treasury STRIP 0% 02/15/2015  912833DH0  02/15/2015  50  99.89700  1  250  0.086  $49,948.50  
 Buy   US Treasury STRIP 0% 02/15/2015  912803AA1  02/15/2015  50  99.90500  1  1000  0.080  $49,952.50  
 Buy   US Treasury STRIP 0% 02/15/2015  912820LJ4  02/15/2015  50  99.92100  1  3000  0.066  $49,960.50  
 Buy   US Treasury STRIP 0% 05/15/2015  912833KE9  05/15/2015  50  99.77300  10  3000  0.157  $49,886.50  
 Buy   US Treasury STRIP 0% 05/15/2015  912820LS4  05/15/2015  50  99.79600  25  3000  0.141  $49,898.00  
   US Treasury STRIP 0% 05/31/2015  912834DY1  05/31/2015  50  --  1  66  --  --  
 Buy   US Treasury STRIP 0% 08/15/2015  912833JT8  08/15/2015  50  99.70300  1  4000  0.175  $49,851.50  
 Buy   US Treasury STRIP 0% 08/15/2015  912803AC7  08/15/2015  50  99.72800  1  4000  0.161  $49,864.00  
 Buy   US Treasury STRIP 0% 11/15/2015  912803AE3  11/15/2015  50  99.57200  10  3000  0.221  $49,786.00  
 Buy   US Treasury STRIP 0% 11/15/2015  912833KF6  11/15/2015  50  99.58900  10  3000  0.212  $49,794.50  
 Buy   US Treasury STRIP 0% 11/30/2015  912834DZ8  11/30/2015  50  99.62700  1  66  0.188  $49,813.50  
 Buy   US Treasury STRIP 0% 02/15/2016  912833KG4  02/15/2016  50  99.37600  10  3000  0.285  $49,688.00  
 Buy   US Treasury STRIP 0% 02/15/2016  912803AF0  02/15/2016  50  99.39600  25  3000  0.276  $49,698.00  
 Buy   US Treasury STRIP 0% 05/15/2016  912833KH2  05/15/2016  50  99.15200  1  4000  0.349  $49,576.00  
 Buy   US Treasury STRIP 0% 05/15/2016  912803AH6  05/15/2016  50  99.16400  25  3000  0.344  $49,582.00  
 Buy   US Treasury STRIP 0% 06/30/2016  912834EG9  06/30/2016  50  99.10500  1  82  0.350  $49,552.50  
 Buy   US Treasury STRIP 0% 08/15/2016  912833KJ8  08/15/2016  50  98.82100  10  3000  0.440  $49,410.50  
 Buy   US Treasury STRIP 0% 08/15/2016  912820NM5  08/15/2016  50  98.87200  25  3000  0.421  $49,436.00  
 Buy   US Treasury STRIP 0% 11/15/2016  912803AK9  11/15/2016  50  98.41800  25  3000  0.542  $49,209.00  
 Buy   US Treasury STRIP 0% 11/15/2016  912833KK5  11/15/2016  50  98.43800  1  4000  0.535  $49,219.00  
 Buy   US Treasury STRIP 0% 02/15/2017  912833KL3  02/15/2017  50  97.80900  10  3000  0.694  $48,904.50  
 Buy   US Treasury STRIP 0% 02/15/2017  912820PE1  02/15/2017  50  97.90700  25  3000  0.663  $48,953.50  
 Buy   US Treasury STRIP 0% 05/15/2017  912833KM1  05/15/2017  50  97.24100  10  3000  0.814  $48,620.50  
 Buy   US Treasury STRIP 0% 05/15/2017  912803AL7  05/15/2017  50  97.35400  1  4000  0.780  $48,677.00  
 Buy   US Treasury STRIP 0% 05/15/2017  912820PP6  05/15/2017  50  97.38700  1  3000  0.770  $48,693.50  
 Buy   US Treasury STRIP 0% 08/15/2017  912833KN9  08/15/2017  50  96.67600  1  4000  0.917  $48,338.00  
 Buy   US Treasury STRIP 0% 08/15/2017  912803AM5  08/15/2017  50  96.78200  1  4000  0.887  $48,391.00  
 Buy   US Treasury STRIP 0% 11/15/2017  912833KP4  11/15/2017  50  96.04900  10  3000  1.025  $48,024.50  
 Buy   US Treasury STRIP 0% 11/15/2017  912820QE0  11/15/2017  50  96.14000  25  2000  1.000  $48,070.00  
 Buy   US Treasury STRIP 0% 02/15/2018  912833KQ2  02/15/2018  50  95.38300  1  4000  1.130  $47,691.50  
 Buy   US Treasury STRIP 0% 02/15/2018  912820QN0  02/15/2018  50  95.48200  1  4000  1.105  $47,741.00  
 Buy   US Treasury STRIP 0% 05/15/2018  912833KR0  05/15/2018  50  94.62800  1  4000  1.246  $47,314.00  
 Buy   US Treasury STRIP 0% 05/15/2018  912803AN3  05/15/2018  50  94.76900  10  3000  1.212  $47,384.50  
 Buy   US Treasury STRIP 0% 08/15/2018  912833KS8  08/15/2018  50  93.86200  10  3000  1.354  $46,931.00  
 Buy   US Treasury STRIP 0% 08/15/2018  912820RE9  08/15/2018  50  94.14900  25  2000  1.288  $47,074.50  
 Buy   US Treasury STRIP 0% 11/15/2018  912833KT6  11/15/2018  50  93.09200  10  3000  1.453  $46,546.00  
 Buy   US Treasury STRIP 0% 11/15/2018  912803AP8  11/15/2018  50  93.23900  25  2000  1.421  $46,619.50  
 Buy   US Treasury STRIP 0% 11/15/2018  912820RM1  11/15/2018  50  93.29700  1  4000  1.408  $46,648.50  
 Buy   US Treasury STRIP 0% 02/15/2019  912833KU3  02/15/2019  50  92.38900  25  2000  1.529  $46,194.50  
 Buy   US Treasury STRIP 0% 02/15/2019  912803AQ6  02/15/2019  50  92.40700  10  3000  1.526  $46,203.50  
 Buy   US Treasury STRIP 0% 05/15/2019  912833KV1  05/15/2019  50  91.35500  10  3000  1.668  $45,677.50  
 Buy   US Treasury STRIP 0% 08/15/2019  912833KW9  08/15/2019  50  90.45400  10  3000  1.769  $45,227.00  
 Buy   US Treasury STRIP 0% 08/15/2019  912803AR4  08/15/2019  50  90.63700  10  3000  1.733  $45,318.50  
 Buy   US Treasury STRIP 0% 11/15/2019  912833KX7  11/15/2019  50  89.50800  10  3000  1.873  $44,754.00  
 Buy   US Treasury STRIP 0% 11/15/2019  912820US4  11/15/2019  50  89.91600  25  1000  1.796  $44,958.00
Buy   US Treasury STRIP 0% 11/15/2019  912820US4  11/15/2019  50  89.92600  1  1000  1.794  $44,963.00  
 Buy   US Treasury STRIP 0% 02/15/2020  912833KY5  02/15/2020  50  88.56700  10  3000  1.969  $44,283.50  
 Buy   US Treasury STRIP 0% 02/15/2020  912803AS2  02/15/2020  50  88.77200  1  4000  1.932  $44,386.00  
 Buy   US Treasury STRIP 0% 05/15/2020  912833KZ2  05/15/2020  50  87.75500  1  4000  2.037  $43,877.50  
 Buy   US Treasury STRIP 0% 05/15/2020  912803AT0  05/15/2020  50  87.97900  1  4000  1.997  $43,989.50  
 Buy   US Treasury STRIP 0% 08/15/2020  912833LA6  08/15/2020  50  86.73300  1  2000  2.137  $43,366.50  
 Buy   US Treasury STRIP 0% 08/15/2020  912803AU7  08/15/2020  50  86.88500  25  2000  2.111  $43,442.50  
 Buy   US Treasury STRIP 0% 11/15/2020  912833LB4  11/15/2020  50  85.82600  25  2000  2.213  $42,913.00  
 Buy   US Treasury STRIP 0% 02/15/2021  912833LC2  02/15/2021  50  84.60800  25  2000  2.336  $42,304.00  
 Buy   US Treasury STRIP 0% 02/15/2021  912803AV5  02/15/2021  50  84.81900  25  2000  2.301  $42,409.50  
 Buy   US Treasury STRIP 0% 05/15/2021  912833LD0  05/15/2021  50  83.63300  10  10000  2.415  $41,816.50  
 Buy   US Treasury STRIP 0% 05/15/2021  912803AW3  05/15/2021  50  83.83900  25  2000  2.382  $41,919.50  
 Buy   US Treasury STRIP 0% 08/15/2021  912833LE8  08/15/2021  50  82.60300  25  2000  2.499  $41,301.50  
 Buy   US Treasury STRIP 0% 08/15/2021  912803AX1  08/15/2021  50  82.84100  25  2000  2.461  $41,420.50  
 Buy   US Treasury STRIP 0% 11/15/2021  912833LF5  11/15/2021  50  81.73800  10  10000  2.554  $40,869.00  
 Buy   US Treasury STRIP 0% 11/15/2021  912803AY9  11/15/2021  50  81.93200  10  10000  2.524  $40,966.00  
 Buy   US Treasury STRIP 0% 02/15/2022  912833LG3  02/15/2022  50  80.71900  25  2000  2.631  $40,359.50  
 Buy   US Treasury STRIP 0% 02/15/2022  912820ZW0  02/15/2022  50  81.27500  1  1000  2.546  $40,637.50  
 Buy   US Treasury STRIP 0% 05/15/2022  912833LH1  05/15/2022  50  79.78000  25  2000  2.693  $39,890.00  
 Buy   US Treasury STRIP 0% 05/15/2022  912820E29  05/15/2022  50  80.32300  1  1000  2.612  $40,161.50  
 Buy   US Treasury STRIP 0% 08/15/2022  912833LJ7  08/15/2022  50  78.80400  25  2000  2.758  $39,402.00  
 Buy   US Treasury STRIP 0% 08/15/2022  912803AZ6  08/15/2022  50  79.26500  25  2000  2.690  $39,632.50  
 Buy   US Treasury STRIP 0% 11/15/2022  912833LK4  11/15/2022  50  77.78500  10  5000  2.828  $38,892.50  
 Buy   US Treasury STRIP 0% 11/15/2022  912803BA0  11/15/2022  50  78.32500  1  2000  2.750  $39,162.50  
 Buy   US Treasury STRIP 0% 02/15/2023  912833LL2  02/15/2023  50  76.83300  10  10000  2.887  $38,416.50  
 Buy   US Treasury STRIP 0% 02/15/2023  912803BB8  02/15/2023  50  77.27200  25  2000  2.824  $38,636.00  
 Buy   US Treasury STRIP 0% 05/15/2023  912833LN8  05/15/2023  50  75.97200  25  2000  2.931  $37,986.00  
 Buy   US Treasury STRIP 0% 08/15/2023  912833LM0  08/15/2023  50  75.09400  10  10000  2.976  $37,547.00  
 Buy   US Treasury STRIP 0% 08/15/2023  912803BC6  08/15/2023  50  75.64800  25  2000  2.899  $37,824.00  
 Buy   US Treasury STRIP 0% 11/15/2023  912833LP3  11/15/2023  50  74.19300  25  2000  3.024  $37,096.50  
 Buy   US Treasury STRIP 0% 02/15/2024  912833LQ1  02/15/2024  50  73.22200  25  2000  3.080  $36,611.00  
 Buy   US Treasury STRIP 0% 05/15/2024  912833LR9  05/15/2024  50  72.34500  25  2000  3.124  $36,172.50  
 Buy   US Treasury STRIP 0% 08/15/2024  912833LS7  08/15/2024  50  71.36900  25  2000  3.179  $35,684.50  
 Buy   US Treasury STRIP 0% 11/15/2024  912833LT5  11/15/2024  50  70.40600  25  2000  3.232  $35,203.00  
 Buy   US Treasury STRIP 0% 11/15/2024  912803BD4  11/15/2024  50  70.96100  25  2000  3.159  $35,480.50  
 Buy   US Treasury STRIP 0% 02/15/2025  912833LU2  02/15/2025  50  69.36600  25  2000  3.294  $34,683.00  
 Buy   US Treasury STRIP 0% 02/15/2025  912803BE2  02/15/2025  50  69.94100  25  2000  3.219  $34,970.50  
 Buy   US Treasury STRIP 0% 05/15/2025  912833LV0  05/15/2025  50  68.54400  10  10000  3.328  $34,272.00  
 Buy   US Treasury STRIP 0% 08/15/2025  912833LW8  08/15/2025  50  67.67000  1  2000  3.367  $33,835.00  
 Buy   US Treasury STRIP 0% 08/15/2025  912803BF9  08/15/2025  50  68.20000  25  2000  3.299  $34,100.00  
 Buy   US Treasury STRIP 0% 11/15/2025  912833LX6  11/15/2025  50  66.77000  25  2000  3.410  $33,385.00  
 Buy   US Treasury STRIP 0% 02/15/2026  912833LY4  02/15/2026  50  65.81800  25  2000  3.459  $32,909.00  
 Buy   US Treasury STRIP 0% 02/15/2026  912803BG7  02/15/2026  50  66.46700  1  4000  3.377  $33,233.50  
 Buy   US Treasury STRIP 0% 05/15/2026  912833LZ1  05/15/2026  50  65.05000  25  2000  3.485  $32,525.00  
 Buy   US Treasury STRIP 0% 08/15/2026  912833PA2  08/15/2026  50  64.19900  25  2000  3.521  $32,099.50  
 Buy   US Treasury STRIP 0% 08/15/2026  912803BH5  08/15/2026  50  64.85000  25  2000  3.441  $32,425.00  
 Buy   US Treasury STRIP 0% 11/15/2026  912833PB0  11/15/2026  50  63.39600  25  2000  3.552  $31,698.00  
 Buy   US Treasury STRIP 0% 11/15/2026  912803BJ1  11/15/2026  50  64.02300  25  2000  3.475  $32,011.50  
 Buy   US Treasury STRIP 0% 02/15/2027  912833PC8  02/15/2027  50  62.60600  1  2000  3.581  $31,303.00  
 Buy   US Treasury STRIP 0% 02/15/2027  912803BK8  02/15/2027  50  63.20800  25  2000  3.507  $31,604.00
Buy   US Treasury STRIP 0% 05/15/2027  912833PD6  05/15/2027  50  61.83400  25  2000  3.608  $30,917.00  
 Buy   US Treasury STRIP 0% 08/15/2027  912833PE4  08/15/2027  50  61.07900  25  2000  3.632  $30,539.50  
 Buy   US Treasury STRIP 0% 08/15/2027  912803BL6  08/15/2027  50  61.61800  25  2000  3.567  $30,809.00  
 Buy   US Treasury STRIP 0% 11/15/2027  912833QB9  11/15/2027  50  60.23200  25  2000  3.669  $30,116.00  
 Buy   US Treasury STRIP 0% 11/15/2027  912803BM4  11/15/2027  50  60.81900  1  4000  3.598  $30,409.50  
 Buy   US Treasury STRIP 0% 02/15/2028  912833RY8  02/15/2028  50  59.56700  25  2000  3.683  $29,783.50  
 Buy   US Treasury STRIP 0% 05/15/2028  912833WQ9  05/15/2028  50  58.85200  25  2000  3.704  $29,426.00  
 Buy   US Treasury STRIP 0% 08/15/2028  912833RZ5  08/15/2028  50  58.10200  1  2000  3.729  $29,051.00  
 Buy   US Treasury STRIP 0% 08/15/2028  912803BP7  08/15/2028  50  58.70000  1  4000  3.658  $29,350.00  
 Buy   US Treasury STRIP 0% 11/15/2028  912833WR7  11/15/2028  50  57.36700  1  4000  3.753  $28,683.50  
 Buy   US Treasury STRIP 0% 11/15/2028  912803BV4  11/15/2028  50  58.00900  25  2000  3.677  $29,004.50  
 Buy   US Treasury STRIP 0% 02/15/2029  912833XN5  02/15/2029  50  56.69900  25  2000  3.769  $28,349.50  
 Buy   US Treasury STRIP 0% 02/15/2029  912803BW2  02/15/2029  50  57.23300  25  2000  3.706  $28,616.50  
 Buy   US Treasury STRIP 0% 05/15/2029  912833XS4  05/15/2029  50  55.99500  25  2000  3.790  $27,997.50  
 Buy   US Treasury STRIP 0% 08/15/2029  912833XP0  08/15/2029  50  55.29000  25  2000  3.811  $27,645.00  
 Buy   US Treasury STRIP 0% 08/15/2029  912803CG6  08/15/2029  50  55.78600  1  4000  3.753  $27,893.00  
 Buy   US Treasury STRIP 0% 11/15/2029  912833XT2  11/15/2029  50  54.58400  1  4000  3.833  $27,292.00  
 Buy   US Treasury STRIP 0% 02/15/2030  912833XX3  02/15/2030  50  53.93800  1  4000  3.848  $26,969.00  
 Buy   US Treasury STRIP 0% 05/15/2030  912833XU9  05/15/2030  50  53.29900  1  4000  3.863  $26,649.50  
 Buy   US Treasury STRIP 0% 05/15/2030  912803CH4  05/15/2030  50  54.03300  1  4000  3.779  $27,016.50  
 Buy   US Treasury STRIP 0% 08/15/2030  912833XY1  08/15/2030  50  52.75400  1  2000  3.867  $26,377.00  
 Buy   US Treasury STRIP 0% 11/15/2030  9128337N4  11/15/2030  50  52.10100  1  2000  3.885  $26,050.50  
 Buy   US Treasury STRIP 0% 02/15/2031  912833XZ8  02/15/2031  50  51.57000  25  2000  3.888  $25,785.00  
 Buy   US Treasury STRIP 0% 02/15/2031  912803CK7  02/15/2031  50  52.26900  25  2000  3.809  $26,134.50  
 Buy   US Treasury STRIP 0% 05/15/2031  9128337P9  05/15/2031  50  51.00700  25  2000  3.897  $25,503.50  
 Buy   US Treasury STRIP 0% 08/15/2031  9128334S6  08/15/2031  50  50.42800  25  2000  3.907  $25,214.00  
 Buy   US Treasury STRIP 0% 11/15/2031  9128337Q7  11/15/2031  50  49.82100  25  2000  3.921  $24,910.50  
 Buy   US Treasury STRIP 0% 02/15/2032  9128334T4  02/15/2032  50  49.22400  1  4000  3.934  $24,612.00  
 Buy   US Treasury STRIP 0% 05/15/2032  9128337R5  05/15/2032  50  48.69500  1  2000  3.940  $24,347.50  
 Buy   US Treasury STRIP 0% 08/15/2032  9128334U1  08/15/2032  50  48.18500  1  4000  3.944  $24,092.50  
 Buy   US Treasury STRIP 0% 11/15/2032  9128337S3  11/15/2032  50  47.64800  25  2000  3.952  $23,824.00  
 Buy   US Treasury STRIP 0% 02/15/2033  9128334V9  02/15/2033  50  47.06700  25  2000  3.965  $23,533.50  
 Buy   US Treasury STRIP 0% 05/15/2033  9128337T1  05/15/2033  50  46.58600  1  2000  3.967  $23,293.00  
 Buy   US Treasury STRIP 0% 08/15/2033  9128334W7  08/15/2033  50  46.07100  25  2000  3.974  $23,035.50  
 Buy   US Treasury STRIP 0% 11/15/2033  9128337U8  11/15/2033  50  45.49700  25  2000  3.988  $22,748.50  
 Buy   US Treasury STRIP 0% 02/15/2034  9128334X5  02/15/2034  50  44.97700  25  2000  3.996  $22,488.50  
 Buy   US Treasury STRIP 0% 05/15/2034  9128337V6  05/15/2034  50  44.53600  25  2000  3.996  $22,268.00  
 Buy   US Treasury STRIP 0% 08/15/2034  9128334Y3  08/15/2034  50  44.03300  25  2000  4.003  $22,016.50  
 Buy   US Treasury STRIP 0% 11/15/2034  9128337W4  11/15/2034  50  43.55600  1  2000  4.008  $21,778.00  
 Buy   US Treasury STRIP 0% 02/15/2035  9128334Z0  02/15/2035  50  43.04400  25  2000  4.017  $21,522.00  
 Buy   US Treasury STRIP 0% 05/15/2035  912833X88  05/15/2035  50  42.56600  1  2000  4.023  $21,283.00  
 Buy   US Treasury STRIP 0% 08/15/2035  9128335A4  08/15/2035  50  42.13300  25  2000  4.024  $21,066.50  
 Buy   US Treasury STRIP 0% 11/15/2035  912833X96  11/15/2035  50  41.68100  25  2000  4.028  $20,840.50  
 Buy   US Treasury STRIP 0% 02/15/2036  9128335B2  02/15/2036  50  41.18100  1  2000  4.037  $20,590.50  
 Buy   US Treasury STRIP 0% 02/15/2036  912803CX9  02/15/2036  50  41.88900  1  4000  3.959  $20,944.50  
 Buy   US Treasury STRIP 0% 05/15/2036  912833Y20  05/15/2036  50  40.76000  25  2000  4.039  $20,380.00  
 Buy   US Treasury STRIP 0% 08/15/2036  9128337E4  08/15/2036  50  40.27200  25  2000  4.048  $20,136.00  
 Buy   US Treasury STRIP 0% 11/15/2036  912833Y38  11/15/2036  50  39.79200  25  2000  4.057  $19,896.00  
 Buy   US Treasury STRIP 0% 02/15/2037  9128337F1  02/15/2037  50  39.33000  1  2000  4.064  $19,665.00  
 Buy   US Treasury STRIP 0% 02/15/2037  912803CZ4  02/15/2037  50  39.94100  25  2000  3.996  $19,970.50
Buy   US Treasury STRIP 0% 05/15/2037  912833Y46  05/15/2037  50  38.87600  1  2000  4.071  $19,438.00  
 Buy   US Treasury STRIP 0% 05/15/2037  912803DA8  05/15/2037  50  39.44600  1  2000  4.007  $19,723.00  
 Buy   US Treasury STRIP 0% 08/15/2037  912833Z52  08/15/2037  50  38.44400  1  2000  4.075  $19,222.00  
 Buy   US Treasury STRIP 0% 11/15/2037  912834AD0  11/15/2037  50  38.04700  25  2000  4.077  $19,023.50  
 Buy   US Treasury STRIP 0% 02/15/2038  912833Z60  02/15/2038  50  37.59600  1  2000  4.084  $18,798.00  
 Buy   US Treasury STRIP 0% 02/15/2038  912803DC4  02/15/2038  50  38.15200  1  2000  4.022  $19,076.00  
 Buy   US Treasury STRIP 0% 05/15/2038  912834AE8  05/15/2038  50  37.23300  25  2000  4.083  $18,616.50  
 Buy   US Treasury STRIP 0% 05/15/2038  912803DD2  05/15/2038  50  37.70300  1  2000  4.030  $18,851.50  
 Buy   US Treasury STRIP 0% 08/15/2038  912834AT5  08/15/2038  50  36.75100  25  2000  4.095  $18,375.50  
 Buy   US Treasury STRIP 0% 11/15/2038  912834DU9  11/15/2038  50  36.32800  25  2000  4.101  $18,164.00  
 Buy   US Treasury STRIP 0% 02/15/2039  912834AU2  02/15/2039  50  35.89800  25  2000  4.108  $17,949.00  
 Buy   US Treasury STRIP 0% 02/15/2039  912803DF7  02/15/2039  50  36.39700  1  2000  4.052  $18,198.50  
 Buy   US Treasury STRIP 0% 05/15/2039  912834DV7  05/15/2039  50  35.50100  25  1000  4.112  $17,750.50  
 Buy   US Treasury STRIP 0% 05/15/2039  912803DG5  05/15/2039  50  36.06200  1  2000  4.049  $18,031.00  
 Buy   US Treasury STRIP 0% 08/15/2039  912834EP9  08/15/2039  50  35.06100  25  1000  4.121  $17,530.50  
 Buy   US Treasury STRIP 0% 08/15/2039  912803DH3  08/15/2039  50  35.63800  1  2000  4.056  $17,819.00  
 Buy   US Treasury STRIP 0% 11/15/2039  912834EV6  11/15/2039  50  34.68900  25  1000  4.123  $17,344.50  
 Buy   US Treasury STRIP 0% 11/15/2039  912803DJ9  11/15/2039  50  35.23000  1  2000  4.062  $17,615.00  
 Buy   US Treasury STRIP 0% 02/15/2040  912834FB9  02/15/2040  50  34.32700  25  1000  4.124  $17,163.50  
 Buy   US Treasury STRIP 0% 02/15/2040  912803DK6  02/15/2040  50  34.88100  1  2000  4.061  $17,440.50  
 Buy   US Treasury STRIP 0% 05/15/2040  912834HV3  05/15/2040  50  33.97100  1  250  4.125  $16,985.50  
 Buy   US Treasury STRIP 0% 05/15/2040  912803DM2  05/15/2040  50  34.41300  1  2000  4.075  $17,206.50  
 Buy   US Treasury STRIP 0% 08/15/2040  912834JB5  08/15/2040  50  33.57300  25  2000  4.131  $16,786.50  
 Buy   US Treasury STRIP 0% 08/15/2040  912803DN0  08/15/2040  50  34.01300  1  2000  4.081  $17,006.50  
 Buy   US Treasury STRIP 0% 11/15/2040  912834JH2  11/15/2040  50  33.12800  25  2000  4.143  $16,564.00  
 Buy   US Treasury STRIP 0% 11/15/2040  912803DP5  11/15/2040  50  33.61100  1  2000  4.088  $16,805.50  
 Buy   US Treasury STRIP 0% 02/15/2041  912834JP4  02/15/2041  50  32.79800  1  250  4.141  $16,399.00  
 Buy   US Treasury STRIP 0% 02/15/2041  912803DQ3  02/15/2041  50  33.31600  1  2000  4.083  $16,658.00  
 Buy   US Treasury STRIP 0% 05/15/2041  912834KH0  05/15/2041  50  32.49900  1  250  4.138  $16,249.50  
 Buy   US Treasury STRIP 0% 05/15/2041  912803DS9  05/15/2041  50  32.85400  1  2000  4.097  $16,427.00  
 Buy   US Treasury STRIP 0% 08/15/2041  912834KP2  08/15/2041  50  32.11500  1  3000  4.144  $16,057.50  
 Buy   US Treasury STRIP 0% 08/15/2041  912803DT7  08/15/2041  50  32.38100  1  2000  4.113  $16,190.50  
 Buy   US Treasury STRIP 0% 11/15/2041  912834KV9  11/15/2041  50  31.71900  25  500  4.152  $15,859.50  
 Buy   US Treasury STRIP 0% 11/15/2041  912803DU4  11/15/2041  50  31.97100  1  2000  4.123  $15,985.50  
 Buy   US Treasury STRIP 0% 02/15/2042  912834LB2  02/15/2042  50  31.32500  1  250  4.159  $15,662.50  
 Buy   US Treasury STRIP 0% 02/15/2042  912803DV2  02/15/2042  50  31.55000  1  3000  4.134  $15,775.00  
 Buy   US Treasury STRIP 0% 05/15/2042  912834LK2  05/15/2042  50  31.05700  1  3000  4.153  $15,528.50  
 Buy   US Treasury STRIP 0% 05/15/2042  912803DX8  05/15/2042  50  31.22200  1  500  4.134  $15,611.00  
 Buy   US Treasury STRIP 0% 08/15/2042  912834LR7  08/15/2042  50  30.61000  1  3000  4.168  $15,305.00  
 Buy   US Treasury STRIP 0% 08/15/2042  912803DY6  08/15/2042  50  30.78200  1  3000  4.148  $15,391.00  
 Buy   US Treasury STRIP 0% 11/15/2042  912803DZ3  11/15/2042  50  30.42600  1  3000  4.153  $15,213.00  
 Buy   US Treasury STRIP 0% 02/15/2043  912803EA7  02/15/2043  50  30.07100  1  3000  4.158  $15,035.50  
 Buy   US Treasury STRIP 0% 05/15/2043  912803EC3  05/15/2043  50  29.67900  1  3000  4.168  $14,839.50 
";
data=ImportString[schwdata,"Table"];
data1=Select[data,NumericQ[#[[9]]]&];
s0=DateListLogPlot[sdata=First/@Split[data1[[All,{8,10}]],#1[[1]]==#2[[1]]&]];
schwPrice={DateDifference[DateList[],#1,"Year"][[1]],#2}&@@@sdata;
zbondParameters={{r0,0.045},{r1,1.1},{k,1.2}};
schwFit=NonlinearModelFit[schwPrice,{100ZBondPrice[t,{r0,r1,k}],r0<r1&&r0>0&&k≥1},zbondParameters,t,Method->Automatic];
CellPrint[ExpressionCell[Normal[schwFit],"DisplayFormula",TextAlignment->Center]];
CellPrint[ExpressionCell[schwFit["BestFitParameters"],"DisplayFormula",TextAlignment->Center]];
Show[LogPlot[schwFit[t],{t,0,30},PlotStyle->{Thickness[0.01],Red}],ListLogPlot[schwPrice,PlotStyle->Blue],Frame->True,FrameLabel-> {"Time to Maturity","Price Percent"}, PlotLabel->"Ask Price Fit\nLog Scale"]
ListPlot[Transpose[{schwPrice[[All,1]],schwFit["FitResiduals"]}],PlotRange->All,Frame->True,FrameLabel->{"Time to Maturity","Δ Price Percent"},PlotLabel->"Fit Residuals"]

100 (({{{, ({{1-0.000839486333953224` (e^(-0.04793338401931043` t)) (-1416.6711234599316`+1191.2046206766718` (e^(0.04793338401931043` t))+16.724045082273484` Gamma[5.793574412521545`,1.5781950689303952` t]-14.062374427280124` (e^(0.04793338401931043` t)) Gamma[5.793574412521545`,1.6261284529497055` t]), t>0}, {1, True}})}}))

{r0->0.04793338401931043`,r1->1.6261284529497055`,k->5.793574412521545`}

Quiet@CellPrint[ExpressionCell[schwFit["ParameterTable"],TextAlignment->Center]]

It may be possible to use this model to study the shape of the pricing structure for all Treasury bonds.  Daily Treasury yield curves can be converted to zero coupon prices and fit to the model.  It will be interesting to watch how the parameter structure changes as the Federal Reserve withdraws its quantitative easing.

The price curves can also be turned around to look at the expected growth with time for a specific bond.  For instance, if you are holding a zero coupon bond, does it make sense to sell it before it matures and buy another one with longer maturity, in order to maximize return, which begins to decline as the bond approaches maturity?  When a yield is calculated for a zero coupon bond, it is based on an average yield to maturity, but if you are holding a bond you receive higher yield while the maturity is in the distant future and much lower yield as it approaches maturity.

tMax=DateDifference[DateList[],{2030,11,15},"Year"][[1]];
LogPlot[bidFit[tMax-t],{t,0,tMax},Frame->True,FrameLabel->{"Time in Years","Price"},PlotLabel->"Bid Price Fit Log Scale\nBond Matures "<>DateString[{2030,11,15},"DateShort"]]

If you paste the code below into a Mathematica notebook and execute it, you will open this notebook into Mathematica and all the code will be available by opening the closed cells.

NotebookPut@Import["http://pages.suddenlink.net/rhr/fin07/TreasuryZeroes.nb"];

There are interactive modules which require Wolfram CDF Player or Mathematica to be installed on the computer.  The Zero Coupon Model explores the three-parameter bond yield function and its first two derivatives in detail; the Yield Curve module reconstructs the traditional yield curve from the model.

Zero Coupon Model

Yield Curve

Track FOMC Policy

Financial Data Analysis Home

CellPrint[TextCell["\n\n© Copyright " <> ToString[DateList[][[1]]] <> " Robert H. Rimmer, Jr.    " <> DateString[DateList[], "DateShort"], "Text"]]

© Copyright 2014 Robert H. Rimmer, Jr.    Thu 2 Jan 2014