Weekly Update 7/22/12: Live Trading AUD/NZD with the Arb Trader Application & Update on New Features

Live by the sword, die by the sword.  The AUD/NZD strategy took a bit hit this week losing 114 ticks.  I was on the wrong end of a bad fill this week.  IdealPro (currency exchange venue IB uses) is supposed to be closed from 14:00 to 14:15 each day.  I was filled on a order at 14:01 when the price spiked down.  I contracted IB and asked how I was filled AFTER the market was supposedly closed.  They explained that the IdealPro ‘closed’ time is like a rolling shutdown where each bank that acts as a market maker will begin their shutdown period starting at 14:00, but some banks may still be online for a few minutes.  So basically, liquidity disappears starting at 14:00 until all banks are offline.

This is the first week that I also begin trading EUR/DKK, HKD/JPY, and USD/SGD with minimal position sizes in the live account to see how they perform.  All results include commission.


Week of 7/15/12

AUD/NZD USD/SGD HKD/JPY EUR/DKK
# of Trades 17 18 13 16
Winning Trades 76.5% 72.2% 76.9% 87.5%
Avg. Trade (Ticks) -6.71 -3.92 +0.07 +1.68
Total Profit/Loss (Ticks) -114 -70.6 +0.90 +26.9

 

Total since inception

AUD/NZD* USD/SGD** HKD/JPY** EUR/DKK**
# of Trades 325 18 13 16
Winning Trades 77.5% 72.2% 76.9% 87.5%
Avg. Trade (Ticks) +0.90 -3.92 +0.07 +1.68
Total Profit/Loss (Ticks) +293.1 -70.6 +0.90 +26.9

* 3/11/12
** 7/22/12

 

Update on Progress of the Arb Trader Application

Currency Strategy

This week I will be moving to live trading the following features/bugfixes.

  • Ensure that all orders are cancelled by the IdealPro close time of 14:00, and resubmitted by the 14:15 open time.
  • Make sure trades placed on Sunday evening have the correct parameters based ONLY on Sunday’s hourly prices, and not on Friday’s
  • Add timestamp to output that is displayed in the app’s text area.

End-of-Day ETF arb strategy

This strategy has closed 1 round turn trade at this point.  The strategy takes its positions near the close of the market.  It begins looking for entry/exit signals 1 minute before the market closes.  I will be taking this value down to 15 seconds before the market closes instead

Twitter: @LimitUpTrading
Twitter: @RobTerp

Issues with Interactive Brokers Gateway

Well this doesn’t give me warm fuzzies, but I thought that I would share.  IB does its nightly reset at 9pm PDT at which time the Trader Workstation (TWS) and IB Gateway will briefly lose their connections to the server.  After a few seconds the apps reconnect and everything goes fine.

Tonight however when I returned to my computer at about 9:30pm PDT, both TWS and IB Gateway were prompting me to re-enter my username and password.  Which means that Arb Trader was not connected to IB monitoring its trades because somehow I had been logged out.

I entered my username and password in both TWS and IB Gateway.  TWS reconnected, but I didn’t check the Gateway because I had assumed it has as well.  After about 20 minutes I cleared my desktop to find IB Gateway frozen (screenshot below).

I don’t think that this is a condition that can be programmed for except to send me a notification that the connection has gone bad.  I had to shutdown the IB Gateway and restart it in order to get the Arb Trader application to connect to it again.

image

Weekly Update 7/15/12: Live Trading AUD/NZD with the Arb Trader Application & Update on New Features

The AUD/NZD strategy closed another positive week, but only because of a fill that the system received near the close of trading where the market spiked up more than 60 ticks and dropped right back down in a matter of seconds.  I was fully expecting a call by Interactive Brokers telling me the trade was going to be busted, but no such call came and the strategy ended up profiting about 50 ticks on the trade.  All results below include commission.


Week of 7/15/12

AUD/NZD
60-minute
# of Trades 14
Winning Trades 64.3%
Avg. Trade (Ticks) +1.04
Total Profit/Loss (Ticks) +14.6


Total since 3/11/12

AUD/NZD
60-minute
# of Trades 308
Winning Trades 77.6%
Avg. Trade (Ticks) +1.31
Total Profit/Loss (Ticks) +407.1

 

Update on Progress of the Arb Trader Application

 

 

Currency Strategy

As of this week the Arb Trader is no longer relying on Trade Station to generate trades for the AUD/NZD strategy.  Modifications have been completed to have the strategy generate its own entry/exit orders.  In addition to this I’ve also added the following three currency pairs and will begin trading them this week in test mode, which means with minimal position sizes in the live account.:

  • HKD/JPY
  • EUR/DKK
  • USD/SGD

 

End-of-Day ETF arb strategy

I’ve completed the end-of-day ETF arb strategy and will begin trading it in my live account as well with minimal position sizes.  This strategy will not be as active as the currency strategy with an estimated 1 trade a week.  Results will be documented here.

 

Twitter: @LimitUpTrading
Twitter: @RobTerp

Weekly Update: Live Trading AUD/NZD with the Arb Trader & Update on New Features

