equal
deleted
inserted
replaced
1 // Core Part 6 about a really dumb investment strategy |
1 // Main Part 1 about a really dumb investment strategy |
2 //===================================================== |
2 //===================================================== |
3 |
3 |
4 |
4 |
5 // generate jar with |
5 // generate jar with |
6 // > scala -d drumb.jar drumb.scala |
6 // > scala -d drumb.jar drumb.scala |
7 |
7 |
8 |
8 |
9 object CW6b { |
9 object M1 { |
10 |
10 |
11 |
11 |
12 //two test portfolios |
12 //two test portfolios |
13 |
13 |
14 val blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "AMZN", "BIDU") |
14 val blchip_portfolio = List("GOOG", "AAPL", "MSFT", "IBM", "FB", "AMZN", "BIDU") |
165 compound_yield(get_deltas(get_prices(portfolio, years)), start_balance, 0) |
165 compound_yield(get_deltas(get_prices(portfolio, years)), start_balance, 0) |
166 } |
166 } |
167 |
167 |
168 |
168 |
169 |
169 |
170 |
|
171 investment(List("AAPL"), 2000 to 2001, 100) |
|
172 val aapl_prices = get_prices(List("AAPL"), 2000 to 2002) |
|
173 val aapl_deltas = get_deltas(aapl_prices) |
|
174 |
|
175 //test cases for the two portfolios given above |
170 //test cases for the two portfolios given above |
176 |
171 |
177 //println("Real data: " + investment(rstate_portfolio, 1978 to 2019, 100)) |
172 println("Real data: " + investment(rstate_portfolio, 1978 to 2019, 100)) |
178 //println("Blue data: " + investment(blchip_portfolio, 1978 to 2019, 100)) |
173 println("Blue data: " + investment(blchip_portfolio, 1978 to 2019, 100)) |
|
174 |
179 |
175 |
180 } |
176 } |
181 |
177 |
182 |
178 |
183 |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |