Software design, trading development process, and Ikea

I spent a few months between 2010 and 2011 not on the market, not on coming up with new strategies, but on developing a software framework for my trading system. For my trading strategy development, I make use of a continuous systems development life cycle process from the engineering realm. Starting from planning, to analysis, to design, to implementation, to maintenance, and finally, back to planning, and so on for each and every new concept that I have. (see Sir James Dyson’s guest column on Wired)

Imagine that if you need to write a new strategy file for each and every idea and for each of its design iteration. Pretty soon you’ll have many strategy files and a lot of boilerplate codes. What if you found a bug or figured out some enhancements to a particular component of your strategy? Then you’ll have to sift through all those files and make the changes to all those relevant codes to make the update across the board.

Hopefully, this isn’t the approach you’re taking. Yet, a few trading API that I have used before inherently encourage or even limit you (EasyLanguage and MQL4) to this archaic procedural programming paradigm.

Luckily, Java is an object-oriented programming language. However, it is only as object-oriented as you make it to be. JForex, the trading API that I use, actually runs on the edge of breaking this object-orientedness as I have recently lamented.

The bad news for the beginning developer is that practically every published strategy which I have seen or guilty of posting myself are illustrations of what not to do with software design. In that there’s none in it whatsoever. Think of common published strategies like the Ikea mini-model showrooms. Everything is crammed into a tiny space but it is a simple way to convey the gist of a room design (read: the trading algorithm). However, they are not built for practical use. Real strategies are like suites in an apartment building. There is an underlying architectural commonality for easy management and maintenance while enabling diversity in the strategies.

My recently completed software framework dramatically made my life easier in the tasks of implementation and maintenance. Software maintenance, in particular, is most often needlessly and overly complicated in trading strategy development because of the lack of a good design. Because at the end of the day, most programmers spend the majority of their time debugging, maintaining, and extending their code. A true object-oriented design decouples all its components so that you can use a divide and conquer approach with no repetition of work.

Do you have a development process in place? I’d like to hear how you tackle this problem.

read more

What is a trading system?

For some traders, building a trading system means that they focus on finding the best indicators they could get their hands on or the one trading setup that is backtested to work 99% of the time. All I can say is, to each his own.

For me, the keyword of a trading system lies not with trading, but with system. Remember, it is a system. First of all, it is a system for trading. Not a system to trade. What do I mean by that?

Consider this saying, “traders don’t go broke by missing opportunities, they go broke by taking too many.” A trading system needs to be selective. It needs prudent risk management.

Secondly, you need to generate your own market view to trade. Rather it be technical, fundamental, sentimental, or just following some joe, you trade based on your view. Trading is a test of your market hypothesis using money. If you think the market will rise, you buy. If you think the market will fall, you short.

Lastly, a trading system needs to execute trades. Otherwise you’d be an anlayst. It needs to time entries and exits. Again, this could be as simple as on a whim or as complicated as some n-th order algorithm.

Thus we have the three pillars of a trading system.

  1. Risk Management
  2. Market Analysis
  3. Trade Execution

What’s more, if we combine some of these pillars we get some well known concepts. For example, market analysis + trade execution = trading signals, wherein you derive signals based on market conditions to execute trades. Or risk management + trade execution = position management, wherein you manage your holdings by manipulating your trades based on your risk profile.

All these relationships and composition of a trading system can be summarized with a Venn diagram. So, this is my view of a trading system:

Trading system Venn diagram

read more

An illustration of what it means by missing the boat in trading

As I wrote last Friday, I took a long position in Teck Resources (TCK-B.TO) at $36.03 but got stopped out at breakeven. In hindsight, the retracement after testing the $37 resistance held the 50% level near the close. That was a bullish sign that I missed at the time and only realized during my weekend review.

As you know, the TSX market gapped about 2% up and S&P gapped about 4% up right at the open. The market traded in a range all day but managed to hold the gap.

However, EUR/USD closed its gap and is testing 1.27 support as I write this. The EUR/USD pair will be an important pair to watch as the European Union drama unfolds.

With regard to TCK, Figure 1 speaks for itself. It gapped up about 8% and closed up 8.78% at $39.53. I decided not to chase the market early on today as the reward/risk ratio just isn’t as appealing anymore.

There are always opportunities sailing around the corner. So there is no need to go out of breath chasing that one missed boat.

Tech Resources (TCK-B.TO)

read more

Ranking investment options for my self-directed RRSP

If the idea of handing your RRSP contributions over to a sales person (a.k.a. financial advisor) at a bank isn’t appealing to you, then it is time to consider your investment choices. I am about to contribute for the first time ever into my RRSP this year. So I performed my due diligence by researching and evaluating my choices. This post is a ranking of my findings.

I evaluate each investment strategy according to three criterias, in descending order of importance.

  • Risk. Will I lose sleep at night if I put all my money in it?
  • Reward. How much can I potentially gain?
  • Effort. How much time and energy do I need to spend on it?

My overall portfolio is exposed to enough risk already from my other trading activities. So my risk appetite is leaning towards a conservative approach. Also note that I factor in costs as a part of my risk assessment. I place a 40% emphasis on this criteria.

Next, I consider the return of each investment vehicle using a 40% weight. For obvious reasons.

Lastly, I prefer something that requires as little time and effort as possible. I weight this criteria at 20%. As I’ve said numerous times, I don’t like the limitations in a registered account. It is like trying to invest with one hand tied behind my back. I do not want to put much effort to manage this account because I can do better in my regular trading.

The resulting ranking of the six types of markets that I am considering for my RRSP (and TFSA) is as follows.

  1. Guaranteed savings
  2. Indices or sectors (through passive mutual funds or ETF’s)
  3. Fixed income (using a mutual fund or ETF bond index)
  4. Gold
  5. Stocks
  6. Actively managed mutual funds

One thing of note about investing in physical gold within a registered account is that it can only be done at Questrade as far as I know. Although I doubt they are the only one.

Here is the table I used to estimate this ranking. I give each category a score from 1 (bad) to 5 (good) based on my own experience and my sentiment of future market condition. So yes, it is a very crude guess at best.

Nevertheless, the table shows that my best choice is to either put my RRSP money in a savings account or invest in indices using passive mutual funds (like the TD e-Series) or ETF’s.

However, I plan to do both. I will trade indices in my RRSP and put my TFSA money in a high yield savings account.

RRSP investment choices ranking

read more

What is your trading process?

Here is my discretionary trading process in a UML workflow diagram. How does it compare to yours?

My trading process workflow diagram

read more