The AUD/NZD strategy closed the week out with a nice gain of 37.6 ticks, bringing its total up to 392.5 ticks since the system began trading in March.All results below include commission.


Week of 7/8/12

  AUD/NZD
60-minute
# of Trades 12
Winning Trades 75%
Avg. Trade (Ticks) +3.14
Total Profit/Loss (Ticks) +37.6


Total since 3/11/12

  AUD/NZD
60-minute
# of Trades 294
Winning Trades 78.2%
Avg. Trade (Ticks) +1.34
Total Profit/Loss (Ticks) +392.5

Continue reading

Weekly Update: Live Trading AUD/NZD with the Arb Trader Application and Update on New Features

Results for the week of July 1st for ArbTrader appear below. The AUD/NZD strategy closed the week out with a nice gain of 26.8 ticks, bringing its total up to 370.1 ticks since the system began trading in March.  All results below include commission.


Week of 7/1/12

AUD/NZD
60-minute
# of Trades 14
Winning Trades 78.6%
Avg. Trade (Ticks) +1.91
Total Profit/Loss (Ticks) +26.8


Total since 3/11/12

AUD/NZD
60-minute
# of Trades 284
Winning Trades 78.5%
Avg. Trade (Ticks) +1.30
Total Profit/Loss (Ticks) +370.1

Continue reading

Designing an Automated Trading Application on the Netbeans Rich Client Platform (Part 1)

Over the past 10 years new opportunities have opened in the stock, futures and currency markets to allow retail traders the ability to produce their own automated trading strategies which was once only the realm of hedge funds and investment banks.  Interactive Brokers was one of the first brokerage firms to offer a Java API to its retail customers. Originally envisioned as way for developers to augment Interactive Brokers Trader Workstation (TWS) desktop application with features such as charting or record keeping, the API has gained popularity as a way to automate trading strategies.

In my first iteration of developing a trading strategy and software to automate the trades I built a Java desktop application using Swing components which would monitor stocks throughout the day and place trades when certain parameters were met, and then exit the trades at the close of the trading day. The software worked well, and it was adequate for the strategy it was designed to trade, however it was not extensible and attempting to implement new trading strategies to automate as well as connect to different brokerage accounts proved difficult and cumbersome.  Also, there are restrictions on how many stocks could be monitored via the broker’s data feed so the software had to be able to accommodate real-time market data feeds from other sources in addition to the broker’s data feed. 

I was introduced to the Netbeans Rich Client Platform (RCP) a couple of years ago and have recently decided to begin porting my application to the platform due to a large number of advantages that it provides.  The Netbeans RCP is built on a modular design principle allowing the developer to define abstract APIs for features and then provide modules which may have different implementations of the API, allowing the application to select at runtime which implementation to use.  Not only does it provide for a cleaner design by separating concerns, but by using the Netbeans Lookup API it also decouples the application and its various components from each other.  There are numerous other features that can be leveraged including a built-in windowing system, text editor, file explorer, toolbar, table and tree table components as well the Action API (just to name a few).

The trading application will make use of the RCP module system to define abstract APIs with the following functionality:

 

Broker API

  • Place and cancel orders for stocks, options, futures, or currencies
  • Provide event notification when orders are filled
  • Monitor cash balances in the account

 

Market Data API

  • Subscribe to real-time quote data for any ticker symbol
  • Subscribe to Level 2 data (market depth/order-book) for any ticker symbol

 

Historical Data API

  • Request historical price data for any ticker symbol

 

Trading Strategy API

  • Define a set of rules for entering and exiting trades
  • Ability to use any broker, market data, and historical data API implementations in order to make trading decisions.

 

The primary implementation for the Broker, Market Data and Historical data API modules will be utilizing Interactive Broker’s Java API,  but other implementations can also be created  as Netbeans modules and then imported into the trading application so that trading strategies can make use of market data from different sources if needed.

New trading strategies can be built as Netbeans modules  implementing the Trading Strategy API, where each strategy can make use of one of the implementations of the various data and broker APIs.  Utilizing the Netbeans Lookup API, strategies can query the platform to get a list of all implementations of the broker and market data APIs providing for loose coupling between the APIs and allowing the user to select which implementation to use at runtime.
Below is a diagram illustrating the organization of the various API components of the application:

 

 

 

 

In future posts I will go into more detail on how to create an API plug-in for the Netbeans RCP as well as show how to create a concrete implementation of the API.  In the illustration above the abstract broker, market data, and trading strategy APIs are installed into the RCP as plug-ins.  The broker API has a single implementation for Interactive Brokers at this point in time.  The market data API has plug-ins which provide implementations for real-time market data from Yahoo Finance as well as Interactive Brokers real-time market data.  Finally, the trading strategy API has 2 implementations in this example.  The first strategy named “Limit Buyer” will watch the prices of approx 800 stocks and place limit order to buy when certain conditions are met.  The second strategy in the example above, named AUD/NZD Currency Strategy will monitor the exchange rates of the Australian and New Zealand dollars and place orders to buy or sell when certain conditions are met.

