MCPcopy Index your code
hub / github.com/ccxt/ccxt / fetchOHLCV

Method fetchOHLCV

java/lib/src/main/java/io/github/ccxt/exchanges/CexCore.java:833–907  ·  view source on GitHub ↗

@method @name cex#fetchOHLCV @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market @see https://trade.cex.io/docs/#rest-public-api-calls-candles @param {string} symbol unified symbol of the market to fetch OHLCV data for @param {

(Object symbol, Object... optionalArgs)

Source from the content-addressed store, hash-verified

831 * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
832 */
833 public java.util.concurrent.CompletableFuture<Object> fetchOHLCV(Object symbol, Object... optionalArgs)
834 {
835
836 return java.util.concurrent.CompletableFuture.supplyAsync(() -> {
837
838 Object timeframe = Helpers.getArg(optionalArgs, 0, "1m");
839 Object since = Helpers.getArg(optionalArgs, 1, null);
840 Object limit = Helpers.getArg(optionalArgs, 2, null);
841 Object parameters = Helpers.getArg(optionalArgs, 3, new java.util.HashMap<String, Object>() {{}});
842 Object dataType = null;
843 var dataTypeparametersVariable = this.handleOptionAndParams(parameters, "fetchOHLCV", "dataType");
844 dataType = ((java.util.List<Object>) dataTypeparametersVariable).get(0);
845 parameters = ((java.util.List<Object>) dataTypeparametersVariable).get(1);
846 if (Helpers.isTrue(Helpers.isEqual(dataType, null)))
847 {
848 throw new ArgumentsRequired((String)Helpers.add(this.id, " fetchOHLCV requires a parameter \"dataType\" to be either \"bestBid\" or \"bestAsk\"")) ;
849 }
850 (this.loadMarkets()).join();
851 Object market = this.market(symbol);
852 final Object finalDataType = dataType;
853 Object request = new java.util.HashMap<String, Object>() {{
854 put( "pair", Helpers.GetValue(market, "id") );
855 put( "resolution", Helpers.GetValue(CexCore.this.timeframes, timeframe) );
856 put( "dataType", finalDataType );
857 }};
858 if (Helpers.isTrue(!Helpers.isEqual(since, null)))
859 {
860 Helpers.addElementToObject(request, "fromISO", this.iso8601(since));
861 }
862 Object until = null;
863 var untilparametersVariable = this.handleParamInteger2(parameters, "until", "till");
864 until = ((java.util.List<Object>) untilparametersVariable).get(0);
865 parameters = ((java.util.List<Object>) untilparametersVariable).get(1);
866 if (Helpers.isTrue(!Helpers.isEqual(until, null)))
867 {
868 Helpers.addElementToObject(request, "toISO", this.iso8601(until));
869 } else if (Helpers.isTrue(Helpers.isEqual(since, null)))
870 {
871 // exchange still requires that we provide one of them
872 Helpers.addElementToObject(request, "toISO", this.iso8601(this.milliseconds()));
873 }
874 if (Helpers.isTrue(Helpers.isTrue(Helpers.isTrue(!Helpers.isEqual(since, null)) && Helpers.isTrue(!Helpers.isEqual(until, null))) && Helpers.isTrue(!Helpers.isEqual(limit, null))))
875 {
876 throw new ArgumentsRequired((String)Helpers.add(this.id, " fetchOHLCV does not support fetching candles with both a limit and since/until")) ;
877 } else if (Helpers.isTrue(Helpers.isTrue((Helpers.isTrue(!Helpers.isEqual(since, null)) || Helpers.isTrue(!Helpers.isEqual(until, null)))) && Helpers.isTrue(Helpers.isEqual(limit, null))))
878 {
879 throw new ArgumentsRequired((String)Helpers.add(this.id, " fetchOHLCV requires a limit parameter when fetching candles with since or until")) ;
880 }
881 if (Helpers.isTrue(!Helpers.isEqual(limit, null)))
882 {
883 Helpers.addElementToObject(request, "limit", limit);
884 }
885 Object response = (this.publicPostGetCandles(this.extend(request, parameters))).join();
886 //
887 // {
888 // "ok": "ok",
889 // "data": [
890 // {

Callers

nothing calls this directly

Calls 15

getArgMethod · 0.95
isTrueMethod · 0.95
isEqualMethod · 0.95
addMethod · 0.95
GetValueMethod · 0.95
addElementToObjectMethod · 0.95
publicPostGetCandlesMethod · 0.65
handleOptionAndParamsMethod · 0.45
getMethod · 0.45
loadMarketsMethod · 0.45
marketMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected