In this blog I’ll show how to use SAMOA to calculate the returns of buy-and-hold strategies for the 10Y Treasury Note Future (TY) that trades in the CBOT. These results can be useful for benchmark purposes.
Manual Calculation (Using adjusted prices)
- As explained in the blog “Generic Series”, SAMOA calculates forward and backwards adjusted prices for futures. In this section we’ll use those prices so that we don’t have to deal with the rolls. All we need is daily closes. SAMOA’s database goes back to the TYM82 contract:
select Min(DateS) as DateS, dbo.ssToFrontContract('TY', Min(DateS), null) as [Contract], Min([Close]) as Price from DailyFutFront where Market='TY'
union all
select Max(DateS) as DateS, dbo.ssToFrontContract('TY', Max(DateS), null) as [Contract], Max([Close]) as Price from DailyFutFront where Market='TY'

- First, lets calculate the monthly returns manually (using forward-adjusted prices):
declare @TY_DailyCloses_Returns_Monthly table (
DateS datetime
,FirstP decimal(18,8)
,LastP decimal(18,8)
,PrevLastP decimal(18,8)
,ReturnPerc decimal(18,2)
);
insert into @TY_DailyCloses_Returns_Monthly (DateS, FirstP, LastP)
select
Max(DateS) as DateS
, dbo.ssAggrFirst( dates, CloseA) as FirstP
, dbo.ssAggrLast( dates, CloseA) as LastP
from DailyFutFrontA
where Market='TY'
group by dbo.ssOnlyMonth(dates);
UPDATE t SET t.PrevLastP = u.PrevLastP
FROM @TY_DailyCloses_Returns_Monthly t
INNER JOIN (
select DateS, (select top 1 LastP from @TY_DailyCloses_Returns_Monthly where DateS<p.DateS order by DateS desc) as PrevLastP
from @TY_DailyCloses_Returns_Monthly p
) u
ON t.DateS = u.DateS;
UPDATE @TY_DailyCloses_Returns_Monthly SET ReturnPerc = (LastP-isnull(PrevLastP,FirstP) ) / isnull(PrevLastP,FirstP) * 100;
Select * from @TY_DailyCloses_Returns_Monthly Order by DateS;

Notes about these calculations:
- DateS: Last day of the month for which there is a closing price.
- FirstP: First closing price of the month (chronologically), adjusted by the rolls.
- LastP: Closing price on DateS, adjusted by the rolls.
- PrevLastP: LastP of the previous month.
- ReturnPerc: Return for the month ending on DateS. Calculated as (LastP- PrevLastP) / PrevLastP * 100, except for the first row, where PrevLastP is replaced by FirstP.
- The functions ssAggrFirst() and ssAggrLast() are aggregating functions provided by SAMOA, that return the first and last prices chronologically.
Using SAMOA
SAMOA’s Booking System can handle generic futures if you don’t want to deal with rolls. Let’s use this feature to simulate the strategy.
- The strategy script for this buy-and-hold strategy can be defined as follows (please read “Back-testing Strategies” for more information about how to define a strategy using JScript, and about the function ssRunStrategyS):
var K = 10000000;
var valuept = CacheDS.Get_PLInfo("TY").ValuePT;
function event_OpenBook() {
context.AddCapital(K, "Initial K");
context.AddMark("TY", vars.Close);
var q = Math.Floor( K / (valuept * vars.Close));
context.AddTrade(null, "TY", q, vars.Close, "Stay fully invested");
}
function event_CloseDay() {
context.AddMark("TY", vars.Close);
}
function event_CloseBook() {
context.AddTrade(null, "TY", -book.accQ("TY"), vars.Close, "Liquidate");
}
NOTES:
- At the beginning, we add $10,000,000 of capital (K) to the book (line 4)
- The code CacheDS.Get_PLInfo("TY").ValuePT returns the value of a point for TY.
- We calculate the amount of contracts (q) necessary to be fully invested (line 6), and make the trade (line 7) at the prevailing price (vars.Close).
- Each new day, we mark the book to market (line 10).
- Finally, at the end of the simulation, we close the position (line 13).
- We can feed this JScript into the function ssRunStrategyS(…), which will produce only 2 trades:
- The monthly P&L report will look like this:
Figure P1:

- The monthly returns in the green column match exactly those calculated previously. In fact, when displayed side by side we never see differences bigger than 1 basis point, which can be attributed to rounding errors.

