GMapsFX 2.0.6 Released

A new version of GMapsFX has been released to bintray and Maven Central which contains

  • additional bug fixes related to hiding/showing the directions pane at runtime.
  • Ability to pass the map/directions language to the Google map at runtime, eliminating the need to hardcode it.

Screen Shot 2016-05-20 at 2.25.33 PM.png

<dependency> 
  <groupId>com.lynden</groupId> 
  <artifactId>GMapsFX</artifactId> 
  <version>2.0.6</version> 
</dependency>

 

GMapsFX Home: http://rterp.github.io/GMapsFX/
twitter: @RobTerpilowski

GMapsFX 2.0.4 Released

A minor update of GMapsFX has been released this week which provides a bugfix for an issue that was preventing the GMapsFX GoogleMapView component from being loaded into Scene Builder under certain circumstances.

The release number is 2.0.4 and is currently available from BinTray, and hopefully should be available via Maven Central in the next couple of days.

twitter: @RobTerpilowski
LinkedIn: RobTerpilowski

 

Screen Shot 2016-03-18 at 3.40.46 PM

 

 

GMapsFX 2.0.3 Released With Support for Directions, Elevation, and Geocoding APIs

I have just released version 2.0.3 which includes support for the following major new features:

Directions API
Elevation API
Geocoding API

http://rterp.github.io/GMapsFX/

Below is an example of a JavaFX application displaying a Google map with directions, utilizing the Directions API.

Screen Shot 2016-03-18 at 3.40.46 PM.png

This release has been uploaded to bintray, and should hopefully be available on maven central by next week.

Blog posts to follow this one with tutorials on how to use each one of these new APIs.

https://bintray.com/artifact/download/rterp/maven/com/lynden/GMapsFX/2.0.3/GMapsFX-2.0.3.jar

twitter: @RobTerpilowski
LinkedIn: RobTerpilowski

 

Placing Trades with Interactive Brokers using the SumZero Trading API

Placing trades through Interactive Brokers using the SumZero Trading API is a relatively straightforward task, with support for Equity, Futures, and Foreign Exchange orders.  A few examples are below that illustrate how to place orders for the various markets as well as screenshots of Interactive Brokers Trader Workstation (TWS), which is their desktop trading client.  The API interacts with Trader Workstation, and when a trade is placed via the API, the trade will then appear in Trader Workstation where it is routed to Interactive Brokers, and then on to its specified exchange.

 

Equity Order

In the equity order example below, a connection to the Interactive Brokers client is obtained, which is running on the localhost at port 7999.

A StockTicker object is constructed for Amazon (ticker AMZN), the SumZero library initializes default properties for the ticker such as which exchange to route to.

The next order ID is obtained from the broker, and a TradeOrder object is constructed, specifying the orderId, the ticker symbol for the order, the number of shares, and whether this is a buy or sell order.

The order is then placed with the Interactive Brokers client.

If no other parameters are specified on the order, it is assumed to be a market order which will be placed in the market immediately after it is passed to the broker.

In the example below, we are placing a market order to sell 500 shares of Amazon.


public void placeEquityOrder() {
InteractiveBrokersClientInterface ibClient = InteractiveBrokersClient.getInstance("localhost", 7999, 1);
ibClient.connect();
StockTicker amazonTicker = new StockTicker("AMZN");
String orderId = ibClient.getNextOrderId();
int shares = 500;
TradeOrder order = new TradeOrder(orderId, amazonTicker, shares, TradeDirection.SELL);
ibClient.placeOrder(order);
}

view raw

StockTrade.java

hosted with ❤ by GitHub

 

Below is a screen shot of Interactive Brokers Trader Workstation.  There is a line with price information for Amazon stock (AMZN), showing a bid price of $559.02 and an ask of $559.80.  In the line immediately below, the order is visible which was placed by the code above.  A market order to sell 500 shares of Amazon.

 

AMZN

 

Futures Order

Submitting orders for the futures markets is very similar to the equity markets, except a few more parameters need to be specified when building a ticker, such as what month and year that desired futures contract is expiring.

In the example below, we build a new FuturesTicker object for crude oil, specifying the symbol “CL”, and a contract expiration of April 2016.  Also, the exchange needs to be specified for futures, which in this case is NYMEX.

