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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
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.
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.
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.
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 finalvoid setName( String value ) {
name.set(value);
}
public final StringProperty nameProperty() {
return name;
}
The latest release version can either be download from github:
I 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.