progs/drumb.scala
author Christian Urban <urbanc@in.tum.de>
Wed, 09 Nov 2016 01:02:41 +0000
changeset 19 fa18976cf4cf
parent 18 87e55eb309ed
child 26 a7afc2540a88
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
// Advanvced Part 3 about Mr T. Drumb investing into stocks
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
//==========================================================
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
//two test portfolios
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
val blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "YHOO", "AMZN", "BIDU")
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
val rstate_portfolio = List("PLD", "PSA", "AMT", "AIV", "AVB", "BXP", "CBG", "CCI", 
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
                            "DLR", "EQIX", "EQR", "ESS", "EXR", "FRT", "GGP", "HCP") 
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    11
def get_yahoo_page(url: String): Option[List[String]] = ...
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    13
def get_first_price(symbol: String, year: Int): Option[Double] = ...
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    15
def get_prices(portfolio: List[String], years: Range): List[List[Option[Double]]] = ...
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    18
//val p = get_prices(List("GOOG", "AAPL"), 2010 to 2012)
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    21
def get_delta(price_old: Option[Double], price_new: Option[Double]): Option[Double] = ...
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    23
def get_deltas(data: List[List[Option[Double]]]):  List[List[Option[Double]]] = ...
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    25
//val d = get_deltas(p)
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    29
def yearly_yield(data: List[List[Option[Double]]], balance: Long, year: Int): Long = ... 
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    30
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    31
//yearly_yield(d, 100, 0)
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    32
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    33
def compound_yield(data: List[List[Option[Double]]], balance: Long, year: Int): Long = ... 
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    34
18
87e55eb309ed updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
19
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    36
def investment(portfolio: List[String], years: Range, start_balance: Long): Long = ...
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    37
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    38
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    39
//investment(rstate_portfolio, 1978 to 2016, 100)
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    40
//investment(blchip_portfolio, 1978 to 2016, 100)
fa18976cf4cf updated
Christian Urban <urbanc@in.tum.de>
parents: 18
diff changeset
    41