2019-01-01 부터시작

static int START = 1718616;

 static int MAX   = 2350000;

 static int STEP = 1000;

 static BufferedWriter writer = null;

 private static void setExcel() throws InvalidFormatException, InterruptedException {

  

  String domain = "https://www.bitmex.com/api/v1/trade/bucketed?binSize=1m&symbol=XBTUSD&count="+STEP+"&start=";

  try {

   URL u = null;

   HttpURLConnection con = null;

   System.out.println("시작");

    if(START > MAX) {

     System.out.println("종료");

    }else{

     u = new URL(domain+START);

     System.out.println(domain+START);

     con = (HttpURLConnection) u.openConnection();

     StringBuilder sb = new StringBuilder();

     if (con.getResponseCode() == HttpURLConnection.HTTP_OK) {

      BufferedReader br = new BufferedReader(

        new InputStreamReader(con.getInputStream(), "utf-8"));

      String line;

      while ((line = br.readLine()) != null) {

       sb.append(line+"\n");

      }

      

      br.close();

      bucketedVO[] vo = gson.fromJson(sb.toString(), bucketedVO[].class);

      ArrayList<bucketedVO> arrayList = new ArrayList<>(Arrays.asList(vo));

      

      for( bucketedVO item : arrayList) {

       String txt = item.getTimestamp()+"\t"+item.getOpen()+"\t"+item.getHigh()+"\t"+item.getLow()+"\t"+item.getClose()+"\n";

       writer.append(txt);

      }

      

      START = START+STEP;

      con.disconnect();

      Thread.sleep(3000);

      setExcel();

    } else {

     System.out.println(con.getResponseMessage());

    }

   }

  } catch (IOException e) {

   e.fillInStackTrace();

  }

 }


<dependencies>
  <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.17</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.17</version>
    </dependency>
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.6</version>
</dependency>
  </dependencies>
pom.xml