At this point in time the application is functional and is utilizing Interactive Brokers as the main brokerage as well as market data provider.  The AUD/NZD trading strategy is actively being traded through the application, albeit with a rudimentary user interface which is publishing messages to a text area within the strategy’s main tab.  The screenshot below illustrates Interactive Brokers “Trader Workstation” application, the large black application (which is a Java Swing app), as well as the Netbeans RCP automated trading application which is the small white application, with the large text area.  In the screenshot below the application is currently monitoring prices and placing trades for the Australian Dollar, New Zealand dollar, Hong Kong dollar and Japanese yen currencies.

 

screenshot

 

 

 

 

 

 

This post is just a high level overview on the design of an RCP application to trade in the financial markets.  Future parts to this series will include more information on how to implement abstract APIs and make them available for other portions of the application to use via the Netbeans Lookup API as well as working with some of the Netbeans UI components included with the platform such as tabs, trees and tables, showing how easy it is to render the same data via these different views using the Netbeans Nodes API.  In addition to this I would like to incorporate some JavaFX components into the application such as the charting components that can be found in the core JavaFX library which will provide a graphical representation of some of the data the strategies are monitoring which will be a bit more user friendly than the current large text area.  The integration of JavaFX components within the application will be documented in a future post as well.

 

twitter: @RobTerp
twitter: @LimitUpTrading

 

Weekly Update: Live Trading AUD/NZD with the Arb Trader Application and Update on New Features

Results for the week of June 24th for ArbTrader appear below. The EUR/CHF variation remains ‘off’ until the point in time that ArbTrader app has better risk control measures in place so that when the SNB does abandon the 1.20 peg I won’t be sitting on a large loss.

The AUD/NZD strategy closed the week out with a small gain of 3.3 ticks, bringing its total up to 343.3 ticks since the system began trading in March. There were a couple of issues with the link to Trade Station which prevented the application from placing trades that are discussed in the section below  All results below include commission.


Week of 6/24/12

EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 14
Winning Trades 51.7%
Avg. Trade (Ticks) +0.24
Total Profit/Loss (Ticks) +3.3


Total since 3/11/12

EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 179 270
Winning Trades 88.3% 79.5%
Avg. Trade (Ticks) +0.27 +1.27
Total Profit/Loss (Ticks) +48.0 +343.3

Continue reading

Weekly Update: Live Trading AUD/NZD with the Arb Trader Application

Results for the week of June 17th for ArbTrader appear below. The EUR/CHF variation remains ‘off’ until the point in time that ArbTrader app has better risk control measures in place so that when the SNB does abandon the 1.20 peg I won’t be sitting on a large loss.


 

The AUD/NZD strategy had another profitable week, posting a gain of 7.2 ticks, bringing its total up to +340.0  ticks since the system began trading in March.  All results below include commission.


Week of 6/17/12

  EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 17
Winning Trades 64.7%
Avg. Trade (Ticks) +0.42
Total Profit/Loss (Ticks) +7.2


Total since 3/11/12

  EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 179 256
Winning Trades 88.3% 79.7%
Avg. Trade (Ticks) +0.27 +1.33
Total Profit/Loss (Ticks) +48.0 +340

 

I have continued work on the Arb Trader application and have begun the process of developing a new generic strategy template to be used for pair trading highly correlated assets based on end-of-day data.  This new module willl have the ability to define the 2 instruments (whether stocks, futures or options), the amount of each instrument to trade as well as the threshold value that will trigger a trade based on a proprietary indicator calculation.

In addition to this, I have begun work to allow the user to define and save configuration data for connecting to multiple Interactive Broker accounts in order to place trades and receive market data.  The current configuration is hard coded in the application itself and has made it very cumbersome when switching the application between connecting to a live account and paper trade account.

 

Twitter: @LimitUpTrading
Twitter: @RobTerp

Weekly Update: Live Trading EUR/CHF and AUD/NZD with the Arb Trader Application

Results for the week of May 27th for ArbTrader appear below. Midway through the week, after some rumors that the Swiss National Bank was planning further intervention in the FX market, (other than the 1.20 EUR/CHF peg they are attempting to maintain), I decided to suspend trading EUR/CHF as I felt I was picking up nickels in front of a steam roller.  I may re-enable it at some point if I can devise a way to deal with the volatility should the 1.20 peg be dropped or other intervention is used by the SNB.


Both variations of the strategy had a good week, closing solidly in the black, including the EUR/CHF strategy, which only saw trading the first 2 days of the week. I’ll be preparing for the Series 30 test over the next week, so unfortunately I will not have any time available to work on the additional features mentioned in last week’s post.  All results below include commission.


Week of 5/27/12

EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 12 20
Winning Trades 75% 75.0%
Avg. Trade (Ticks) +1.22 +1.95
Total Profit/Loss (Ticks) +14.6 +38.9


Total since 3/11/12

EUR/CHF
60-minute
AUD/NZD
60-minute
# of Trades 179 197
Winning Trades 88.3% 80.7%
Avg. Trade (Ticks) +0.27 +1.05
Total Profit/Loss (Ticks) +48.0 +206.6

 

Twitter: @LimitUpTrading
Twitter: @RobTerp