main_templates1/drumb.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 15 Jan 2023 10:58:13 +0000
changeset 462 34feeb53c0ba
parent 428 cdfa6a293453
child 470 86a456f8cb92
permissions -rw-r--r--
updated

// Main Part 1 about a really dumb investment strategy
//===================================================

object M1 {

//two test portfolios

val blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "AMZN", "BIDU")
val rstate_portfolio = List("PLD", "PSA", "AMT", "AIV", "AVB", "BXP", "CCI", 
                            "DLR", "EQIX", "EQR", "ESS", "EXR", "FRT", "HCP") 

import io.Source
import scala.util._

// ADD YOUR CODE BELOW
//======================


// (1) 
def get_january_data(symbol: String, year: Int) : List[String] = ???


// (2) 
def get_first_price(symbol: String, year: Int) : Option[Double] = ???


// (3) 
def get_prices(portfolio: List[String], years: Range) : List[List[Option[Double]]] = ???



// (4) 
def get_delta(price_old: Option[Double], price_new: Option[Double]) : Option[Double] = ???



// (5) 
def get_deltas(data: List[List[Option[Double]]]) :  List[List[Option[Double]]] = ???

// (6) 
def yearly_yield(data: List[List[Option[Double]]], balance: Long, index: Int) : Long = ???


// (7) 
def compound_yield(data: List[List[Option[Double]]], balance: Long, index: Int) : Long = ???

def investment(portfolio: List[String], years: Range, start_balance: Long) : Long = ???




//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))


}