From this point on, the order process is exactly the same as the previous example.  This time however, we’ll place a limit order to buy 5 contracts at $32.50, meaning that the price needs to come down to at least $32.50 for the trade to be executed.


public void placeFuturesOrder() {
InteractiveBrokersClientInterface ibClient = InteractiveBrokersClient.getInstance("localhost", 7999, 1);
ibClient.connect();
//Create a crude oil futures ticker
FuturesTicker futuresTicker = new FuturesTicker();
futuresTicker.setSymbol("CL");
futuresTicker.setExpiryMonth(4);
futuresTicker.setExpiryYear(2016);
futuresTicker.setExchange(Exchange.NYMEX);
String orderId = ibClient.getNextOrderId();
int contracts = 5;
//Create the order and send to Interactive Brokers
TradeOrder order = new TradeOrder(orderId, futuresTicker, contracts, TradeDirection.BUY);
order.setType(TradeOrder.Type.LIMIT);
order.setLimitPrice(32.50);
ibClient.placeOrder(order);
}

 

The result of the example is illustrated in the screenshot of TWS below.  There is a line corresponding to April 2016 Crude Oil, (CL Apr’16 @NYMEX), which shows a bid price of $33.22 and ask of $33.23.  On the line immediately below, the order that was submitted by the program above is shown.  Buy 5 contracts at a limit price of $32.50.

CL

 

Foreign Exchange Order

Finally, in the last example I’ll show how to place an order for foreign currencies through the API.

Again, the general process is the same as above, in this example we’ll construct an order to buy 50,000 Euros.

The symbol for the currency ticker is “EUR”, and the underlying currency needs to be set to “USD”.  The exchange where currency trades are executed at Interactive Brokers is “IDEALPRO”.  The amount of the order is set to 50000, and the TradeOrder object is constructed to buy at the market price.


public void placeCurrencyOrder() {
InteractiveBrokersClientInterface ibClient = InteractiveBrokersClient.getInstance("localhost", 7999, 1);
ibClient.connect();
CurrencyTicker eurTicker = new CurrencyTicker();
eurTicker.setSymbol("EUR");
eurTicker.setCurrency("USD");
eurTicker.setExchange(Exchange.IDEALPRO);
String orderId = ibClient.getNextOrderId();
int amount = 50000;
TradeOrder order = new TradeOrder(orderId, eurTicker, amount, TradeDirection.BUY);
ibClient.placeOrder(order);
}

view raw

FxOrder.java

hosted with ❤ by GitHub

 

 

The TWS screenshot below shows the EUR row denoted by “EUR.USD”, with a bid and ask price of $1.08695.  The row immediately below shows our order to buy 50,000 EUR at the market price, routed to IDEALPRO

EUR

 

These were some simple examples of various order types that can be submitted to buy/sell equities, futures, and currencies at Interactive Brokers.  More complex order types such as OCO, OSO, FOK, MOC, etc. are possible with the SumZero API, and will be shown in future posts.

twitter: @RobTerpilowski
twitter: @SumZeroTrading
LinkedIn: Rob Terpilowski

 

 

 

JavaFX vs. Swing vs. HTML5, Who Wins? – My Interview with Alexander Casall

In November 2015 Dirk Lemmermann (Freelancer) and Alexander Casall of Saxonia Systems had a JavaOne session about JavaFX Real World Applications. The article 20 JavaFX real-world applications summarizes the presentation by showing the applications that they’ve talked about. In addition to providing example applications for the article, I was interviewed by Alexander to get my thoughts on JavaFX and desktop development in general. The interview appears below.

Can you tell us about the highlights when you used JavaFX?

The animated transitions and effects such as blurring or drop shadows make a huge difference in the user experience of the application when implemented properly. These are small details that sometimes get glossed over, but when introduced to an application can create a very polished UI.  The effects and transitions were something that were possible to do with Swing, but it was so painful.  I don’t remember how many times I had to override the paintComponent() method to customize the look of a particular component, but all of this is baked into the JavaFX framework, allowing you to do these things in literally a few lines of code.

What is your general opinion about JavaFX?

Overall I am pleased with JavaFX as a successor to Swing.  The addition of property bindings, which eliminate the need for event listeners in many circumstances helps cut down on some of the code complexity.  I also like the fact that there is a very clear seperation between the model, view, and controller, where the view is FXML, the model can be a collection of JavaFX properties, and the controller utilizes dependency injection to have the UI components passed in.  There are some nice tools for doing JavaFX development, including NetBeans for coding, SceneBuilder as a WYSIWYG design tool and ScenicView to help visual provide information about the application while it is running.

