updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Mon, 08 Nov 2021 01:16:13 +0000
changeset 402 de59aa20a1dc
parent 401 9471c3b7ea02
child 403 ffce7b61b446
updated
core_solution1/collatz.jar
core_solution2/docdiff.jar
core_solution3/postfix.jar
core_solution3/postfix2.jar
main_solution1/drumb.scala
main_testing1/drumb.scala
main_testing1/drumb_test1.scala
main_testing1/drumb_test2.scala
main_testing1/drumb_test3.scala
main_testing1/drumb_test4.scala
main_testing1/drumb_test5.scala
main_testing1/drumb_test6.scala
main_testing1/drumb_test7.scala
Binary file core_solution1/collatz.jar has changed
Binary file core_solution2/docdiff.jar has changed
Binary file core_solution3/postfix.jar has changed
Binary file core_solution3/postfix2.jar has changed
--- a/main_solution1/drumb.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_solution1/drumb.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -194,7 +194,3 @@
 
 
 
-
-
-import CW6b._ 
-investment(rstate_portfolio, 1978 to 2019, 100)
--- a/main_testing1/drumb.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -1,4 +1,4 @@
-// Core Part 6 about a really dumb investment strategy
+// Main Part 1 about a really dumb investment strategy
 //=====================================================
 
 
@@ -6,7 +6,7 @@
 //   > scala -d drumb.jar  drumb.scala
 
 
-object CW6b { 
+object M1 { 
 
 
 //two test portfolios
@@ -167,17 +167,30 @@
 
 
 
-
-investment(List("AAPL"), 2000 to 2001, 100)
-val aapl_prices = get_prices(List("AAPL"), 2000 to 2002)
-val aapl_deltas = get_deltas(aapl_prices)
-
 //test cases for the two portfolios given above
 
-//println("Real data: " + investment(rstate_portfolio, 1978 to 2019, 100))
-//println("Blue data: " + investment(blchip_portfolio, 1978 to 2019, 100))
+  println("Real data: " + investment(rstate_portfolio, 1978 to 2019, 100))
+  println("Blue data: " + investment(blchip_portfolio, 1978 to 2019, 100))
+
 
 }
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- a/main_testing1/drumb_test1.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test1.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -1,5 +1,5 @@
-assert(CW6b.get_january_data("GOOG", 1980) == List())
-assert(CW6b.get_january_data("GOOG", 2010).head == "2010-01-04,312.204773")
+assert(M1.get_january_data("GOOG", 1980) == List())
+assert(M1.get_january_data("GOOG", 2010).head == "2010-01-04,312.204773")
 
 
 
--- a/main_testing1/drumb_test2.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test2.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -7,6 +7,6 @@
 }
 */
 
-assert(CW6b.get_first_price("GOOG", 1980) == None)
-assert(CW6b.get_first_price("GOOG", 2010) == Some(312.204773))
+assert(M1.get_first_price("GOOG", 1980) == None)
+assert(M1.get_first_price("GOOG", 2010) == Some(312.204773))
 
--- a/main_testing1/drumb_test3.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test3.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -1,4 +1,4 @@
-import CW6b._
+import M1._
 
 
 
--- a/main_testing1/drumb_test4.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test4.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -1,6 +1,6 @@
 
 
-assert(CW6b.get_delta(None, None) == None)
-assert(CW6b.get_delta(Some(50.0), None) == None)
-assert(CW6b.get_delta(None, Some(100.0)) == None)
-assert(CW6b.get_delta(Some(50.0), Some(100.0)) == Some(1.0))
+assert(M1.get_delta(None, None) == None)
+assert(M1.get_delta(Some(50.0), None) == None)
+assert(M1.get_delta(None, Some(100.0)) == None)
+assert(M1.get_delta(Some(50.0), Some(100.0)) == Some(1.0))
--- a/main_testing1/drumb_test5.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test5.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -12,7 +12,7 @@
                         List(Some(331.462585), Some(51.464207)))
 
 
-assert(CW6b.get_deltas(urban_prices) == List(List(Some(-0.03573991804411003), Some(0.539974575389325)), 
+assert(M1.get_deltas(urban_prices) == List(List(Some(-0.03573991804411003), Some(0.539974575389325)), 
                                           List(Some(0.10103414222249969), Some(0.24777764141006836))))
 
 
@@ -22,6 +22,6 @@
                          List(Some(38.188)))
 
 
-assert(CW6b.get_deltas(urban_prices2) == List(List(None), List(None), 
+assert(M1.get_deltas(urban_prices2) == List(List(None), List(None), 
                                         List(Some(0.9277165354330709)), 
                                         List(Some(2.119679764725104))))
--- a/main_testing1/drumb_test6.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test6.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -14,5 +14,5 @@
 
 
 
-assert(CW6b.yearly_yield(ds_urban, 100, 0) == 125)
-assert(CW6b.yearly_yield(ds_urban, 100, 1) == 117)
+assert(M1.yearly_yield(ds_urban, 100, 0) == 125)
+assert(M1.yearly_yield(ds_urban, 100, 1) == 117)
--- a/main_testing1/drumb_test7.scala	Mon Nov 08 01:03:09 2021 +0000
+++ b/main_testing1/drumb_test7.scala	Mon Nov 08 01:16:13 2021 +0000
@@ -8,17 +8,17 @@
 }
 */
 
-assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100)
-assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27)
-assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42)
-assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27)
-assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38)
+assert(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100)
+assert(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27)
+assert(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42)
+assert(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27)
+assert(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38)
 
 // 113
-assert((112 to 114).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100)))
+assert((112 to 114).contains(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100)))
 // 254
-assert((252 to 256).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100)))
+assert((252 to 256).contains(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100)))
 // 349
-assert((346 to 352).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100)))
+assert((346 to 352).contains(M1.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100)))
 //11504
-assert((11389 to 11619).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 1990 to 2017, 100)))
+assert((11389 to 11619).contains(M1.investment(List("GOOG", "AAPL", "BIDU"), 1990 to 2017, 100)))