CPSC 217: Assignment 2
New Concepts to be applied for the assignment
- Input, branching, looping, random numbers and program documentation
Introduction to investing1
|
|
|
Financial investing is complex but the
essence of it involves: risk and the potential reward. Risk is the amount
of fluctuation (in this case downwards) that can occur in a particular
investment. Putting money into a term bank deposit insured by a stable
government entails very little risk. Investing your money into the assets of a
corporation in the hopes of receiving a return entails
greater risk: losses may occur or the entire investment itself may be lost.
Prices may quickly go up or down (sometimes by wide variations). Selling when prices have decreased may result in a
loss, while selling when prices have increased may result in profits.
Why do people willing put their money into
riskier investments? The low risk investments have a very low return on your
investment (e.g., in a depressed economy the interest you make in a savings
account is less than the rate of inflation e.g., 1.5% interest a year
(max) on some term deposits vs. an inflation rate around 2 - 3%2). While it is not
guaranteed that 'riskier' investments will result in a larger return they
generally have the potential for larger gains. It's up to the would-be
investor to balance out the desire for maximum returns vs. his or her aversion
to risk.
1 Note this introduction is meant only to provide background information
needed to create your simulation. No guarantees are provided about
your ability to making big $$$!
2 Raw data comes from the actual interest and inflation rates from the
2012 - 2013.
Assignment description
Write a program that allows the user to invest in one of three investment
products, each with a different level of risk. The goal is to reap maximum
returns at the end of the year (and in the long term earn maximum returns for
the 10 year simulation span). The starting cash is $100. To simplify things all cash must be
invested wholly in a product - no 'diversifying' or splitting amounts between multiple
products is possible. To implement the random nature for each of the three
products you can use the pre-created code in the 'random'
library module.
Product I, Fly-By-Night Investments (Stock code: FBN): high risk, high
potential returns
- 50% chance3 of a loss of 2 - 20% during a year e.g., $100
starting cash with a 20% loss would result in $80 at year end.
- 20% chance3 the value of the investment does not change
during the year.
- 30% chance3 of a gain of 5 - 50% during a year.
Product II, Blue Chips INC. (Stock code: BCI): moderate risk, good
potential yearly returns
- 25% chance3 of a loss of 1 - 6% during the year.
- 50% chance3 of no change to the investment.
- 25% change3 of a gain of 1 - 6% during the year.
The losses/gains are average performances over a year (the average change
cannot be an increase and a decrease so only one outcome is possible).
3 To reduce the complexity when generating the probability of a gain or
a loss the program only has to generate integer value percentages e.g.,
1%, 2%, 3% etc. and not the real number values in between these integers. So
when generating the chance of loss or gain for FBN then the program would just
generate a value from 1 - 100%. In a similar fashion the range of percentages
for the average increase or decrease will also consist only of whole number
percentages.
Product III, Slow-And-Steady Corp. (Stock code: SNS), mature industry
stock: no risk but low returns
- This stock will generate a gain at the 'prime' interest rate of 1.5%
each year.
As mentioned losses or gains will be calculated for each year with the year
end monies carried over as the starting money for the next year. At the end of each year the following financial report
should display the current risk level (high, medium or low) on one line and
on the line below it a summary of the performance for year:
Format:
<Investment risk level>
<Amount of money at the start of the year>
<Dollars earned or lost during the year> <Amount of money at the end of the
year>
Example:
High risk investment
Investment (start) $142.13
Investment (change) $-7.11 Investment (end) $135.02
Then the user will be prompted with a menu to put his/her cash in one of the
three investment products:
If a selection doesn't match option 1 - 3, then the program will continue
prompting the user until a value within this range has been entered. The program will run for a ten years
at which point it will display a summary for the tenth year as well as displaying
performance for the entire ten year period.
Format:
<Amount of money at the start of the
simulation>
<Dollars earned or lost during the 10 years
<Amount of money at the end of the
simulation>
Example (notice the formatting of the
information at the end of the ten years is different from the yearly report in order to
make it stand out):
Test mode:
Under normal conditions the program will
randomly determine profits/loses as well randomly determining the magnitude of
the loss/gain (where applicable). To make it easier to determine if the program
is working correctly you also must implement a test mode. When the program first
runs the user can choose whether the program will run in normal (random) mode or
test mode. The program should allow either upper or lower case input. If however
the user doesn't not enter one of: 'r', 'R', 't' or 'T' then similar to
the menu that allows selection for the type of investment product, the program
should loop until random or test mode has been selected.
Under test mode: the 'seed' (starting value
used as input to the random generator) will be a fixed value (the number one).
Using the same seed will mean that the function will generate the same series of
numbers. The effect is that if the same investment product or products is chosen
by the user then the yearly returns will be same each time that the program is
run. In test mode comparing your results vs. the expected results allows markers
to quickly determine if your program is correct. In additional to materials
covered in class regarding random number generation here is an additional
example that will show you how to generate a series of numbers that will be
different each time that the program is run (random seed) and how to generate an
identical series of numbers each time the program runs (fixed seed): [Python
program]
Submitting your work:
- Source code Python program/'dot-py' file(s) must be electronically
submitted according to [submission submision
requirements].
- As a reminder, you cannot work in groups for this class.
Copying/viewing other student's work will be
regarded as academic misconduct (cheating). For additional details about
what is and is not okay for this class please refer to the following
[misconduct link].
- Before you submit your assignment here is a checklist of items to be
used in marking: [checklist link]
External libraries that can be used (unless listed don't assume you can use
an external library)
- Libraries that allow for text-based (console) input and output.
- Random number generators