Ejemplo n.º 1
0
 public void report(List<String> headers) {
   StringBuilder sb = new StringBuilder();
   sb.append(ROW_START);
   for (String column : headers) {
     sb.append(FIELD_START).append(column).append(FIELD_END);
   }
   sb.append(ROW_END);
   write(sb);
 }
Ejemplo n.º 2
0
  public void write(long time, Instrument instrument1, Instrument instrument2) {
    double bid1 = instrument1.getBid();
    double ask1 = instrument1.getAsk();
    double bid2 = instrument2.getBid();
    double ask2 = instrument2.getAsk();

    if (bid1 > 0 && ask1 > 0 && bid2 > 0 && ask2 > 0) {
      StringBuilder sb = new StringBuilder();
      sb.append(dateFormat.format(new Date(time))).append(",");
      sb.append(decimalFormat.format(bid1)).append(",");
      sb.append(decimalFormat.format(ask1)).append(",");
      sb.append(decimalFormat.format(bid2)).append(",");
      sb.append(decimalFormat.format(ask2));

      writer.println(sb);
      writer.flush();
    }
  }
Ejemplo n.º 3
0
 private StringBuilder getHeader(String symbol1, String symbol2) {
   StringBuilder header = new StringBuilder();
   String appInfo = JArbitrager.APP_NAME + ", version " + JArbitrager.VERSION;
   header.append("# This historical data file was created by ").append(appInfo).append(LINE_SEP);
   header
       .append("# Each line represents a 1-second snapshot of the market and contains ")
       .append(BackTestFileReader.COLUMNS)
       .append(" columns:")
       .append(LINE_SEP);
   header.append("# 1. date in the MMddyy format").append(LINE_SEP);
   header.append("# 2. time in the HHmmss format").append(LINE_SEP);
   header.append("# 3. best bid for the first instrument").append(LINE_SEP);
   header.append("# 4. best ask for the first instrument").append(LINE_SEP);
   header.append("# 5. best bid for the second instrument").append(LINE_SEP);
   header.append("# 6. best ask for the second instrument").append(LINE_SEP);
   header.append(LINE_SEP);
   header.append("instruments=").append(symbol1).append(",").append(symbol2).append(LINE_SEP);
   header.append("timeZone=").append(dateFormat.getTimeZone().getID()).append(LINE_SEP);
   return header;
 }
Ejemplo n.º 4
0
 public void reportDescription(String message) {
   StringBuilder sb = new StringBuilder();
   sb.append(message).append(FIELD_BREAK);
   write(sb);
 }