Originally posted by Lightship


public class ClientTester {
private static List accounts = new ArrayList();
private static String accountMassID;
private static String openOrderMassID;
private static String openPositionMassID;
private static String closedPositionMassID;
private static String tradingSessionStatusID;
private static TradingSessionStatus tradingSessionStatus;
private static boolean printMarketData = false;
public static void main(final String[] args) {
System.out.println("startctc");
// step 1: get an instance of IGateway from the GatewayFactory
final IGateway fxcmGateway = GatewayFactory.createGateway();
/*
step 2: register a generic message listener with the gateway, this
listener in particular gets all messages that are related to the trading
platform MarketDataSnapshot,OrderSingle,ExecutionReport, etc...
*/
fxcmGateway.registerGenericMessageListener(new IGenericMessageListener() {
public void messageArrived(ITransportable message) {
if (message instanceof MarketDataSnapshot) {
MarketDataSnapshot incomingQuote = (MarketDataSnapshot) message;
if (printMarketData || incomingQuote.getMDReqID() != null) {
try {
ConnectDB conn = new ConnectDB();
String sql = null;
conn.insert(sql);
sql = "INSERT INTO Sample5 (`QuoteID`, `Symbol`, `BidPx`, `OfferPx`, `TimeStamp`) VALUES ('" + incomingQuote.getQuoteID() + "','" + incomingQuote.getInstrument().getSymbol() + "','" + incomingQuote.getAskOpen() + "','" + incomingQuote.getBidOpen() + "','" + incomingQuote.getOpenTimestamp() + "')";

Leave a comment: