TradingSystems

Algorithmic Trading Possible in India?

17 comments Written on June 9th, 2010 by
Categories: TradingSystems

In a program trading group on LinkedIn, someone asked if Algo trading is viable in India. My answer, suitably explained:

Note: If you aren’t a trader, this will seem like a foreign language to you. I’m not going into detail – that will take me the rest of the year to explain, so excuse the jargon.

One pain point is that STT is between 1.7 and 2.5 basis points (only on sell part) for a two-way transaction. That’s for futures and cash respectively. If you add transaction fees and stamp dity, you end up paying between 2 and 3 basis points per transaction overall. Brokerage - if you are a member this can be zero, but at retail end you might get 1/2 basis point to 2 basis points as additional cost. That means you need 5-6 basis points for a market making transaction, which is high considering most liquid bid-asks are not quite that much.

VWAP algos are easily doable in liquid stocks (Cash market) but then after the top 30 stock, every stock trades less than $5 million (25 cr.) a day. That means you can't move much volume on VWAP, and you don't get a deep order book to hit market. VWAP in India mostly means the weighted average of the last 30 min of trading, unlike in the western world – funds want last 30 min VWAP because it’s what the closing price prints.

You can do classic arb algos, like cash/future, basket arb or BSE/NSE. But there is quite a bit of competition here with software from the likes of FT and Greek occupying the classic arb space.

You can also do stat-arb or pairs or such, but pairing is a pain in that you don't get margin offsets. Still, there are useful mid-freq strategies – not necessarily high frequency – that might work. What’s important is to not get muddled up in the mathematics or see pair correlations where they don’t exist. For instance there is no point pairing an Real Estate company along with an IT exporter, no matter how correlated their prices seem to be. This seems obvious but it really is not; a number of people get confused.

Yesterday, in the US, the Nasdaq was down while the Dow was up 1%.A number of high-freq pair trades must have just died – the pair is well traded, even if the indices are weighted on completely different industries.

Option strategies can be made to work - from traditional triangles to risk or stat based like butterflies, IV arb etc. but these have risk associated with execution (you will almost never get a decent spread on bid-ask). Plus, liquidity is low in non Nifty options, so cash deployable is probably <10cr. Additionally in India, you have the issue of options exercisable in cash, meaning your offset position is naked in case you hold an ITM option that gets exercised at 5 pm (you can do nothing)

Still, things have improved. From tick-bunching to real-time ticks, and co-location, NSE is providing some support. They are also penalizing order-junkies by putting a small cost on order-exec ratio >100 and such.

If you consider “algo” trading as purely something that’s generated by an algorithm with no human input, then yes, algo trading can definitely work. I’m doing quant work in generating trades myself, and I’ve had success in the past (though I choose to execute manually, and have pretty high costs). Quant work can be in technicals – price and volume only – or by adding fundamentals (earnings, news) and finally by mixing in macro (sector, country, allocation, money flows); whatever mix you choose, the algo should be able to say buy X shares in Y company and so on.

A number of people think algo = high frequency trading only. High frequency trading will work best in exchanges like the US ones where they give market makers rebates. India has no rebates, and further transaction charges like STT, so high-freq has a bigger barrier.

This is an interesting field, but as in all fields, timing is important. I don’t know if this is the greatest time to invest in it, but in the long term, quant and algo work will be useful, even if as a worthwhile alternative to discretionary trading.

Trading System Log: 2% up for the month

6 comments Written on January 27th, 2010 by
Categories: TradingSystems

I’ve been working with a system we had developed over 18 months ago at Moneyoga, and the results have luckily been charming.

image

(Above is the daily equity curve, marked to market, including all commissions – which are unfortunately too high. The green curve is the portfolio normalized to 100, and the orange curve is the Nifty through the entire series, normalized to 100)

I’ve only had to take four trades, two long and two short. I’ve had no signal since the 22nd as the system does not throw up a signal when option values are too low to cover brokerage costs. Now I must retest that system using further dated futures and options – a task I have decided to use Python for and am learning the concepts of that scripting language.

This system’s been quite decent on back-testing; About three years is shown here:

image

(182 trades, 1 Jan 2007 to 6 Nov 2009; I still need to finish the test till December)

I have about five years of data but some of the instruments used weren’t liquid at all in 2005, so it is unreliable. The system has seen a drawdown (peak to trough) of about 18% – but it’s likely to see something as much as 30%, from another statistical analysis test I’ve done. (See Carstens’ ultra-useful tool, which we modified to be more rigorous)

On the back test the system has seen about 55% gains compounded annually (242% flat), and with a 30% potential drawdown the  of the system the “system heat” (risk adjusted return or return/drawdown) is greater than one. 

