Skip to content

Commit

Permalink
fixes coinapi#132 by allowing to pass dates as string instead of inst…
Browse files Browse the repository at this point in the history
…ant for the java sdk because instant.now() might have higher precision the 7 on jdk > 8
  • Loading branch information
Roman Meier committed May 6, 2022
1 parent a6956f4 commit 61f2067
Showing 1 changed file with 92 additions and 3 deletions.
95 changes: 92 additions & 3 deletions data-api/java-rest/src/main/java/io/coinapi/rest/REST_methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,36 @@ public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_ident
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, String time_start) throws IOException {
String json = get_json("/v1/ohlcv/" + symbol_id + "/history?period_id=" + period_id + "&time_start=" + time_start);
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, Instant time_start, Instant time_end) throws IOException {
String json = get_json("/v1/ohlcv/" + symbol_id + "/history?period_id=" + period_id + "&time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, String time_start, String time_end) throws IOException {
String json = get_json("/v1/ohlcv/" + symbol_id + "/history?period_id=" + period_id + "&time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, Instant time_start, int limit) throws IOException {
String json = get_json("/v1/ohlcv/" + symbol_id + "/history?period_id=" + period_id + "&time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, String time_start, int limit) throws IOException {
String json = get_json("/v1/ohlcv/" + symbol_id + "/history?period_id=" + period_id + "&time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_timeseries(array);
}

public Timedata[] ohlcv_get_historical_timeseries(String symbol_id, Period_identifier period_id, Instant time_start, Instant time_end, int limit) throws IOException {
String json = get_json(
Expand Down Expand Up @@ -399,24 +417,48 @@ public Trade[] trades_get_historical_data(String symbol_id, Instant time_start)
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, String time_start) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, Instant time_start, int limit) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, String time_start, int limit) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, Instant time_start, Instant time_end) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, String time_start, String time_end) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, Instant time_start, Instant time_end, int limit) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Trade[] trades_get_historical_data(String symbol_id, String time_start, String time_end, int limit) throws IOException {
String json = get_json("/v1/trades/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_trades(array);
}

public Quote_with_trade[] quotes_get_for_all_symbols() throws IOException {
String json = get_json("/v1/quotes/current");
Expand Down Expand Up @@ -459,24 +501,47 @@ public Quote[] quotes_get_historical_data(String symbol_id, Instant time_start)
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, String time_start) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, Instant time_start, int limit) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}


public Quote[] quotes_get_historical_data(String symbol_id, String time_start, int limit) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, Instant time_start, Instant time_end) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, String time_start, String time_end) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, Instant time_start, Instant time_end, int limit) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Quote[] quotes_get_historical_data(String symbol_id, String time_start, String time_end, int limit) throws IOException {
String json = get_json("/v1/quotes/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_quotes(array);
}

public Orderbook[] orderbooks_get_for_all_symbols() throws IOException {
String json = get_json("/v1/orderbooks/current");
Expand Down Expand Up @@ -507,24 +572,48 @@ public Orderbook[] orderbooks_get_historical_data(String symbol_id, Instant time
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, String time_start) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, Instant time_start, int limit) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, String time_start, int limit) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, Instant time_start, Instant time_end) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}


public Orderbook[] orderbooks_get_historical_data(String symbol_id, String time_start, String time_end) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, Instant time_start, Instant time_end, int limit) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

public Orderbook[] orderbooks_get_historical_data(String symbol_id, String time_start, String time_end, int limit) throws IOException {
String json = get_json("/v1/orderbooks/" + symbol_id + "/history?time_start=" + time_start + "&time_end=" + time_end + "&limit=" + limit);
JSONArray array = new JSONArray(json);
return parse_orderbooks(array);
}

private int[] parse_int_array(JSONArray array) {
int[] result = new int[array.length()];
Expand Down

0 comments on commit 61f2067

Please sign in to comment.