cws/cw01.tex
changeset 167 349d706586ef
parent 166 780c40aaad27
child 192 a112e0e2325c
equal deleted inserted replaced
166:780c40aaad27 167:349d706586ef
   306 
   306 
   307   \[
   307   \[
   308   \frac{price_{new} - price_{old}}{price_{old}}
   308   \frac{price_{new} - price_{old}}{price_{old}}
   309   \]
   309   \]
   310 
   310 
       
   311   If the change factor is defined, you should return it
       
   312   as \texttt{Some(change factor)}; if not, you should return
       
   313   \texttt{None}.
   311   
   314   
   312 \item[(2.b)] Write a function that calculates all change factors
   315 \item[(2.b)] Write a function that calculates all change factors
   313   (deltas) for the prices we obtained under Task 1. For the running
   316   (deltas) for the prices we obtained under Task 1. For the running
   314   example of Google and Apple for the years 2010 to 2012 you should
   317   example of Google and Apple for the years 2010 to 2012 you should
   315   obtain 4 change factors:
   318   obtain 4 change factors:
   318   List(List(Some(-0.03573992567129673), Some(0.5399749442411563))
   321   List(List(Some(-0.03573992567129673), Some(0.5399749442411563))
   319         List(Some(0.10103412653643493), Some(0.2477771728154912)))
   322         List(Some(0.10103412653643493), Some(0.2477771728154912)))
   320 \end{verbatim}
   323 \end{verbatim}
   321 
   324 
   322   That means Google did a bit badly in 2010, while Apple did very well.
   325   That means Google did a bit badly in 2010, while Apple did very well.
   323   Both did OK in 2011.\\
   326   Both did OK in 2011. Make sure you handle the cases where a company is
       
   327   not listed in a year. In such cases the change factor should be \texttt{None}
       
   328   (see 2.a).\\
   324   \mbox{}\hfill\mbox{[1 Mark]}
   329   \mbox{}\hfill\mbox{[1 Mark]}
   325 
   330 
   326 \item[(3.a)] Write a function that calculates the ``yield'', or
   331 \item[(3.a)] Write a function that calculates the ``yield'', or
   327   balance, for one year for our portfolio.  This function takes the
   332   balance, for one year for our portfolio.  This function takes the
   328   change factors, the starting balance and the year as arguments. If
   333   change factors, the starting balance and the year as arguments. If