It’s done about 2% on one month of live testing with real money behind it; will have to wait a few more months, increasing money allocated each month as I gain confidence. Note: not revealing the details of this system here; and the purpose is not to sell the system or it’s output as tips. This is just a log entry.

Strangle Trades: Very interesting results

3 comments Written on October 24th, 2008 by
Categories: Options, Strangle, TradingSystems
I have been looking at Nifty strangles for a while and the results seem to be very encouraging. Essentially it's about buying an option strangle - a lower strike put and a higher strike call - near the money, for a quick turnaround in these markets.

I'd mentioned last about a 50% return, and later a 38% return, on a September strangle, which were reasonable. Those were based on a hypothesis that the Nifty moves dramatically after being range bound for a few months. (And how that is true in October!)

This month, I decided to start off with a strangle. And then chickened out. A 4000 call/3800 put strangle cost me Rs. 287. I sold out for Rs. 249, incurring a 20% loss. In hindsight I would have got over 1400 for it if I had held till now - but that's teaching me a lesson. (Remember this is per lot of Nifty, size 50 each)

I then decided when the Nifty moved a lot, that implied volatilities were through the roof. the Nifty was around 3300 then - so I said, heck, the Nifty isn't sticking around here too long. So a 3300/3400 strangle was bought, for Rs. 135/123 - a total of Rs. 258 per Nifty - on a per-lot level, this is an investment of about 12500. (I usually buy larger quantities, and there is enough liquidity to take in enough)

The idea was to hit the strangles when the IV was very high and the market had just moved a considerable amount, and the target was around 30%.

Sure enough, the Nifty went down to 3050 in a couple days, netting me Rs. 335 on the return side - I cashed in, with a 30% return.

And today I saw the volatility going nuts again, and I bought yet another strangle - this time a November 2850 put, 2900 call - for a premium of Rs. 500 total. And that is up to about Rs. 570 today, though I still have a 30% target.

I'm now considering systematising this - a) buy strangles when the market stays rangebound for over two months, and b) buy strangles when the IV goes to ridiculous highs (like 55+).

I know the first part has had very good results in the recent past. I also know the second part has worked recently too. It will be interesting to see if the theories still hold.

Also need to investigate optimum profit targets (or a trailing stop loss) and an optimum holding period. Can't initiate a strangle in the last few days of expiry - that's one thing I've learnt.

Position sizing here is tough. Since premium is very very volatile, you can't put all your money in there - perhaps 10-15% of the money goes in each time. So even a 30% return is like a 3% return on your whole portfolio - still decent. I need to experiment with various levels. But the preliminary tests are very interesting.

Stopped out!

3 comments Written on October 24th, 2008 by
Categories: TradingSystems
I got stopped out of my long Nifty trade this morning - the Nifty was down only 4% then. That's a loss of around 25% net, reasonably huge for me, though I managed to recover some through a long strangle that I put on immediately. Interestingly, system's all short, so it teaches me a few things. Knowledgeable and bankrupt? :)

It's good to have stops, however wide, when you know you will get out at that point. It's down 10% now! Luckily all puts have liquidity and I'm paying a lot lesser to buy them back than I thought, and the premium gave me a little cushion (but not enough, obviously).

Tough luck, but heck I traded with what I could afford to lose, and I still have enough capital left to trade the systems. And some more actually - something unexpected turned up. I think I'll have to now decide between the discretion and systems in general - turns out systems are lot less emotional damage (and on the right side of the trend, I may add!).

Systems or discretion?

7 comments Written on October 23rd, 2008 by
Categories: TradingSystems
Weird thing. Our systems - which end up being short or long, depending on the trend,are doing wonderfully in these markets. In the last couple weeks, we made over 7% and the last two days have been about trading larger capital, with a 0.75% return in that period.

We've been working with another system that has closed the month with around 5% return. A third one, that occurs only once in a while, has provided a 29% return in a few days and has provided no other entries.

Meanwhile, my discretionary trade (Long nifty) continues to make losses. I have been adding and rolling over, but it's tough to fight the feeling that this could be a seriously losing battle. I'm close to stops - stops I thought wouldn't get triggered but that's why you have stops. I remain confident about that trade - why else would I stay in - but the wave of selling, and sustained downsides is emotionally challenging.

It's largely emotions that creates problems with investing. Systems are good that way - you have a certain knowledge of how bad it might get, and you can design systems that work with your risk appetite. Yet, even systems have emotions - unless you constantly research them, you can get into system fear - i.e. running away from tweaking, observing or even training your system because you're not quite confident of it.

Take trend following. It hasn't been easy - for a few months, there really were no trends other than really short term ones. Stocks reverted to some levels and stuck there - once in a while they would move around, but get back there. Come october and a down trend sets in - but many trend followers were simply sitting on the sidelines, since they weren't confident of a system! Mean-reverters who made a killing till now, went all in - and they're in fairly bad shape. So there's a time to follow trends, a time to do mean-reversion, and a time for other kinds of strategies. But how do you identify what market works for what?

