61 ### get january data |
61 ### get january data |
62 |
62 |
63 if [ $tsts -eq 0 ] |
63 if [ $tsts -eq 0 ] |
64 then |
64 then |
65 echo " get_january_data(\"GOOG\", 1980) == List()" >> $out |
65 echo " get_january_data(\"GOOG\", 1980) == List()" >> $out |
66 echo " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,311.349976\"" >> $out |
66 echo " get_january_data(\"GOOG\", 2010).head == \"2010-01-04,312.204773\"" >> $out |
67 |
67 |
68 if (scala_assert "drumb.scala" "drumb_test1.scala") |
68 if (scala_assert "drumb.scala" "drumb_test1.scala") |
69 then |
69 then |
70 echo " --> success" >> $out |
70 echo " --> success" >> $out |
71 else |
71 else |
72 echo " --> test failed" >> $out |
72 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
73 fi |
73 fi |
74 fi |
74 fi |
75 |
75 |
76 ### get first price |
76 ### get first price |
77 |
77 |
78 if [ $tsts -eq 0 ] |
78 if [ $tsts -eq 0 ] |
79 then |
79 then |
80 echo " get_first_price(\"GOOG\", 1980) == None" >> $out |
80 echo " get_first_price(\"GOOG\", 1980) == None" >> $out |
81 echo " get_first_price(\"GOOG\", 2010) == Some(311.349976)" >> $out |
81 echo " get_first_price(\"GOOG\", 2010) == Some(312.204773)" >> $out |
82 |
82 |
83 if (scala_assert "drumb.scala" "drumb_test2.scala") |
83 if (scala_assert "drumb.scala" "drumb_test2.scala") |
84 then |
84 then |
85 echo " --> success" >> $out |
85 echo " --> success" >> $out |
86 else |
86 else |
87 echo " --> test failed" >> $out |
87 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
88 fi |
88 fi |
89 fi |
89 fi |
90 |
90 |
91 ### get prices tests |
91 ### get prices tests |
92 |
92 |
93 if [ $tsts -eq 0 ] |
93 if [ $tsts -eq 0 ] |
94 then |
94 then |
95 echo " get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" >> $out |
95 echo " get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012) ==" >> $out |
96 echo " List(List(Some(311.349976), Some(20.544939))," >> $out |
96 echo " List(List(Some(311.349976), Some(20.544939))," >> $out |
97 echo " List(Some(300.222351), Some(31.638695))," >> $out |
97 echo " List(Some(300.222351), Some(31.638695))," >> $out |
98 echo " List(Some(330.555054), Some(39.478039)))" >> $out |
98 echo " List(Some(330.555054), Some(39.478039))))" >> $out |
99 |
99 |
100 if (scala_assert "drumb.scala" "drumb_test3.scala") |
100 if (scala_assert "drumb.scala" "drumb_test3.scala") |
101 then |
101 then |
102 echo " --> success" >> $out |
102 echo " --> success" >> $out |
103 else |
103 else |
104 echo " --> test failed" >> $out |
104 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
105 fi |
105 fi |
106 fi |
106 fi |
107 |
107 |
|
108 ### get_delta_test |
|
109 |
|
110 if [ $tsts -eq 0 ] |
|
111 then |
|
112 echo " get_delta(None, None) == None" >> $out |
|
113 echo " get_delta(Some(50.0), None) == None" >> $out |
|
114 echo " get_delta(None, Some(100.0)) == None" >> $out |
|
115 echo " get_delta(Some(50.0), Some(100.0)) == Some(1.0)" >> $out |
|
116 |
|
117 if (scala_assert "drumb.scala" "drumb_test4.scala") |
|
118 then |
|
119 echo " --> success" >> $out |
|
120 else |
|
121 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
|
122 fi |
|
123 fi |
|
124 |
|
125 |
108 ### get_deltas_test |
126 ### get_deltas_test |
109 |
127 |
110 #if [ $tsts -eq 0 ] |
128 if [ $tsts -eq 0 ] |
111 #then |
129 then |
112 # echo " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " >> $out |
130 echo -e " get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012)) == " >> $out |
113 # echo " List(List(Some(-0.03573992567129673), Some(0.5399749442411563)), " >> $out |
131 echo -e " List(List(Some(-0.03573991804411003), Some(0.539974575389325)), " >> $out |
114 # echo " List(Some(0.10103412653643493), Some(0.2477771728154912)))" >> $out |
132 echo -e " List(Some(0.10103414222249969), Some(0.24777764141006836)))" >> $out |
115 # |
133 echo -e "" >> $out |
116 # if (scala_assert "drumb.scala" "drumb_test2.scala") |
134 echo -e " get_deltas(get_prices(List(\"BIDU\"), 2004 to 2008)) == " >> $out |
117 # then |
135 echo -e " List(List(None), List(None), " >> $out |
118 # echo " --> success" >> $out |
136 echo -e " List(Some(0.9277165354330709)), List(Some(2.119679764725104)))) " >> $out |
119 # else |
137 |
120 # echo " --> test failed" >> $out |
138 if (scala_assert "drumb.scala" "drumb_test5.scala") |
121 # fi |
139 then |
122 #fi |
140 echo " --> success" >> $out |
|
141 else |
|
142 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
|
143 fi |
|
144 fi |
123 |
145 |
124 |
146 |
125 ### yield_tests, investment_test |
147 ### yield_tests |
126 |
148 |
127 #if [ $tsts -eq 0 ] |
149 if [ $tsts -eq 0 ] |
128 #then |
150 then |
129 # echo " yearly_yield(get_deltas(<<GOOG+AAPL 2010 - 2012>>), 100, 0) == 125" >> $out |
151 echo -e " val ds = get_deltas(get_prices(List(\"GOOG\", \"AAPL\"), 2010 to 2012))" >> $out |
130 # echo "" >> $out |
152 echo -e " yearly_yield(get_deltas(ds, 100, 0)) == 125" >> $out |
131 # echo " investment(rstate_portfolio, 1978 to 2017, 100) == 30895" >> $out |
153 echo -e " yearly_yield(get_deltas(ds, 100, 1)) == 117" >> $out |
132 # echo " investment(bchips_portfolio, 1978 to 2017, 100) == 349597" >> $out |
154 |
133 # |
155 if (scala_assert "drumb.scala" "drumb_test6.scala") |
134 # if (scala_assert "drumb.scala" "drumb_test3.scala") |
156 then |
135 # then |
157 echo " --> success" >> $out |
136 # echo " --> success" >> $out |
158 else |
137 # else |
159 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
138 # echo " --> test failed" >> $out |
160 fi |
139 # fi |
161 fi |
140 #fi |
|
141 |
162 |
|
163 |
|
164 ### investment_test |
|
165 |
|
166 if [ $tsts -eq 0 ] |
|
167 then |
|
168 echo -e " All results need to be in the range of -/+ 1% of the given values." >> $out |
|
169 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2000, 100) == 100" >> $out |
|
170 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2001, 100) == 27 " >> $out |
|
171 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2002, 100) == 42 " >> $out |
|
172 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2003, 100) == 27 " >> $out |
|
173 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2004, 100) == 38 " >> $out |
|
174 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2005, 100) == 113" >> $out |
|
175 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2006, 100) == 254" >> $out |
|
176 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 2000 to 2007, 100) == 349" >> $out |
|
177 echo -e " investment(List(\"GOOG\", \"AAPL\", \"BIDU\"), 1990 to 2017, 100) == 11504" >> $out |
|
178 |
|
179 |
|
180 if (scala_assert "drumb.scala" "drumb_test7.scala") |
|
181 then |
|
182 echo " --> success" >> $out |
|
183 else |
|
184 echo " --> ONE OF THE TESTS FAILED\n" >> $out |
|
185 fi |
|
186 fi |
|
187 |