--- a/cws/cw01.tex Wed Nov 09 13:09:38 2016 +0000
+++ b/cws/cw01.tex Wed Nov 09 13:36:13 2016 +0000
@@ -7,10 +7,10 @@
\section*{Coursework 6 (Scala)}
This coursework is about Scala and is worth 10\%. The first and second
-part is due on 16 November at 11:00, and the third part on 23 November
+part are due on 16 November at 11:00, and the third part on 23 November
at 11:00. You are asked to implement three programs about list
processing and recursion. The third part is more advanced and might
-include material you have not yet heard about in the first lecture.
+include material you have not yet seen in the first lecture.
\subsection*{Disclaimer}
@@ -80,9 +80,10 @@
\item[(2)] Write a second function that takes an upper bound as
argument and calculates the steps for all numbers in the range from
1 up to this bound. It returns the maximum number of steps and the
- corresponding number that needs that many steps. The first
- component of the pair is the number of steps and the second is the
- corresponding number. \hfill[1 Mark]
+ corresponding number that needs that many steps. More precisely
+ it returns a pair where the first
+ component is the number of steps and the second is the
+ corresponding number. \hfill\mbox{[1 Mark]}
\end{itemize}
\noindent
@@ -121,7 +122,7 @@
to buy and when to sell this commodity. In the example above it should
return the pair $\texttt{(1, 3)}$ because at index $1$ the price is lowest and
then at index $3$ the price is highest. Note the prices are given as
-lists of \texttt{Float}s. \hfill[1 Mark]
+lists of \texttt{Float}s.\newline \mbox{} \hfill[1 Mark]
\item[(2)] Write a function that requests a comma-separated value (CSV) list
from the Yahoo websevice that provides historical data for stock
@@ -131,7 +132,7 @@
\url{http://ichart.yahoo.com/table.csv?s=GOOG}
\end{center}
-\noindent where \texttt{GOOG} stands for Google's stock market symbol
+\noindent where \texttt{GOOG} stands for Google's stock market symbol,
then you will receive a CSV-list of the daily stock prices since
Google was listed. You can also try this with other stock market
symbols, for instance AAPL, MSFT, IBM, FB, YHOO, AMZN, BIDU and so
@@ -188,18 +189,18 @@
estimated he is 3 Billion Dollar worth (one is not sure, of course,
because Mr Drump refuses to make his tax records public).
-The question about Mr Drump's business acumen remains. So let's do a
+Since the question about Mr Drump's business acumen remains, let's do a
quick back-of-the-envelope calculation in Scala whether his claim has
any merit. Let's suppose we are given \$100 in 1978 and we follow a
really dump investment strategy, namely:
\begin{itemize}
-\item We blindly choose a portfolio of stocks, say some Blue-Chips stocks
+\item We blindly choose a portfolio of stocks, say some Blue-Chip stocks
or some Real Estate stocks.
\item If some of the stocks in our portfolio are traded in January of
- a year, we invest our money to equal amounts in each of these
+ a year, we invest our money in equal amounts in each of these
stocks. For example if we have \$100 and there are four stocks that
- are traded in our portfolio, we buy in January \$25 worth of stocks
+ are traded in our portfolio, we buy \$25 worth of stocks
from each.
\item Next year in January, we look how our stocks did, liquidate
everything, and re-invest our (hopefully) increased money in again
@@ -217,7 +218,7 @@
\item[(1.a)] Write a function that queries the Yahoo financial data
service and obtains the first trade (adjusted close price) of a
stock symbol and a year. A problem is that normally a stock exchange
- is not open on 1st of January, but depending a the day of the week
+ is not open on 1st of January, but depending on the day of the week
on a later day (maybe 3rd or 4th). The easiest way to solve this
problem is to obtain the whole January data for a stock symbol as
CSV-list and then select the earliest entry in this list. For this
@@ -234,12 +235,12 @@
\texttt{f} argument of the query). Such a request might fail, if the
company does not exist during this period. For example, if you query
for Google in January of 1980, then clearly Google did not exists yet.
- Therefore you need to return a trade price as
+ Therefore you are asked to return a trade price as
\texttt{Option[Double]}.
-\item[(1.b)] Write a function that takes a portfolio (a List of stock symbols),
- a years range and gets all the first trading prices for a year. You should
- organise this as a list of lists of \texttt{Option[Double]}. The inner lists
+\item[(1.b)] Write a function that takes a portfolio (a list of stock symbols),
+ a years range and gets all the first trading prices for each year. You should
+ organise this as a list of lists of \texttt{Option[Double]}'s. The inner lists
are for all stock symbols from the portfolio and the outer list for the years.
For example for Google and Apple in years 2010 (first line), 2011
(second line) and 2012 (third line) you obtain:
@@ -262,15 +263,15 @@
\item[(2.b)] Write a function that calculates all change factors
(deltas) for the prices we obtained under Task 1. For the running
- example of Google and Apple for the years 2010 to 2012 gives
- the 4 change factors:
+ example of Google and Apple for the years 2010 to 2012 you should
+ obtain 4 change factors:
\begin{verbatim}
List(List(Some(-0.03573991820699504), Some(0.5399747522663995))
List(Some(0.10103414428290529), Some(0.24777742035415723)))
\end{verbatim}
- That is Google did a bit badly in 2010, while Apple did very well.
+ That means Google did a bit badly in 2010, while Apple did very well.
Both did OK in 2011.\hfill\mbox{[1 Mark]}
\item[(3.a)] Write a function that calculates the ``yield'', or
@@ -304,7 +305,7 @@
into \$23,794 for real estate and a whopping \$524,609 for blue chips.\medskip
\noindent
-\textbf{Moral:} Reflecting on our assumptions, we are overestimating
+\textbf{Moral:} Reflecting on our assumptions, we are over-estimating
our yield in many ways: first, who can know in 1978 about what will
turn out to be a blue chip company. Also, since the portfolios are
chosen from the current S\&P 500, they do not include the myriad