Is it a function of volatility? Daily option implied volatility or the Average True Range (ATR) specified as a percentage of move? Or do you take the ADX - a directional index? There's something out there that gives you quantifiable info - not just someone saying "yeah, I think it's going to trend today". We have to find this - and I would imagine something like this would reduce risk or improve performance. Any little bit also helps - as long as we keep it simple and don't over optimise.

Constant research is required . Just because our systems do well shouldn't mean we give up the research. But we have been guilty of that, and there are plans to fix it. More systems, more work, but hopefully we'll have alternatives when these systems go down.

An interesting thing we have been hearing from people is that they want us to use systems that have ultra-low risk. Arbitrage. Or mispriced butterfly-able options. Or pair trades. This kind of thing makes absurdly low returns but their deal is to leverage themselves, thus increasing returns. So they would do a single arb trade giving them 0.05%, twenty times a day, which makes 1% a day. Or they lever themselves 10:1 and get their 0.5%. We've been looking at such stuff and we realize that too many times, people talk only about their arb successes, not failures. So one day they see the model break down and take away all their profits.

Just recently there was talk of a pair trade of ICICI bank versus SBI - the former being oversold, so the deal was to buy ICICI and sell SBI. And then there was a day when ICICI fell 28% and SBI was UP 4%. Model went into the gutter - and any trade leveraged 4x followed it with complete loss of capital.

But there is a time to arb too - if the returns are decent enough that you don't have to lever yourself up the wazoo to make the grade. This is one time where everyone and his uncle is doing arb - and thus, diminishing returns for everyone.

Systems need a macro-view; something that tells someone that a certain kind of market is underway. A lot of discretionary traders use such macro-indicators implicitly, sometimes without even knowing it - like gap moves, increasing volumes, number of stocks hitting new highs, the advance decline ratio, or volatility measures. Systems have got to transcend from a micro-analysis to using macros too - something I must test and see.

System Trading Performance Update

10 comments Written on October 3rd, 2008 by
Categories: TradingSystems
A system trading update: now we have two systems in operation. The first one is running reasonably, up 19.11% since Jun 08, unlevered. This translates to around 60% annualized returns, which is reasonable - our aim was to get something that can survive ups and downs.

The Nifty in the same time period, has been down 17%. Last five days have been positive returns, regardless of which way the market went. (All returns are net of costs/brokerage etc.)

System 2 is now on for about five days. It's done one trade and is up 3%, though 5 days is simply too little to judge. Will keep posting as it goes on.

What we've learnt is to understand how systems change - and they change often. Specifically intraday systems change because the behaviour of markets changes. Plus, given that we've focussed only on the most liquid stocks, adding a lot more money shouldn't impact prices too much. (Otherwise, you could buy 1 lakh worth of a small cap and literally make it hit upper circuit - a waste of effort!)

One thing is that now we must look at whether this kind of system trading concept can be taken to a new level. Either by directly managing money or providing system advise. It's a pretty lousy market to raise money, unfortunately. Need to find investors who'll understand the concept and be willing to participate - this is going to be tougher than designing the systems themselves!

Another Strangle: 38% this time

No Comments » Written on September 18th, 2008 by
Categories: Options, Strangle, TradingSystems
Continuing a strangle strategy: A strangle bought two days ago - when the index was near 4100, a figure too close to comfort from the 4210 closing last expiry - yielded a 38% profit today. A 4000 put and 4200 call were bought at a premium of Rs. 67 each - a net premium of Rs. 134 - or Rs. 6700 per contract.

Today the Nifty is around 3870, and the effective premiums were 167 (put) and 19 (call). A net sell value of Rs. 186, which translates to a 38% return in a couple days.

There's probably mood for one more of these, should the nifty come back close to 4200.

Note: This is not portfolio advice. I was willing to lose 100% on the trade, remember that.

Outperformance By Hanging Around

10 comments Written on September 16th, 2008 by
Categories: TradingSystems
Yesterday we decided not to trade the system. We'd found that when the market had gapped and was in some direction by over 4% - then we found that by and large we don't make positive returns if we traded in that direction.

By the time our first trade was in the market had gapped down 4%, and was down a further two percent. At this point, there wasn't a point trading - and our system was throwing out shorts - so we decided, heck, let's not do it. This is evident in back tests too, so there's some element of 'quant' in it.

But we thought why not look at the days we haven't traded for any reason - meetings, illnesses, holidays - and see what happened. Amazingly, more than 90% of such days were our system underperforming the market, or the market going down tremendously and our system going down in small absolute terms. Either ways we had outperformed the system or outperformed the market.

I call this OBHA - Outperformance By Hanging Around. Sometimes not doing anything is worth it.