equal
deleted
inserted
replaced
103 def get_deltas(data: List[List[Option[Double]]]): List[List[Option[Double]]] = |
103 def get_deltas(data: List[List[Option[Double]]]): List[List[Option[Double]]] = |
104 for (i <- (0 until (data.length - 1)).toList) yield |
104 for (i <- (0 until (data.length - 1)).toList) yield |
105 for (j <- (0 until (data(0).length)).toList) yield get_delta(data(i)(j), data(i + 1)(j)) |
105 for (j <- (0 until (data(0).length)).toList) yield get_delta(data(i)(j), data(i + 1)(j)) |
106 |
106 |
107 |
107 |
|
108 |
108 // test case using the prices calculated above |
109 // test case using the prices calculated above |
109 //val d = get_deltas(p) |
110 //val d = get_deltas(p) |
110 //val ttd = get_deltas(tt) |
111 //val ttd = get_deltas(tt) |
111 |
112 |
112 |
113 |
121 else { |
122 else { |
122 val portion: Double = balance.toDouble / somes_length.toDouble |
123 val portion: Double = balance.toDouble / somes_length.toDouble |
123 balance + (for (x <- somes) yield (x * portion)).sum.toLong |
124 balance + (for (x <- somes) yield (x * portion)).sum.toLong |
124 } |
125 } |
125 } |
126 } |
|
127 |
|
128 |
|
129 yearly_yield(get_prices(rstate_portfolio, 2016 to 2018), 100, 2) |
|
130 get_prices(rstate_portfolio, 2016 to 2018)(2).flatten.sum |
126 |
131 |
127 |
132 |
128 // (7) Write a function compound_yield that calculates the overall balance for a |
133 // (7) Write a function compound_yield that calculates the overall balance for a |
129 // range of years where in each year the yearly profit is compounded to the new |
134 // range of years where in each year the yearly profit is compounded to the new |
130 // balances and then re-invested into our portfolio. For this use the function and |
135 // balances and then re-invested into our portfolio. For this use the function and |