marking/drumb_test3.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 25 Jan 2017 01:25:17 +0000
changeset 104 07780accd5df
parent 82 28c8e17ab83a
child 169 b37052895281
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
//println("starting test now")
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import scala.concurrent._
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
import scala.concurrent.duration._
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
import ExecutionContext.Implicits.global
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
import scala.language.postfixOps 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
val test_data = List(List(Some(71.539941), None), List(Some(76.974614), None), 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
                     List(Some(65.226685), Some(6.35)), List(Some(78.354649), Some(12.241)), 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
                     List(Some(85.517645), Some(38.188)))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
val test_deltas = List(List(Some(0.07596697626574789), None), 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
                       List(Some(-0.152620823795232), None), 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
                       List(Some(0.20126676681483952), Some(0.9277165354330709)), 
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
                       List(Some(0.09141762603007778), Some(2.119679764725104)))
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
lazy val f = Future {
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
  assert((yearly_yield(test_deltas, 100, 0) - 107).abs <= 2)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  assert((yearly_yield(test_deltas, 100, 1) - 85).abs <= 2)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  assert((yearly_yield(test_deltas, 100, 2) - 156).abs <= 2)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  assert((yearly_yield(test_deltas, 100, 3) - 210).abs <= 2)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  assert((investment(List("IBM", "BIDU"), 2004 to 2008, 100) - 298).abs <= 10)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
}
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
Await.result(f, 180 second)
28c8e17ab83a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27