This assignment is due by 2:00 p.m. on Wednesday, 5 February.
See the assignment turn-in page (last modified on 9 February 2004) for instructions on
turning in your assignment.
You belong to a 401(k) plan at work. Every month $2,500 is deducted from your
pay to buy shares from any of three mutual funds X, Y, and Z.
An investment strategy determines how your monthly deduction should be
spent to buy some number of shares of each mutual fund. The return on
your investment strategy is the difference between your portfolio value and the
amount of money you've spent (which is called the principle), expressed as
percentage of amount of money you've spent. For example, if after a year (12
months) your portfolio is worth $33,000, then your return would be
= | (value - principle)/principle |
= | (33000 - 30000)/30000 |
= | 33/30 - 1 |
= | 1.1 - 1 |
= | 10% |
Here are some important rules regarding your 401(k) plan:
- Transactions are carried out exactly once per month.
- The full $2,500 must be spent each month; no withdrawals or parking in
money markets.
- You can only buy shares of mutual funds X, Y, and Z,
although you needn't buy all three each month (however, because of rule
2 you must buy at least one of them). Fractional share purchaces are
allowed.
- You may sell shares in one mutual fund to buy shares of another; all
extra money received from sales must be spent in the same transaction.
- No fancy stuff; no market orders, no margins or short selling, no
options, no bid-ask spreads. Just good, simple buying and selling.
- There are no other costs or fees.
Find an investment strategy maximizes your 401(k) return. Because you can't
foresee the future (I'm assuming), you'll have to develop a strategy that works
reasonably well for a broad range of market conditions, rather than a strategy
that works very well for a particular market condition.
Your program should read input from std-in. Input consists of a sequence of
zero or more text lines. Each line contains three numbers giving the dollar
value per share of mutual funds X Y, and Z in that order. For
example, the line
100.34 34.00 75.25
indicates that a share of X costs $100.34, a share of Y costs $34.00
and a share of Z costs $75.25.
Consecutive non-empty lines represent prices for consecutive months. All data
read during a program run should be considered part of the same data set.
If an input line doesn't have the specified format, your program should output
an informative error message to std-err and exit.
The assignment directory /export/home/class/cs-525/pa1
contains three data files prices.{1,2,3}
, each one of which contains monthly share prices for mutual funds X,
Y, and Z over a ten-year period (the '70s, '80s and '90s).
You are encouraged to create your own data sets too. Probably the easiest way
to do that is to find downloadable historical mutual-fund or
stock share prices on the web.
Your program should write output to std-out; output consists of a sequence of
lines. A non-empty line contains a single month's transaction; each line
contains three numbers representing the value of shares of mutual funds X,
Y and Z bought that month (a negative number indicates the value of
shares sold).
For example, the line
2000.00 -1000.00 1500.00
indicates that on month's transactions consisted of buying $2000 worth of
shares in mutual fund $(X), selling $1000 worth of shares in mutual fund $(Y),
and buying $1500 worth of shares in mutual fund $(Z). Note that the sum of the
values for any month should be $2,500.00.
The final line of output should contain a single number representing the
return achieved by the investment plan. The return should have no more than
four significant digits, and be expressed as a percentage. For example, the
output
12.34
indicates the investment plan had a return of 12.34%.
The assignments will be ordered based on best average return for a given set of
mutual-fund data, which includes, but it not limited to, the data in the
assignment directory. Once ordered, the assignment with the best average
return gets 100, the next best 95, and so on down to 85; the remaining
assignments get 80.
You should turn-in the code of the simulation that implements the best
investment policy you've discovered. You should also turn-in a brief two- or
three-page report describing your financial simulation. The report should
describe
- your financial simulation. This is a half-page description of the
general structure of your simulation and an analysis
- the set of investment plans you simulated. For each investment plan,
your report should describe the plan, the motivation or principles behind the
plan, the return on the plan, and an analysis of the results. One paragraph of
one or two sentence per description should be enough for most investment plans.
- the mutual-fund data used. If you created extra data sets (and you
should have) write a paragraph describing the source of each data set and any
processing you applied to the data. (You need not describe the data available
in the assignment directory).
This report will be the basis for your presentation. The report should be in a
generic format, such as plain text, PostScript, or Portable Document Format
(pdf). Get in touch with me if you want to use something else.
You should include a makefile among the files you turn in, either for testing
or to turn-in. Your makefile should understand two targets: go and clean. The
go target should build your assignment; the name of the executable should be
401k-sim
, but the testing scripts should be able to deal with other
names. The clean target should delete all unnecessary files. Unnecessary files
are any files generated by the makefile itself; such files include the .o files
for C++, class files for Java, and any executables built by the makefile.
When you test or turn-in your project, the turn-in script runs (among other
things) the following commands:
$ make clean
$ make go
You should make sure this works correctly.
There's an example makefile you can use in the assignment directory. If
anybody feels the need to use ant or some other build mechanism, they should
get in touch with me (essentially, what I'll tell you to put it in a makefile,
but we'll have to work that out together).
See the assignment turn-in page (last modified on 9 February 2004) for instructions on
turning in your assignment.
This page last modified on 15 February 2005.