Productivity on the road

I am waiting for a flight to Geneva. For a guy that works in an unexciting cubicle, I seem to travel a lot. As Europe is the fourth continent which I am visiting this year. (More about this very exciting trip once I am back) The thing with travelling is that I will be away from my development desktop, amongst other things of course. As I work a day job and can only do my trading analysis and quant development work between the hours that I can squeeze in every day, every free minute is precious. One productivity habit that I adapted from frequent travelling is that I have a portable workflow system implemented. For the sake of completeness by stating the obvious, there are three keys to being productive while on the road.

  1. Exploiting downtime.
  2. Being prepared.
  3. Planning ahead.

Being productive doesn't mean that I coup myself up in a hotel room to work. Enjoying a foreign city and absorbing a different culture help enhance my personal experience in the long run. Being productive means exploiting down-times. The times waiting at an airport (like now), stuck in a plane, the wee hours of the morning when you couldn't sleep because of jet-lag, etc. Being prepared means have your work ready and available. There are three free software/services that I can't live without these days. They are Dropbox, Subversion, and SSH.

  • Dropbox is a web-based file hosting and synchronizing service. Basically, after installing the Dropbox software, anything you put in your "My Dropbox" directory in your computer will be mirrored on their online server. Then you can install the Dropbox software in a second computer and choose to link your private dataset with this second computer. Thus the "My Dropbox" directory will be synchronized in real-time between these two (or more) computers and an online version. All your most important files will be up-to-date and available to you anywhere. No more need for USB drives.
  • A software version control system to keep track and backup my source code revisions. I use Apache Subversion in particular. You can use Subversion to archive any file other than source code. For example, you can use it to keep track of revisions and branches to your presentation slides. Assembla offers a free 2GB online private repository so that you can access it from anywhere and save the hassle of rolling your own repository server.
  • Secure Shell (SSH) is not a service like the other two but a network protocol. It is not as easy to setup so I'll leave it to Google. I use it to securely and remotely access my main computer's file system or the desktop when necessary. A simpler alternative to SSH is to use LogMeIn, a remote desktop service.

Note that some of these links are affiliate programs. But I just use their free services, so I am only recommending you do that too. These tools not only help me stay productive while away, they also ease the trouble of using more than one computers between my office, my home desktop, and my wife's laptop. Together they create a true virtual development environment. While mobile and cloud computing technologies are certainly useful, nothing beats old fashioned planning and organizing. Plan ahead, prepare your work, and have them available with you wherever you are. A lot can be done with plain pen and paper.

Number one with 40+ percent return in a month! So am I rich yet? Not really

I have won first place in the August Dukascopy JForex contest! My automated strategy returned over 45% in the month of August. With that honour comes a \$5,000 grand prize in real greenbacks. The setup that I used is a minor updated version of the one I used last month. I continue to adapt my system to expect market conditions of the month ahead. Sometimes I'm right, sometimes I'm wrong. This contest is turning out to be more than a nerdy pass time for me as I have finished in the top 10 three times already since it started in April. However, I must reiterate the fact that this is not real trading. It's just a paper trading contest with no real money risked on my part. If I'm really that good at trading to make 45% of return a month, I wouldn't be writing this post at lunch in my cubicle at this moment. So yes, back to reality as I continue my engineering work while improving my own trading and developing my quantitative trading system in my spare time. As my blog's tagline reads, this is an engineer's training to trade for a living.

On technical analysis and fuzzy logic for mechanical trading