- Here are the summary statistics on the column “FromPrices-FromBook”:
- Finally, here is the full table of returns:

With no cash flows
The strategy that we’ve simulated so far buys 140 contracts at the beginning of the simulation, and rolls them all into the new front contracts every 3 months. Since the prices of the front and back contracts are usually different, this portfolio generates cash flows along the simulation.
We can modify the strategy so that on each roll we only use the proceeds of the sale to buy the new front contracts, thus reducing the cash left after both transactions (not eliminating it completely because it is not possible to trade fractions of a contract).
- For this strategy we will take care of the rolls ourselves. Therefore we need a table with the front contracts and the dates of the rolls:
with MainT as (
select Market, DateS,
Expiry as ExpiryF, [Close] as CloseF,
dbo.ssNextGenericCode(Expiry,'Front','TYFut',(select RollingMethod from Markets where Market='TY'),1) as ExpiryB
from DailyFutFront
where Market='TY'
)
select
Market, DateS,
Market + ExpiryF as Front, CloseF as FrontP,
case when DateS=dbo.ssGetCodeDatesTO(ExpiryF, 'Front', Market+'Fut', NULL) then 'YES' else '' end as Switch,
Market + ExpiryB as Back,
(select [Close] from DailyFut where Market=MainT.Market and Expiry=MainT.ExpiryB and DateS=MainT.DateS) as 'BackP'
from MainT
order by DateS
NOTES:
- Front, FrontP: front contract on DateS, with it’s price
- Back, BackP: back contract on DateS, with it’s price (if available)
- Switch: “YES” when a roll needs to be made from the Front to the Back (which will become the front the next day)
- Only rows with a FrontP are returned in this table.
- Let’s define the strategy:
var K = 10000000;
var valuept = CacheDS.Get_PLInfo("TY").ValuePT;
function event_OpenBook() {
context.AddCapital(K, "Initial K");
//Initial Buy
var q = Math.Floor(K / (valuept * vars.FrontP));
context.AddTrade(null, vars.Front, q, vars.FrontP, "Initial Buy");
}
function event_OpenDay() {
//Mark the book
context.AddMark(vars.Front, vars.FrontP);
if (vars.BackP!=null) context.AddMark(vars.Back, vars.BackP);
}
function event_CloseDay() {
if (vars.Switch == "YES") {
context.Liquidate("Switch:sell");
//Switch: buy
var q = Math.Floor( book.NAV / (valuept * vars.BackP) );
context.AddTrade(null, vars.Back, q, vars.BackP, "Switch: buy");
}
}
function event_CloseBook() {
context.Liquidate("Liquidate");
}
Note that this time around, in event_OpenDay we roll the position whenever Switch=“YES”.
- Feeding this script into ssRunStrategyS will produce the following trades:
NOTES:
- One “Initial Buy”, followed by a number of rolls (“Switch:sell”/”Switch:sell” pairs), followed by one “Liquidate” trade.
- The number of contracts Q varies over time to keep us fully invested.
- Which will produce the following slightly different returns:

