Saturday, 27 October 2012

Trading Systems - Part 1

Trading Systems are simply set of rules that traders use to determine their entry and exit from a position. In an ideal condition, traders should be like machines which have no emotions. But this is an ideal case and there is practically no emotionless human being. Now the question is what stops us from building a machine which trades.

What is a Trading System ?

A trading system is just a strategy which you develop to trade. You might need different trading systems for different markets because the strategy you use to trade in one market may not be applicable to another market. A trading system consists of 8 parts :
1. A Market Filter
2. Set up conditions
3. Time Frame
4. Entry signal
5. Protective Stop
6. Re-entry Strategy
7. Exit Strategy
8. A position sizing algorithm

A Market Filter : 

A market filter is a way of looking at your market to determine whether this market is appropriate for your system. We can have bullish markets, we can bearish markets, we can have flat markets etc. Your trading system might work well only in one of these market conditions. As a result you need a filter to determine whether your trading system should trade in such market conditions.

Set Up Conditions :

This is your screening criteria. For example, if you trade stocks, there would be 10000+ stocks available that you might decide to invest in at a time.As a result, trading systems employ a series of screening criteria to bring this number down to around 100 stocks. You might have a component in trading system to watch the stock to go down for 7 consecutive days before entry. 

Time Frame :

The first thing when you are developing a trading system is to decide what kind of trader you are. Are you a day trader or a swing trader ? Do you look at charts everyday, every week, every month or every year. How long do you want to hold on to your positions ? This will help determine which time frame you will use to trade.Though you still will be looking at multiple time frames, this will be the main time frame you will use when looking for a trade signal.

Entry Signal :

It is signal that tell you when you might enter a position - either long or short. Entry signal depends on entry rules. The simplest way to generate an entry signal is to employ moving average cross over system. The dual moving average crossover (DMAC) is a simple entry rule. If you employ this rule, a 'buy' entry signal is generated when the shorter term moving average crosses the shorter term moving average. Many traders seem to despise such simple procedures and prefer to use more sophisticated rules.

Protective Stop : 

This is one of the most important components of a trading system. This defines the worst case loss that you would want to experience. Your stop might be some value that would keep you in the stock for a long time(e.g. a 25% drop in the price of the stock) or something that will get you out quickly if the market turns against you(e.g. a 25% drop). Without having proper protective stop, your trading system can incur heavy losses. 

Re-entry Strategy :

Quite Often when you get stopped out of a position, the stock will turn around in the direction that favors your old position. When this happens you might have a perfect chance for profits that is not covered by your original set-up and entry conditions. As a result, you need to think about re-entry criteria. When might you want to get back into a closed out position ? Under what conditions would this be feasible and what criteria would trigger your re-entry ?

Exit Strategy : 

Just as we have a rule which generates a signal which tells us when to enter a market, there is a rule which generates a signal which tells us when to exit a market. Sometimes you might have to exit from a winning position and sometimes you might have to exit from a loosing position. In fact in most of the profitable trading systems, only 25 - 30 % of the trades are profitable. This is the most critical part of the trading system. You must spend a great deal of time on exit strategies. For exits, you have different options. You can either trail your stop, or have a set target and exit  when the price hits that target.


Position Sizing Algorithm : 

A position sizing algorithm just tell you 'how much' and 'how big' of a position to take. Position Sizing algorithm is a key factor in whether or not you stay in the game, or whether your gains are huge or minimal. In its simplest form, it boils down to : how many shares to trade, when to increase, when to decrease, when to take profits and so on. 

Advantages of Trading System :

Emotionless :  A trading system takes all emotions out of trading which is often cited as one of the biggest flaws in individual traders. 

Save Time : A trading system saves a lot of time which a trader would spend on analysis. A trading system can even directly place trading orders without the intervention of a trader.

Disadvantages of a Trading System : 

If a trading system would be without any disadvantages, it would be like a money making machine. But this is not the case. Lets look at the other side of the coin.

Complexity : Trading systems are very complex. You require solid technical expertise in the development phase as well as afterwards to make any changes in strategies. 

Transaction Costs : These are the costs incurred when do a transaction through a trading system. These are more than commission costs.

Time consuming in the development phase : It takes a lot of time to develop a trading system. You have to come up with strategies and then code your strategies. While coding you would have to come up with very efficient code since the data that you use to trade can be huge and you have to process the data efficiently. Also you are directly dealing with money, so it needs rigorous testing. 

Saturday, 20 October 2012

A View on the Transition from Academia To Finance

The other day I was going through an article by Catherine O'Neil from D.E. Shaw group about her transition from academia to finance which I found very interesting. I am sharing that edited article here. First I would like to introduce Catherine.After earning a degree in mathematics from UC Berkeley in 1994, Catherine went to Harvard as a graduate student where she studied number theory and graduated with a Ph.D. in 1999. Then she went to the Massachusetts Institute of Technology as a Moore instructor and then a second postdoc. She started working for DE Shaw group in June of 2007.
Now on to the answers from Catherine:

