fix whitespace
This commit is contained in:
@ -22,6 +22,7 @@ public class App {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Config config = new Config();
|
||||||
Options options = getCommandlineOptions();
|
Options options = getCommandlineOptions();
|
||||||
try {
|
try {
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
@ -32,27 +33,33 @@ public class App {
|
|||||||
usage("Missing EPL file.", options);
|
usage("Missing EPL file.", options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TickStreamReader reader = null;
|
||||||
|
if (cmdline.hasOption("historical")) {
|
||||||
|
String csv = cmdline.getOptionValue("historical");
|
||||||
|
reader = new CSVReader(new File(csv));
|
||||||
|
log.info("Using CSV file {}", csv);
|
||||||
|
} else {
|
||||||
|
String[] instruments = getInstruments(cmdline);
|
||||||
|
reader = new OANDAReader(config, instruments);
|
||||||
|
log.info("Reading from stream.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String eplFile = extraArgs[0];
|
String eplFile = extraArgs[0];
|
||||||
TickProcessor processor = null;
|
TickProcessor processor = null;
|
||||||
try {
|
try {
|
||||||
String epl = readFile(eplFile);
|
String epl = readFile(eplFile);
|
||||||
processor = new EsperProcessor(epl);
|
processor = new EsperProcessor(epl, trader);
|
||||||
log.info("Using EPL file {}", eplFile);
|
log.info("Using EPL file {}", eplFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error reading EPL file {}", eplFile, e);
|
log.error("Error reading EPL file {}", eplFile, e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TickStreamReader reader = null;
|
|
||||||
if (cmdline.hasOption("historical")) {
|
|
||||||
String csv = cmdline.getOptionValue("historical");
|
|
||||||
reader = new CSVReader(new File(csv));
|
|
||||||
log.info("Using CSV file {}", csv);
|
|
||||||
String[] instruments = getInstruments(cmdline);
|
|
||||||
log.info("Reading from stream.");
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.run(processor);
|
reader.run(processor);
|
||||||
|
|
||||||
|
// TODO: wait for all scheduled esper handlers to fire before exiting.
|
||||||
|
//try { Thread.sleep(10 * 1000); } catch (InterruptedException e) {}
|
||||||
} catch(ParseException e) {
|
} catch(ParseException e) {
|
||||||
usage(e.getMessage(), options);
|
usage(e.getMessage(), options);
|
||||||
}
|
}
|
||||||
@ -118,6 +125,4 @@ public class App {
|
|||||||
formatter.printHelp("java -jar ATS_Esper-all.jar [args] rules.epl", options);
|
formatter.printHelp("java -jar ATS_Esper-all.jar [args] rules.epl", options);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
Config config = new Config();
|
|
||||||
reader = new OANDAReader(config, instruments);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class OANDAReader implements TickStreamReader {
|
public class OANDAReader implements TickStreamReader {
|
||||||
final Logger log = LoggerFactory.getLogger(OANDAReader.class);
|
final Logger log = LoggerFactory.getLogger(OANDAReader.class);
|
||||||
ObjectMapper mapper;
|
ObjectMapper mapper;
|
||||||
String[] instruments;
|
|
||||||
Config config;
|
Config config;
|
||||||
|
String[] instruments;
|
||||||
|
|
||||||
|
|
||||||
public OANDAReader(Config config, String[] instruments) {
|
public OANDAReader(Config config, String[] instruments) {
|
||||||
@ -38,6 +38,7 @@ public class OANDAReader implements TickStreamReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String streamURL() {
|
private String streamURL() {
|
||||||
|
String type = config.isLiveAccount() ? "fxlive" : "fxpractice";
|
||||||
String instrList = String.join(",", instruments);
|
String instrList = String.join(",", instruments);
|
||||||
String query = "";
|
String query = "";
|
||||||
try {
|
try {
|
||||||
@ -45,7 +46,6 @@ public class OANDAReader implements TickStreamReader {
|
|||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
log.error("Creating stream URL", e);
|
log.error("Creating stream URL", e);
|
||||||
}
|
}
|
||||||
String type = config.isLiveAccount() ? "fxlive" : "fxpractice";
|
|
||||||
|
|
||||||
return String.format("https://stream-%s.oanda.com/v3/accounts/%s/pricing/stream?%s",
|
return String.format("https://stream-%s.oanda.com/v3/accounts/%s/pricing/stream?%s",
|
||||||
type, config.accountID(), query);
|
type, config.accountID(), query);
|
||||||
@ -65,8 +65,8 @@ public class OANDAReader implements TickStreamReader {
|
|||||||
//httpConn.setInstanceFollowRedirects(true);
|
//httpConn.setInstanceFollowRedirects(true);
|
||||||
httpConn.setRequestMethod("GET");
|
httpConn.setRequestMethod("GET");
|
||||||
//httpConn.setReadTimeout(50 * 1000);
|
//httpConn.setReadTimeout(50 * 1000);
|
||||||
BufferedReader is =
|
|
||||||
httpConn.setRequestProperty("Authorization", "Bearer " + config.accessToken());
|
httpConn.setRequestProperty("Authorization", "Bearer " + config.accessToken());
|
||||||
|
BufferedReader is =
|
||||||
new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
|
new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
|
||||||
|
|
||||||
while ((line = is.readLine()) != null) {
|
while ((line = is.readLine()) != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user