Technical traders realize that technical analysis is more of an art than science. Until you draw a plethora of lines to fill your chart, which would render it practically useless, prices rarely "hit the spot" based on your doodles. This doesn't matter though because trading is not about charts and guessing numbers. It is about costs and risks (pardon me if you've heard this a thousand times already). To whom this would matter though, are the mechanical traders using technical analysis. It may be obvious to a human to discern price patterns because a trading setup looks like something you know. However, figuring out "obvious" and "looks like" is not trivial in a program. Common ways of tackling this problem is with stochastic algorithms or Bayesian logic. The drawback with using these methods though, is that they are difficult to conjure unless you have some vigorous background in math. Hereby I suggest an alternative--fuzzy logic. In it's simplest implmentation, fuzzy logic are mere if-then statements. Here's a sample fuzzy logic control system for regulating temperature with a fan (it is also a trick solution to the infamous hysteresis problem in control theory...but I digress),IF temperature IS very cold THEN stop fan IF temperature IS cold THEN turn down fan IF temperature IS normal THEN maintain level IF temperature IS hot THEN speed up fan As you can see, there can be more than two values for a result. The classic and ubiquitous TRUE or FALSE boolean is thrown out the window. Let's dive right into an example of applying fuzzy logic to technical analysis. Say you are using the RSI as one of your indicators. Typically, you set a pair of threshold values to determine if the instrument is overbought or oversold. String rsiCondition; if (RSI > 70) rsiCondition = "Overbought"; if (RSI >= 30 && RSI <= 70) rsiCondition = "Neutral"; if (RSI < 30) rsiCondition = "Oversold"; Then here is what a fuzzy logic implementation would look like.String rsiCondition; if (RSI > 90) rsiCondition = "Very overbought!"; if (RSI > 70) rsiCondition = "Overbought"; if (RSI > 60) rsiCondition = "a little overbought"; if (RSI >= 40 && RSI <= 60) rsiCondition = "Neutral"; if (RSI < 40) rsiCondition = "a little oversold"; if (RSI < 30) rsiCondition = "Oversold"; if (RSI < 10) rsiCondition = "Very oversold!"; In fact, you may have noticed that the first RSI example is already a 3-valued fuzzy logic. And you're right! Fuzzy logic is that easy. So what can you do with that second RSI example? Well, perhaps you want to implement fuzzy logic on a MACD as a second indicator. Then you can implement a "conviction" algorithm (which isn't possible with TRUE/FALSE algorithms) by summing the two fuzzy logic (see wiki or google for more information on performing fuzzy logic operations). And then... well. This is a basic example of exploiting the benefits of fuzzy logic in automated trading strategies. More advanced use of fuzzy logic is demonstrated in this seminal work by Lin and Lee, Neural-network-based fuzzy logic control and decision system, 1991. Fuzzy logic + neural net! Well, as you can see, this is only the tip of the iceberg. P.S. I have discussed a lot recently about the frontend work that I have been working on. This post is a break for the reader and a glimpse at what I am really doing behind the scenes. Let me know in the comments below if this is your cup of tea and I'll write more of this type of posts in the future.

JForex Example: Automatic position sizing

Proper position sizing is an integral part of risk management. It can be one of the easiest thing to do too. For example, I typically size my trading position based on the following factors:

  1. Amount of capital willing to put at risk.
  2. Stop price level.
  3. Volatility of the instrument.

The following JForex code calculates a lot size based on these three factors. It is part of my Dukascopy JForex July strategy (complete source code to the strategy is available via that link). [java firstline="232"] private double getLot(Instrument instrument) throws JFException { double riskAmt; double lotSize = 0; riskAmt = this.acctEquity * (this.riskPct / 100d); // CCYUSD only lotSize = riskAmt / (this.atr[instrument.ordinal()] * this.atrFactor); lotSize /= 1000000d; // in millions return roundLot(lotSize); } [/java] Referring to line 237, riskAmt is the amount of capital to put at risk for a trade (#1). Line 238 calculates lotSize, which is the position size that we want. The denominator in that division is the distance of the stop in pips. The strategy uses a multiple of ATR to set the stop loss. Nothing fancy here. Lines 240--241 are to set the lotSize value according to the JForex API specification. In which the lot amount is in millions and in steps of a thousand units, or 0.001 step size. As I've noted in the code, the caveat to this implementation is that the secondary currency of the instrument and your account currency needs to be in U.S. dollar. However, it's just a matter of conversion to extend this method for other currencies. Update: I expanded on this functionality in the JFUtil open source project.

←   newer continue   →