Why leave Academia ? Why finance ? Why the D.E. Shaw group ?

I found the time scale of academic life frustrating. What started as a moment of insight would take years to get published and disseminated, and that's if you are lucky.
     Finance is a huge and rapidly growing, sexy new field which combines the newest technology with the invention of mathematics to deal with ever growing abundant data. It is the essence of modernity,
and paired with New York City’s infinite energy, I found it extremely attractive. It was really as
simple as that—I didn’t actually know any finance when I decided to apply.
     I first heard of the D. E. Shaw group when Eric Wepsic, my high school math friend, chose to leave Harvard math graduate school to work at this company way back in 1994. Eric would send me emails every year or so, asking if I knew anyone interested in working there, and one day I wrote back and said, “How about me?” The D. E. Shaw group was particularly appealing because it is known for being a well-run company, and since I had decided to try my hand at business, I wanted to start at a good one. Although some people apply to the D. E. Shaw group because it’s known as being pretty academic, I think this is not an appropriate line of reasoning: get a job here if you want to be in business and not academics.

What is D.E. Shaw group like ?


There are a number of groups here and some of them, including my group, focus on the systematic quantitative investment strategies that made the D. E. Shaw group famous, while others
work on more fundamental strategies. I work as a quantitative analyst in a group consisting of about twenty traders, quants, and programmers. A group can be thought of as being similar to an academic department at a university. Groups differ by the type of financial instrument they trade or the means used to approach the trading of a common instrument. Frequently, groups overlap in the type of instrument traded but each group
has its own way of looking at the market.
     In the world of finance, the D. E. Shaw group is special. For example, we have no dress code. Personally I don’t really care about that, but this flexibility has allowed us to attract a number of really exceptional people for whom this is important. More importantly, we are not expected to work insane hours, which is great for me and my young family. When I say not insane, I should mention I work about 9.5 hours a day, five days a week, which is definitely more time than I spent in my office as an academic.

What do you do there ?


On a daily scale, my time in largest to smallest allotments is spent writing code to test models, writing up projects, talking to my manager, talking to other quants in my group, attending or giving a weekly seminar, learning techniques and thinking of new models, and reading business news. As a quant my job is to understand how financial markets work, which is neither purely mathematical nor purely social but which has elements of both. I might come up with an idea using broad economic themes but it is not a model until it is in a testable form involving concrete data. Also, in my group we rotate the responsibility of maintaining the
automatic computer trading system. This is really just a huge program that decides what and when to trade, and it needs constant attention. So for one week in about thirteen, I am on-call basically all the time. As a recent academic, I find this to be the part of my job that is probably the most alien and intimidating, but it is also extremely satisfying to be involved with the nuts and bolts of the operation.
     The transition from academia to finance has meant a shift in my priorities. Unlike when I was in academics, I no longer have to worry about grants, getting papers published and waiting a long time from beginning to end on my projects.  Now working in finance I do worry about the relevance and testability of my ideas, the minute correctness of my code, and of course profit. Leaving an academic career has meant giving up teaching, the students, and the absolute freedom to work on any project I want. On the other hand, finance has provided me with the opportunity to come up with good, new ideas that will be put into effect, be profitable, and for which I will be directly rewarded.

Would I like your job ?


To that question, I would counter with these:
Are you efficient-minded?
Can you sustain focus?
Are you flexible about the field to which you apply your quantitative talents?
Do you like to understand how systems work as well as the theory behind them?
Do you enjoy mastering new skills?
Do you appreciate the existence of a “bottom line”, a way to quantitatively measure the success of your projects and your ideas?
Are you articulate?
Are you good at following through and finishing projects?

     Notice I didn’t ask if you are particularly informed about finance or money per se, because honestly I wasn’t when I decided to enter finance. I don’t think it was a disadvantage, and now I really enjoy finance and find myself reading finance books instead of fiction. I had also never coded, but now I really enjoy coding. Both of those are skills that anyone with focus, intelligence, and flexibility can master and enjoy. For me and for many of my colleagues it is intrinsically satisfying to be in a collaborative atmosphere as part of
a functional, productive, and hard-working team with clear goals.

What does the D.E. Shaw group look for ?


The D. E. Shaw group hires people of extraordinary ability. Quant candidates typically come from math, physics, or computer science backgrounds and often have Ph.D.s. This is not to say having a Ph. D. is a requirement, but certainly being capable and smart enough to have a Ph.D. is. What we are really looking for is new ideas, and so our target is the creative, careful thinker. We look for evidence of such talents in the forms of published original papers as well as original personal projects or specialized hobbies. We typically do give brainteasers in interviews, but it is not true that only people who are insanely quick at brainteasers are seriously considered. I do not consider myself all that quick, for example, but I am methodical, articulate, and I don’t make huge mistakes.