JavaFX, Swing, SWT, HTML5 – Who wins – or better, when to use what?

For a new application I would not consider Swing or SWT, which leaves either JavaFX or HTML5 as the remaining options.  In this case there is not a clear winner, but a set of tradeoffs one needs to consider when making a decision.  With HTML5 you have the advantage of being able to deploy your application across many different platforms (phones, tablets, and Desktops), as well as multiple OSs (Windows, Mac, Linux).  There is also the benefit of a huge development community and large selection of open source tools and frameworks.  The ease of deployment across platforms comes at a cost however, in that you must operate within the constraints that are placed on you by the browser. The amount of time debugging issues across different browsers or OSs is often overlooked or underestimated by teams when deciding whether or not to go the desktop or web app route.  We recently worked on a project where a very large chunk of time had been consumed in order to get a piece of functionality working correctly in IE 9 on Windows.With JavaFX the drawback is that the user has to download and install something to their desktop, which is becoming very old fashioned.  But if this is not an issue, then you are free to develop outside the constraints of the browser and use the full power of the Java language and the eco system that backs it.For applications that are used internally within the company I feel that it makes a lot of sense to deploy these at desktop applications for this reason.  Deployments are not an issue in this case as we can automatically push out new installations or updates to PCs in our network automatically.  We also bundle a private JRE with the application so we don’t need to worry about which version(s) of Java the user has installed on their PC.

How satisfied are you with the work of Oracle on JavaFX?

Jonathan Giles and his team have been doing great work at Oracle adding improving and enhancing the JavaFX libraries.  That being said, it would be nice if Oracle officially stated what their long term plans are with JavaFX.  When Oracle let go of some of their evangelists (who were big proponents of JavaFX), just before JavaOne it started a rumor mill of what may have been behind the move.  The uncertainty this has created, and lack of official communication from Oracle will likely deter some development teams who may be on the fence about whether they should port legacy Swing application to JavaFX or HTML5. Over time this will potentially affect how large the JavaFX community eventually becomes.

What do you miss in the work with JavaFX?

The amount of 3rd party component libraries (both open source and commercial) that are available for JavaFX is still somewhat limited at this point, but that should change as the JavaFX community continues to grow.

 

twitter: @RobTerpilowski
LinkedIn: Rob Terpilowski

Subscribing to Real-Time Market Data With Interactive Brokers Using the SumZero Trading API

Connecting to Interactive Brokers to receive streaming real-time market data is easy with the SumZero Trading API.  This example will illustrate how to connect to an Interactive Brokers TraderWorkstation (TWS) or IB Gateway instance in order to obtain quotes for Amazon.


import com.sumzerotrading.data.StockTicker;
import com.zerosumtrading.interactive.brokers.client.InteractiveBrokersClient;
import com.sumzerotrading.marketdata.ILevel1Quote;
import com.sumzerotrading.marketdata.QuoteType;
public class MarketDataStocksExample {
public void start() {
InteractiveBrokersClient ibClient = new InteractiveBrokersClient("localhost", 6468, 1);
ibClient.connect();
StockTicker stockTicker= new StockTicker("AMZN");
ibClient.subscribeLevel1(stockTicker, (ILevel1Quote quote) -> {
if( quote.getType().equals(QuoteType.LAST) ){
System.out.println("Received Quote: " + quote.getValue() );
}
});
}
public static void main(String[] args) {
new MarketDataStocksExample().start();
}
}

The first step is to create a new InteractiveBrokersClient object passing in the hostname that TWS or IB Gateway is running on, the port that is listening on, as well as a client ID for the connection.  All connections to Interactive Brokers require a client ID which must be unique for each application that connects via the API.

Once the connection is established a new StockTicker object is created which will be used to subscribe to market data for Amazon (AMZN).  In order to subscribe to market data the subscribeLevel1() method needs to be called on the client object and passed a Level1Listener object.  In this case a lambda expression is passed in which will check the type of Level1Quote that was received, and if the quote was a ‘Last’ price, as opposed to a bid or ask, then print the value of that price to the console.

