testing/drumb_test3.scala
changeset 137 53c769a78a1e
parent 135 077e63e96287
child 138 7415ff9c91f4
equal deleted inserted replaced
136:c08ba57a7f53 137:53c769a78a1e
     1 //println("starting test now")
       
     2 
       
     3 /*
       
     4 import scala.concurrent._
       
     5 import scala.concurrent.duration._
       
     6 import ExecutionContext.Implicits.global
       
     7 import scala.language.postfixOps 
       
     8 
       
     9 val test_data = List(List(Some(71.539941), None), List(Some(76.974614), None), 
       
    10                      List(Some(65.226685), Some(6.35)), List(Some(78.354649), Some(12.241)), 
       
    11                      List(Some(85.517645), Some(38.188)))
       
    12 
       
    13 val test_deltas = List(List(Some(0.07596697626574789), None), 
       
    14                        List(Some(-0.152620823795232), None), 
       
    15                        List(Some(0.20126676681483952), Some(0.9277165354330709)), 
       
    16                        List(Some(0.09141762603007778), Some(2.119679764725104)))
       
    17 
       
    18 lazy val f = Future {
       
    19   assert((yearly_yield(test_deltas, 100, 0) - 107).abs <= 2)
       
    20   assert((yearly_yield(test_deltas, 100, 1) - 85).abs <= 2)
       
    21   assert((yearly_yield(test_deltas, 100, 2) - 156).abs <= 2)
       
    22   assert((yearly_yield(test_deltas, 100, 3) - 210).abs <= 2)
       
    23   assert((investment(List("IBM", "BIDU"), 2004 to 2008, 100) - 298).abs <= 10)
       
    24 }
       
    25 
       
    26 
       
    27 Await.result(f, 180 second)
       
    28 
       
    29 */
       
    30 
     1 
    31 val urban_prices = List(List(Some(311.349976), Some(27.505054)), 
     2 val urban_prices = List(List(Some(311.349976), Some(27.505054)), 
    32 			List(Some(300.222351), Some(42.357094)), 
     3 			List(Some(300.222351), Some(42.357094)), 
    33 			List(Some(330.555054), Some(52.852215)))
     4 			List(Some(330.555054), Some(52.852215)))
    34 
     5 
    35 
     6 
    36 assert(CW6c.yearly_yield(CW6c.get_deltas(urban_prices), 100, 0) == 125)
     7 assert(CW6c.yearly_yield(CW6c.get_deltas(urban_prices), 100, 0) == 125)
    37 
     8 
    38 
     9 
    39 val blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "AMZN", "BIDU")
    10 val urban_blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "AMZN", "BIDU")
    40 val rstate_portfolio = List("PLD", "PSA", "AMT", "AIV", "AVB", "BXP", "CCI", 
    11 val urban_rstate_portfolio = List("PLD", "PSA", "AMT", "AIV", "AVB", "BXP", "CCI", 
    41                             "DLR", "EQIX", "EQR", "ESS", "EXR", "FRT", "GGP", "HCP") 
    12                                   "DLR", "EQIX", "EQR", "ESS", "EXR", "FRT", "GGP", "HCP") 
    42 
    13 
    43 
    14 
    44 assert(CW6c.investment(rstate_portfolio, 1978 to 2017, 100) == 30839)
    15 assert(CW6c.investment(urban_rstate_portfolio, 1978 to 2017, 100) == 30839)
    45 assert(CW6c.investment(blchip_portfolio, 1978 to 2017, 100) == 349597)
    16 assert(CW6c.investment(urban_blchip_portfolio, 1978 to 2017, 100) == 349597)