Maximal frustration in printing and parsing milliseconds in R

I've just spent an absurd amount of time figuring out how to parse millisecond times into R. (It's standard practice to timestamp tick data with milliseconds timing in a flat data file.) Turns out that there are two problems that I faced. One being that there is a almost-hidden, footnote option in the strptime( ) function (for converting characters to POSIX) in which it describes using format = "%H:%M%OS" instead of "%H:%M:%S" to parse fractional seconds. However, the second, and what's actually the one that's wasted much my time, is the fact that R ignores milliseconds in printing by default! For example, here's an output for the POSIXct representation of the integer value 1286564400.

"2010-10-08 15:00:00 EDT"

So even though I figured how to represent millisecond times in R a few hours ago, I never knew I did it simply because R is not printing the output that I wanted on screen every time I tried! After a couple hours of searching, trying, and frustrating, here's the one-liner command that solved my problem.

options(digits.secs=3)

which changes the options of the display and thus I can see the following output from the same input as above.

"2010-10-08 15:00:00.344 EDT"

I guess that's why they say R has a steep learning curve! Yes, it is very powerful and flexible. But there are limited standards and the documentations are all over the place because it's a mish mash of user-contributed packages!

Data analysis with R: Using the right tool for the right task

I ported Engineering Return's Trend Strength Index to JForex as my first practice to writing custom indicators in JForex. Frank's code in TradeSignal consists of 9 lines. My JForex code? 191. This is my first custom indicator in JForex. It will also be the last. A compiled programming language such as Java is not the most convenient to use for data analysis. The lack of interactivity because of the step of compilation is one obstacle to fluent data explorations. Secondly, the language itself is more cumbersome because of its generality. Java is used to build all sorts of applications. Contrary to something like MatLab, in which it is purposely built to work with numbers. I miss the days when I have my license for MatLab. However, being forced away from MatLab might not be a bad thing. As much as I've become accustomed to it, MatLab isn't without its flaws. But I won't bash it in this post. What I actually want to talk about is R. The rage these days in statistical data analysis is in R (see Wiki entry on R). I've done some research and testing, R is really as good as they say it is (see past publications in R/Finance conference). You will get to see some real examples in financial time series data analysis in R later in this blog once I have some publishable results. This will no doubt take some time as I am learning yet another new programming language (thus the lack of posts this week). The plan from now on is to use R to play with the data. Then once the algorithm is finalized, I will either port it to Java (JForex) for deployment or embed the R environment in Java for live trading.

Why winning automated contest strategies don't work in real trading

I despise sellers of trading robots making misleading promises like "doubling your money every month". They are nothing more than snake oil salesmen exploiting on the greed and ignorance of others. Yet I am finding myself in a similar situation lately. Ever since my interview at Dukascopy about my JForex automated trading contest win, I seem to have established a persona for being able to generate 45%+ return per month using my strategy. Despite my constant reiteration that this is merely a lucky result in a risk-free game, I am still getting inquiries from people interested in following my trading signals. In another attempt to rein in expectations, consider this chart of my contest demo account balance for this month.

September 2010 JForex contest balance

As you can see, my strategy doubled the account within days. However, it also lost half of its paper value plus some more soon afterward. As it stands now, my September strategy will not be in the top 10 for this month.

If I haven't mentioned this embarassing negative return, you wouldn't have noticed it, would you? That's the thing with trading contest and those snake oil trading robots, we hear a lot about them when somebody win. But what happens to those same people when they aren't winning or the countless other unfortunate followers lost money?

This reminds me of the lottery system. Our perception of the probability of winning the lottery is drastically distorted because we hear about the winnings so much while neglecting the fact that there are millions of losers out there.

The fact is, most of the seemingly impressive trading robots out there will not last for the long term. The only reason that I have won three times out of the five months is that I change my strategy's parameters in expectation of the future month's market condition. That expection is based on my own market analysis from my real trading. It isn't something that can be readily quantified yet.

The way I see it, the only way in which others can exploit my success is to buy my real secret trading system, which is, perhaps unfortunately, my brain.

My interview at Dukascopy in Geneva

The complete script for my August 2010 winning strategy is available for free via Dropbox. And for those not familiar with Java programming, I have explained the logic, the setup, and the risk management behind the strategy.

Furthermore, here is an important disclaimer about my winning, Number one with 40+ percent return in a month! So am I rich yet? Not really. If that isn't enough, here's an illustration on Why winning automated contest strategies don't work in real trading.

←   newer continue   →