For this example I’ve connected to the special Interactive Brokers “edemo” account which is free to use, but provides fictitious data for its data feed.  It is a good account to test with to make sure that an application is connecting and receiving data as expected.

The output of the example application which was running within NetBeans IDE appears below.

Screen Shot 2016-02-08 at 7.22.31 AM

SumZero API Github project page

twitter: @RobTerpilowski
twitter: @ZeroSumTrading

Developing Trading Applications with the SumZero Trading API

I have open sourced a Java trading library which I have been using to develop automated trading applications for many years.  The SumZero Trading API provides the ability to develop trading applications for the equity, futures, and currency markets, by utilizing the following sub APIs

  • Market Data API – Request real time Level 1 (NBBO) and Level 2 (Market Depth) market data
  • Broker API – Submit, execute, and monitor orders
  • Historical Data API – Request intraday and end-of-day historical market data.
  • Strategy API – Develop trading strategies to automatically place buy/sell orders based on user defined algorithms.

The library includes implementation of all of these APIs for Interactive Brokers, except for the Broker API, which also has an implementation for Quantitative Brokers.

The libraries are licensed under the MIT open source license and source code is available at:
https://github.com/rterp/SumZeroTrading

In future posts I will show how easy it is to connect to Interactive Brokers to request real-time market data and place a trade using the API.

twitter: @RobTerpilowski
twitter: @SumZeroTrading

Version 1.1.2 of JavaFxPropertyHelper NetBeans Plugin Released

This a minor release of the JavaFxPropertyHelper NetBeans plugin, and will now follow JavaFX best practices by marking any get/set methods as final.

 

This plugin would create the following methods:

public final String getName() {
    return name.get();
}

public final void setName( String value ) {
    name.set(value);
}

public final StringProperty nameProperty() {
    return name;
}

 

The latest release version can either be download from github:
Or the NetBeans plug-in portal page.

New NetBeans Plugin to Generate Getter & Setter Methods for JavaFX Properties

JavaFxPropertyHelper NetBeans Plugin Released

 

This NetBeans plugin will help to generate get/set methods for JavaFx properties that are contained within a POJO.

The standard get/set code generator creates the following get/set methods for a JavaFx property which is not ideal:

private StringProperty name;

public StringProperty getName() { 
    return name;
}
public void setName( StringProperty name ) {
    this.name = name;
}

This plugin would create the following methods:

public String getName() {
    return name.get();
}

public void setName( String value ) {
    name.set(value);
}

public StringProperty nameProperty() {
    return name;
}

It’s also possible to use variables with the suffix Property in their names which will create the following methods:

private StringProperty nameProperty;
public String getName() {
    return nameProperty.get();
}

public void setName( String value ) {
    nameProperty.set(value);
}

public StringProperty nameProperty() {
    return nameProperty;
}

Usage

Press Alt-Insert to get the “Generate” popup menu, and select “Java FX Getter and Setter…” alt tag

Methods for supported property types will automatically be generated. alt tag

Supported Property Types

  • StringProperty
  • BooleanProperty
  • DoubleProperty
  • FloatProperty
  • IntegerProperty
  • LongProperty

Unsupported Property Types

  • ListProperty
  • MapProperty
  • ObjectProperty
  • SetProperty

The plugin is current available on GitHub at:

https://github.com/rterp/JavaFxPropertyHelperNBPlugin/releases/tag/1.1.1

and will hopefully be available via the general NetBeans Plugin portal by next week.

 

Freight Tracking with JavaFX and the NetBeans Rich Client Platform

iconI am super proud of my team who this week, rolled out Version 2.0 of Lynden Navigator to more than 1,000 desktops company-wide.   Navigator allows our freight terminal managers to optimize resource planning by giving them complete visibility to freight that is scheduled to arrive and depart to/from their facility.  In addition, customer service personnel have access to a new Shipment Tracing plugin included in this version which can be used to quickly access current information about customer freight and freight history.

The initial version of the application was built on the NetBeans Rich Client Platform (RCP), utilizing Swing UI components, but version 2.0 includes new functionality implemented with JavaFX.  A screenshot of the new version of Navigator appears below.  The top portion of the application is original portion that is utilizing Swing, and specifically components developed by JideSoft.   The lower portion of the screen is new functionality that has been built utilizing JavaFX.

FMS

Enter a caption