import com.jfx.*; import com.jfx.strategy.Strategy; import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; public class HCollector extends Strategy { public void coordinate() { Timeframe timeFrame = Timeframe.PERIOD_M1; ArrayList syms = getSymbols(); for (int i = 0; i < syms.size(); i++) { String symbol = syms.get(i); try { int bars = iBarShift(symbol, timeFrame, Timestamp.valueOf("1990-01-01 00:00:00.0"), false); System.out.println("" + symbol + ": bars=" + bars); long t1 = System.currentTimeMillis(); for (int shift = bars/* - 1*/; shift >= 0; shift--) { try { double o = iOpen(symbol, timeFrame, shift); double c = iClose(symbol, timeFrame, shift); double h = iHigh(symbol, timeFrame, shift); double l = iLow(symbol, timeFrame, shift); double v = iVolume(symbol, timeFrame, shift); Date t = iTime(symbol, timeFrame, shift); // String msg = ("" + t + ',' + h + ',' + o + ',' + c + ',' + l + ',' + v + "\n"); System.out.println(""+ msg); } catch (ErrHistoryWillUpdated errHistoryWillUpdated) { //noinspection EmptyCatchBlock try { Thread.sleep(1000); } catch (InterruptedException e) { } shift++; } } long t2 = System.currentTimeMillis(); System.out.println("" + symbol + ": bps=" + Math.round(bars / (((double) (t2 - t1)) / 1000.0))); } catch (ErrHistoryWillUpdated errHistoryWillUpdated) { //noinspection EmptyCatchBlock try { Thread.sleep(1000); } catch (InterruptedException e) { } i--; } catch (ErrUnknownSymbol errUnknownSymbol) { errUnknownSymbol.printStackTrace(); } catch (ErrIncorrectSeriesarrayUsing errIncorrectSeriesarrayUsing) { //errIncorrectSeriesarrayUsing.printStackTrace(); } } try { disconnect(); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) throws IOException, InterruptedException { String terminalServerIpAddress = "127.0.0.1"; HCollector hCollector = new HCollector(); hCollector.connect(terminalServerIpAddress, 7788, Broker.AlpariUS_Demo, "1058553", "r7etsoo"); Thread.sleep(1000000); hCollector.disconnect(); } }