Is Finance a good place for women ?


Working in finance is different from working in academics in that there is no tenure. However, I would recommend thinking about the concept of employability over job security. Although a given company may not last forever, the finance industry is here to stay, and there is always a need for quantitatively strong people. If you find yourself out of a job, but you have real skills and knowledge, chances are you will find another job quickly.
     Partly because of this consideration, the D. E. Shaw group tries very hard to get great people and keep them. The turnover is low, partly due to our selectiveness in hiring only the very best people, and partly because people feel valued and don’t want to leave. In fact some people have been known to retire early, but soon change their minds and return. There is little burn-out because the hours and conditions are reasonable.

What is corporate culture like ?


It is really different. People are both more competitive and more collaborative. They are more competitive in the sense that there’s lots of money involved, and therefore getting credit for an idea that makes money is a direct channel to getting paid better. At the same time, everyone relies on their colleagues to keep the whole thing running and so it is imperative that we work as a team. It’s an intense, challenging, and exciting environment to work in.
     About the money: many mathematicians who talk to me about moving to finance are genuinely worried about the potentially corruptive power of money. I take that fear very seriously, and I think I probably would have applied to the D. E. Shaw group earlier if I hadn’t experienced it myself.
     Several factors have helped me come to terms with this concern. First, it is really expensive to live in New York, especially with kids. So actually as a new quant, you are not all that rich, even though you are making more than almost all academics. However, it is clear that if you stay in finance for long enough, and are successful, you do become rich. Even so, I do not find my colleagues to be particularly acquisitive, and indeed some of them are known to support progressive causes and charities such as the Robin Hood Foundation, and I’m sure many of them quietly do so as well. In fact it is a stated goal of the D. E. Shaw group to foster an ethical work environment and to do what’s right.
     I think one can resist being corrupted by money by keeping a perspective and maintaining personal boundaries. I personally give a certain amount of my paycheck to my favorite grass-roots charity. I thereby see working here as a fantastic and rare opportunity to have a great job and to improve the world in some small way simultaneously.





Saturday, 6 October 2012

Financial Information Exchange (FIX)

What is FIX ?

FIX was originally called Fidelity Information Exchange, but now FIX stands for Financial Information Exchange. FIX is an industry driven standard to communicate trading information electronically between brokers, buyer institutions, seller institutions and markets. FIX is platform independent, so it works with various types of computers and communication systems. FIX has been developed through the collaboration of banks, institutional investors, brokers and exchanges. These market participants wanted a common language for automated trading of financial instruments.

Brief History

FIX was first developed in 1992 by Robert Bob for equity trading between Fidelity investments and Salomon Brothers. Hence it was first called Fidelity Information Exchange. FIX has now become the de facto messaging standard for pre-trade and trade communications in the global equity market. FIX has now entered post trade space as well as foreign exchange, fixed income and derivative markets. FIX Protocol Ltd. is the company established for the purpose of ownership and maintenance of the specification. FIX is gaining increased attention within the exchange community as over three quarters of all exchanges surveyed supported a FIX interface, with the majority handling over 25% of their total tarding volume via FIX.

FIX Connectivity Diagram

Financial Information eXchange System Connectivity Diagram.svg
source : http://en.wikipedia.org/w/index.php?title=File:Financial_Information_eXchange_System_Connectivity_Diagram.svg&page=1

FIX Messages

FIX session is layered on TCP. FIX messages are formed from a number of fields, each field is a tag value pairing that is separated from the next field by a delimiter ASCII 01. The tag is a string representation of a integer that indicates the meaning of the field. The value is an array of bytes that hold a specific meaning for the particular tag. FIX protocol defines a set of fields that make up a message. Some of these fields are mandatory and some are optional. The ordering of the fields is unimportant. A FIX message is composed of a header, a body and a trailer. Following is an example of FIX message:

Sending: [
 BeginString 'FIX.4.2'
BodyLength '200'
MsgType 'D' "Order - Single"
MsgSeqNum '81'
SenderCompID 'DSCWE10'
SenderSubID 's1'
SendingTime '20100914-13:34:27.643'
TargetCompID 'BCAPSUBM'
PossResend 'N'
Account 'DESHVALI'
ClOrdID 's1bs6940_20100914'
Currency 'USD‘
OrderQty '100'
OrdType '2' "Limit"
Price '129.45'
Side '1' "Buy"
Symbol 'IBM'
TimeInForce '0' "Day"
TransactTime '20100914-13:34:27'
ExDestination 'N'
MaxFloor '100'
SecurityType 'CS' "Common Stock"
CheckSum '161'
]

Recovery Handling : 

FIX has an optimistic model for recovery. It does not has per message acknowledgement. Instead the receiver monitors sequence number and detects gaps. Sequence number increases monotonically and is generally reset per day. There are serious errors is sequence number is decreased.