aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/edu/brown/cs/student/term/profit/ProfitCalculation.java1
-rw-r--r--src/test/java/edu/brown/cs/student/ProfitCalculationTest.java12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/edu/brown/cs/student/term/profit/ProfitCalculation.java b/src/main/java/edu/brown/cs/student/term/profit/ProfitCalculation.java
index fe12612..77c1c3a 100644
--- a/src/main/java/edu/brown/cs/student/term/profit/ProfitCalculation.java
+++ b/src/main/java/edu/brown/cs/student/term/profit/ProfitCalculation.java
@@ -251,6 +251,7 @@ public class ProfitCalculation {
JSONArray object = new JSONObject(response.body()).getJSONArray(ticker);
try {
double endPrice = object.getJSONObject(object.length() - 1).getDouble("c");
+ currentStockPrices.put(ticker, endPrice);
return endPrice;
} catch (JSONException e) {
currentStockPrices.put(ticker, -1.0);
diff --git a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
index f435c7c..a4baa53 100644
--- a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
+++ b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
@@ -56,13 +56,17 @@ public class ProfitCalculationTest {
//price of GME at end time is 154.69
List<StockHolding> trade = profitCalculation.getHoldingsList();
//buy with no sell
- assertEquals(trade.get(0).getUnrealizedGain(), 3842.25,.25);
+ assertEquals(trade.get(0).getUnrealizedGain(), 3842.25, .25);
assertEquals(trade.get(0).getRealizedGain(), 0, .01);
+ }
+
+ public void checkAPICalls() {
+ ProfitCalculation profitCalculation =
+ new ProfitCalculation(DatabaseQuerier.getConn(), "Don", new Date(1618234200000l),
+ new Date(1618814264000l));
- profitCalculation = new ProfitCalculation(DatabaseQuerier.getConn(), "Don", new Date(1618234200000l),
- new Date(1618814264000l));
-
+ //check sp500 calculation. 411.28 to 417.30
assertEquals(profitCalculation.compareToSP500(), .01464, .001);
}