[...] Buy and Hold: TY futures [...]
[...] Buy and Hold: TY futures [...]
Download Full Movies…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Download Full Movies…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Free Movie Downloads…
[...]just below, are some totally unrelated sites to ours, however, they are definitely worth checking out[...]…
Online Article……
[...]The info mentioned in the article is some of the best available [...]………
Now I’m like, well duh! Truly thfankul for your help.
tRd9JS yjzrgmuomvbk
qsRAKZ , [url=http://vqbcntczyemp.com/]vqbcntczyemp[/url], [link=http://qmblpejbmgpd.com/]qmblpejbmgpd[/link], http://unxweibavghu.com/
tRIpVl , [url=http://bupgmotvwahq.com/]bupgmotvwahq[/url], [link=http://uyudidtwmldg.com/]uyudidtwmldg[/link], http://tcfuscvjjfxp.com/
Blogging about…
[...]I don’t normally suggest other web-sites but I will break my trend for this[...]…
for…
what follows are a few web links to sites which we connect to seeing that we believe they are seriously worth visiting…
jacuzzi…
the time to check or inspect the content or internet sites we have linked to beneath the…
Related websites……
[...]we like to honor a number of other sites on the internet, even though they aren’t associated with us, by linking to them. Under are a few webpages worth checking out[...]……
2012 Fashion ideas30…
No one who cannot rejoice in the discovery of his own mistakes deserves to be called a scholar….
Sites You Should Check Out…
http://www.drainsurgeons.getlisted.co.nz/unblocking-sink-drain...
Travail de Yesturdays pour le demain – un regard à quelques exemples…
A été montré cet exemple, par l’intermédiaire de jon Messer dessus Journal de phase et croyez-le pour être très instructif et trop le point…
Sites You Should Check Out…
http://www.e-psychic-readings.com...
Yeast Infection Treatment…
[...]in the following are several hyper-links to internet websites that we connect to as we feel they will be truly worth browsing[...]…
Trackback…
[...]Do you’ve any? Kindly let me recognise in order that I could subscribe. Thanks.[...]…
Angry Birds Online…
[...]these are some hyper-links to internet pages we link to because we think they will be definitely worth browsing[...]…
Sites You Should Check Out…
http://www.theiminsider.com/how-make-a-website...
Entry Level Mechanical Engineering Jobs…
Entry Level Mechanical Engineering Jobs…
Sites You Should Check Out…
http://www.jucy.getlisted.co.nz/hire-a-car-auckland...
Het werk van Yesturdays voor morgen – een blik op sommige voorbeelden…
Werd getoond dit voorbeeld, via David hardvalder linkedin en gevonden het om te zijn zeer informatief en ook het punt…
Sites You Should Check Out…
http://www.xpanda.getlisted.co.nz/screen-doors-nz...
Sites You Should Check Out…
http://www.myhuntingnews.com...
Funny article…
Extremely funny post…
Dubai Gold Rate…
Hi there, just wanted to say, I enjoyed this blog post. It was helpful. Keep on posting!…
Dubai Gold Rate…
What’s up, just wanted to tell you, I loved this article. It was practical. Keep on posting!…
Websites worth visiting…
[...]here are some links to sites that we link to because we think they are worth visiting[...]……
Sites You Should Check Out…
http://www.drainsurgeons.getlisted.co.nz/master-unblocker...
Sites You Should Check Out…
http://www.christchurchglass.getlisted.co.nz...
Enjoyed every bit of it…
I should say, as a great deal as I enjoyed reading what you had to say, I couldnt assist but shed interest soon after a whilst….
Sites You Should Check Out…
http://www.demo.getlisted.co.nz/new-zealand-advertising...
Check this out…
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……
………..
My partner and i suppose in the meantime i’m going to accept bookmarking and also incorporating the RSS feed to my own Yahoo account. My partner and i enjoy brand new revisions and definately will share this site using my personal Facebook or myspace …
… [Trackback]…
[...] Read More: nestorsulikowski.com/index.php/2009/06/buy-and-hold-ty/ [...]…
Sites You Should Check Out…
http://www.ofis.getlisted.co.nz/...
Yesturdays work for tomorrow – a look at some examples…
Was shown this example, via megan hardvalder on Twitter and imagine it to be somewhat informative and too the point…
Just keep looking…
this blog appears not to be so well maintained these days but I like the post…
Sites You Should Check Out…
http://www.aucklandmarine.getlisted.co.nz/nz-boats-for-sale...
Sites You Should Check Out…
http://www.mymmainfo.com...
Solar Lights…
[...]down the page are a handful of urls to webpages which we link to as we believe they will be worth checking out[...]…
Sites You Should Check Out…
http://www.rotarydirect.getlisted.co.nz/rx7-rx...
Best articles…
[..] More info about this article creator Click Here [..]…
Yesturdays Arbeit für Morgen – ein Blick auf einige Beispiele…
Wurde dieses Beispiel, über gezeigt Megan McCormick an Twitter und glauben Sie ihm vor um zu sein extrem informativ und auch der Punkt…
Articles…
[..] More info Here [..]…
More info…
[..] More info here [..]…
Lavoro per il domani – uno sguardo di Yesturdays ad alcuni esempi…
Notato questo esempio, via jon halign sopra Twitter e credilo per essere estremamente informativo ed ugualmente il punto…
Singapore Web Design…
Ahh tis quite true…….
Nestor Sulikowski…
I actually wanted to send a small remark so as to express gratitude to you for the wonderful pointers you are giving on this website. My extended internet investigation has at the end of the day been compensated with sensible tips to write about with m…
Nestor Sulikowski…
I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an shakiness over that you wish be delivering the following. unwell unquestionably come further forme…
Lucas…
i really want to add your site link at my blog, because your site help me a lot…please give me an anchor text if you want to add your link at my blogroll……
Nestor Sulikowski…
[..] More info here [..]…
Recommended Websites…
[...]below you’ll find the link to some sites that we think you should visit[...]…
Great information…
This is certainly exceptional. Sole looked at the plant amount and we are shocked. We are most certainly fascinated by this type of points. A good appreciate member’s retailer, and estimate your time inside this. Please keep editing. They’re exceedin…
………..
We guess in the meantime i am going to be satisfied with bookmarking as well as incorporating your own Feed to be able to my personal Google consideration. I look ahead to fresh updates and will share this site together with my personal Facebook or mys…
Nestor Sulikowski…
Your blog doesn’t show up correctly on my iphone4 – you may want to try and repair that…
pizdy…
Ostre ruchanie wygolonej cipy…
important links…
Guys check out these important links…
………..
We suppose for now i’ll be happy with bookmarking as well as introducing the RSS feed for you to my own Yahoo and google bank account. My partner and i look forward to new improvements and can share this blog with my Facebook team….
[...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……
Great information…
This is superior. A miami detective checked out this amazing gist therefore we are stupefied. We are curious about this sort of anything. Sole appreciate consumers accumulate, and number your time with this. Please keep enhancing. They’re identical vi…
oferte preturi 2012…
I guess what I’m trying to say is, I don’t think you can measure life in terms of years. I think longevity doesn’t necessarily have anything to do with happiness. I mean happiness comes from facing challenges and going out on a limb and taking risks…
Great information…
This is very nice. Members looked at exactly that substance and we are impressed. We are precisely interested in this kind of whatever you may desire. Folk appreciate dieter s business, and treasure your precious time inside this. Please keep adding in…
Sites we Like……
[...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]……
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
[...]Here are some of the sites we recommend for our visitors[...]……
………..
My spouse and i guess in the meantime i’ll accept book-marking and also including the Feed to our Yahoo and google consideration. My partner and i anticipate fresh revisions and will share this kind of site with my personal Fb team….
Great information…
This is first-class. At least one looked at this guidance gist and we are wordless. We are precisely curious about one of these problems. All of us appreciate body reference, and regard doing in this. Please keep updating. These are entirely practical …
… [Trackback]…
[...] Informations on that Topic: nestorsulikowski.com/index.php/2009/06/buy-and-hold-ty/ [...]…
My opinion is ……
There are actually a number of details like that to take into consideration. That could be a great level to convey up. I provide the ideas above as general inspiration however clearly there are questions like the one you convey up the place crucial fac…
………..
I guess in the meantime i’ll accept book-marking along with adding your Feed for you to my Yahoo and google bank account. My partner and i look forward to brand new revisions and definately will share this blog using my Fb team….
Read More…
[...]…Most Nice…[...]…
Great information…
This is often distinctive. One watch this realisation delighted therefore we are confused. We’re interested in this kind of whatever you may desire. Among appreciate each of your sharing, and evaluate your precious time in this. Please keep updating. …
……
It?s onerous to search out knowledgeable people on this topic, however you sound like you know what you?re speaking about! Thanks…
Read More…
[...]…We like this Blog…[...]…
[...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……
Read More…
[...]…Most Nice…[...]…
Great information…
This is marvelous. Among checked out this in turn substance when we are astounded. We’re attracted to this kind of things. Device appreciate your selected pointers, and amount the effort while in this. Please keep editing. They may be entirely treasur…
[...]the time to read or visit the content or sites we have linked to below the[...]……
[...]here are some links to sites that we link to because we think they are worth visiting[...]……
[...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……
[...]just beneath, are numerous totally not related sites to ours, however, they are surely worth going over[...]……
Read More…
[...]…Very Interesting…[...]…
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
[...]Here are some of the sites we recommend for our visitors[...]……
Read More…
[...]…Most Helpful…[...]…
[...]Sites of interest we have a link to[...]……
[...]usually posts some very interesting stuff like this. If you’re new to this site[...]……
Yahoo Backlinks Service…
What’s up, just wanted to tell you, I liked this blog post. It was helpful. Keep on posting!…
[...]the time to read or visit the content or sites we have linked to below the[...]……
[...]here are some links to sites that we link to because we think they are worth visiting[...]……
[...]The information mentioned in the article are some of the best available [...]……
[...]below you’ll find the link to some sites that we think you should visit[...]……
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
[...]Here are some of the sites we recommend for our visitors[...]……