Skip to content

Forex (FX)

Defaults

interval: Interval.ONE_MIN
ouputSize: OutputSize.COMPACT
dataType: DataType.JSON

Intraday

Alphavantage.api()
    .forex()
    .intraday()
    .forSymbol("AAPL")
    .interval(Interval.THIRTY_MIN)
    .outputSize(OutputSize.FULL)
    .dataType(DataType.JSON)
    .onSuccess(e->onData(e.getForexUnits()))
    .fetch();

Daily

Alphavantage.api()
    .forex()
    .daily()
    .forSymbol("AAPL")
    .outputSize(OutputSize.FULL)
    .dataType(DataType.JSON)
    .onSuccess(e->onData(e.getForexUnits()))
    .fetch();

Weekly

Alphavantage.api()
    .forex()
    .weekly()
    .forSymbol("AAPL")
    .outputSize(OutputSize.FULL)
    .dataType(DataType.JSON)
    .onSuccess(e->onData(e.getForexUnits()))
    .fetch();

Monthly

Alphavantage.api()
    .forex()
    .monthly()
    .forSymbol("AAPL")
    .outputSize(OutputSize.FULL)
    .dataType(DataType.JSON)
    .onSuccess(e->onData(e.getForexUnits()))
    .fetch();

Response Type: ForexResponse

Response

public void onData(List<ForexUnit> forexUnits){
    stockUnits.stream().forEach(u -> {
        System.out.println(u.getHigh());
        System.out.println(u.getLow());
        System.out.println(u.getOpen());
        System.out.println(u.getClose());
        System.out.println(u.getDate());
   })
}