--- a/solutions1/drumb.scala Sat Jun 22 08:39:52 2019 +0100
+++ b/solutions1/drumb.scala Wed Jul 24 14:22:06 2019 +0100
@@ -73,16 +73,13 @@
//test cases
-//val p_fb = get_prices(List("FB"), 2012 to 2014)
-//val p = get_prices(List("GOOG", "AAPL"), 2010 to 2012)
-
-//val tt = get_prices(List("BIDU"), 2004 to 2008)
+//println("Task 3 data from Google and Apple in 2010 to 2012")
+//val goog_aapl_prices = get_prices(List("GOOG", "AAPL"), 2010 to 2012)
+//println(goog_aapl_prices.toString ++ "\n")
-//==============================================
-// Do not change anything below, unless you want
-// to submit the file for the advanced part 3!
-//==============================================
+//val p_fb = get_prices(List("FB"), 2012 to 2014)
+//val tt = get_prices(List("BIDU"), 2004 to 2008)
// (4) The function below calculates the change factor (delta) between
@@ -107,7 +104,11 @@
// test case using the prices calculated above
-//val d = get_deltas(p)
+
+//println("Task 5 change prices from Google and Apple in 2010 and 2011")
+//val goog_aapl_deltas = get_deltas(goog_aapl_prices)
+//println(goog_aapl_deltas.toString ++ "\n")
+
//val ttd = get_deltas(tt)
@@ -125,9 +126,20 @@
}
}
+// test case using the deltas calculated above
+//println("Task 6 yield from Google and Apple in 2010 with balance 100")
-yearly_yield(get_prices(rstate_portfolio, 2016 to 2018), 100, 2)
-get_prices(rstate_portfolio, 2016 to 2018)(2).flatten.sum
+//val d0 = goog_aapl_deltas(0)(0)
+//val d1 = goog_aapl_deltas(0)(1)
+//println(s"50 * ${d0.get} + 50 * ${d1.get} = ${50.toDouble * d0.get + 50.toDouble * d1.get}")
+
+
+//val goog_aapl_yield = yearly_yield(goog_aapl_deltas, 100, 0)
+//println("Rounded yield: " ++ goog_aapl_yield.toString ++ "\n")
+
+
+//yearly_yield(get_prices(rstate_portfolio, 2016 to 2018), 100, 2)
+//get_prices(rstate_portfolio, 2016 to 2018)(2).flatten.sum
// (7) Write a function compound_yield that calculates the overall balance for a
@@ -152,8 +164,8 @@
//test cases for the two portfolios given above
-//println("Real data: " + investment(rstate_portfolio, 1978 to 2018, 100))
-//println("Blue data: " + investment(blchip_portfolio, 1978 to 2018, 100))
+//println("Real data: " + investment(rstate_portfolio, 1978 to 2019, 100))
+//println("Blue data: " + investment(blchip_portfolio, 1978 to 2019, 100))
}