Java SDK Code Samples


Check out our code sample

This zip file includes

  • EasyIn.java
  • Example1.java
  • Example2.java
  • LimitMapper.java
  • RateTicker.java
  • TrailingSL.java
  • Transfeed.java

EasyIn.java

Simple input from the keyboard for all primitive types.This is not thread safe, not high performance, and doesn’t tell EOF. It’s intended for low-volume easy keyboard input.

EasyIn easy = new EasyIn();
    int i = easy.readInt();   // reads an int from System.in
    float f = easy.readFloat();   // reads a float from System.in

Example1.java

Log in with your fxTrade Practice account to monitor your account and display account info every 5 seconds.

        System.out.println("CURRENT TRADES:");
        for (int i = 0; i < trades.size(); i++) {
            System.out.println(trades.elementAt(i));
        }
        System.out.println("CURRENT ACCOUNT INFO:");
        System.out.println("Balance: " + myaccount.getBalance());
        System.out.println("Realized PL: " + myaccount.getRealizedPL());
        System.out.println("Unrealized PL: " + myaccount.getUnrealizedPL());
        System.out.println("MarginUsed: " + myaccount.getMarginUsed());
        System.out.println("MarginAvailable: " + myaccount.getMarginAvailable());
        sleep(5000);

LimitMapper.java

LimitMapper is an FXTrade API example which detects the execution of limit orders and maps the resultant market orders back to the limit order that spawned it.