Skip to content

Commit

Permalink
Merge pull request #39 from TheCookieLab/defect/38/returnTradeHistory…
Browse files Browse the repository at this point in the history
…-error-parsing-date

Defect/38/return trade history error parsing date
  • Loading branch information
TheCookieLab authored Dec 22, 2021
2 parents 748c939 + 0f1215d commit 26de206
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ hs_err_pid*
/.settings/
/.classpath
/.project
/nbproject/
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PoloniexDataMapper {
private final Gson gson;

private final static Logger LOGGER = LogManager.getLogger();
private final static DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneOffset.UTC);
private final static DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[.n]").withZone(ZoneOffset.UTC);
private final static String EMPTY_RESULTS = "[]";
private final static String INVALID_CHART_DATA_DATE_RANGE_RESULT = "[{\"date\":0,\"high\":0,\"low\":0,\"open\":0,\"close\":0,\"volume\":0,\"quoteVolume\":0,\"weightedAverage\":0}]";
private final static String INVALID_CHART_DATA_CURRENCY_PAIR_RESULT = "{\"error\":\"Invalid currency pair.\"}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public void mapCancelOrderFailureReturnsFalse() {

@Test
public void mapBuyTradeOrder() {
String data = "{\"orderNumber\":31226040,\"resultingTrades\":[{\"amount\":\"338.8732\",\"date\":\"2014-10-18 23:03:21\",\"rate\":\"0.00000173\",\"total\":\"0.00058625\",\"tradeID\":\"16164\",\"type\":\"buy\"}]}";
String data = "{\"orderNumber\":31226040,\"resultingTrades\":[{\"amount\":\"338.8732\",\"date\":\"2021-10-23 19:32:05.000000\",\"rate\":\"0.00000173\",\"total\":\"0.00058625\",\"tradeID\":\"16164\",\"type\":\"buy\"}]}";
PoloniexOrderResult orderResult = mapper.mapTradeOrder(data);
assertEquals(31226040L, orderResult.orderNumber.longValue());
assertEquals(1, orderResult.resultingTrades.size());
assertEquals(BigDecimal.valueOf(338.8732), orderResult.resultingTrades.get(0).amount);
assertEquals("2014-10-18T23:03:21Z", orderResult.resultingTrades.get(0).date.toString());
assertEquals("2021-10-23T19:32:05Z", orderResult.resultingTrades.get(0).date.toString());
assertEquals(BigDecimal.valueOf(0.00000173), orderResult.resultingTrades.get(0).rate);
assertEquals(BigDecimal.valueOf(0.00058625), orderResult.resultingTrades.get(0).total);
assertEquals("16164", orderResult.resultingTrades.get(0).tradeID);
Expand Down

0 comments on commit 26de206

Please sign in to comment.