fix whitespace
This commit is contained in:
@ -22,6 +22,7 @@ public class App {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Config config = new Config();
|
||||
Options options = getCommandlineOptions();
|
||||
try {
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
@ -32,27 +33,33 @@ public class App {
|
||||
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];
|
||||
TickProcessor processor = null;
|
||||
try {
|
||||
String epl = readFile(eplFile);
|
||||
processor = new EsperProcessor(epl);
|
||||
processor = new EsperProcessor(epl, trader);
|
||||
log.info("Using EPL file {}", eplFile);
|
||||
} catch (IOException e) {
|
||||
log.error("Error reading EPL file {}", eplFile, e);
|
||||
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);
|
||||
|
||||
// TODO: wait for all scheduled esper handlers to fire before exiting.
|
||||
//try { Thread.sleep(10 * 1000); } catch (InterruptedException e) {}
|
||||
} catch(ParseException e) {
|
||||
usage(e.getMessage(), options);
|
||||
}
|
||||
@ -118,6 +125,4 @@ public class App {
|
||||
formatter.printHelp("java -jar ATS_Esper-all.jar [args] rules.epl", options);
|
||||
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 {
|
||||
final Logger log = LoggerFactory.getLogger(OANDAReader.class);
|
||||
ObjectMapper mapper;
|
||||
String[] instruments;
|
||||
Config config;
|
||||
String[] instruments;
|
||||
|
||||
|
||||
public OANDAReader(Config config, String[] instruments) {
|
||||
@ -38,6 +38,7 @@ public class OANDAReader implements TickStreamReader {
|
||||
}
|
||||
|
||||
private String streamURL() {
|
||||
String type = config.isLiveAccount() ? "fxlive" : "fxpractice";
|
||||
String instrList = String.join(",", instruments);
|
||||
String query = "";
|
||||
try {
|
||||
@ -45,7 +46,6 @@ public class OANDAReader implements TickStreamReader {
|
||||
} catch (UnsupportedEncodingException 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",
|
||||
type, config.accountID(), query);
|
||||
@ -65,8 +65,8 @@ public class OANDAReader implements TickStreamReader {
|
||||
//httpConn.setInstanceFollowRedirects(true);
|
||||
httpConn.setRequestMethod("GET");
|
||||
//httpConn.setReadTimeout(50 * 1000);
|
||||
BufferedReader is =
|
||||
httpConn.setRequestProperty("Authorization", "Bearer " + config.accessToken());
|
||||
BufferedReader is =
|
||||
new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
|
||||
|
||||
while ((line = is.readLine()) != null) {
|
||||
|
||||
Reference in New Issue
Block a user