Spread estimation from TAQ (Trade and Quote) high-frequency data 
//////////////////////////////////////
Objectives:
   1)  Understand the structure of TAQ database
   2)  Using Excel to retrieve data from one day s data sets
   3)  estimate the spread for 10 stocks

  High-Frequency trading has attracted lots of attention because of its 
  huge profits and because of  it is not clear whether it is fair to small 
  investors and its impact on the health of the stock market. According to 
  Investopedia, HFT (High-Frequency Trading) is defined as: A program trading 
  platform that uses powerful computers to transact a large number of orders 
  at very fast speeds. High-frequency trading uses complex algorithms to analyze 
  multiple markets and execute orders based on market conditions. Typically, the 
  traders with the fastest execution speeds will be more profitable than traders 
  with slower execution speeds. As of 2009, it is estimated more than 50% of exchange 
  volume comes from high-frequency trading orders.  To understand HFT, we have to 
  understand TAQ (Trade and Quote) database. 

  Data Sets: November 1, 2004 is randomly selected as our day, see its 4 
     data sets below. Two index files have an extension of  .idx , while 
     two data files have an extension of  .bin .
  
  12/01/2004  04:03 PM     1,800,548,334 Q200411a.bin
  12/01/2004  04:03 PM           182,424 Q200411a.idx
  12/01/2004  04:08 PM       184,899,853 T200411a.bin
  12/01/2004  04:08 PM           169,334 T200411a.idx
                4 File(s)  1,985,799,945 bytes

    References
   Philips, Matthew, What Michael Lewis Gets Wrong About High-Frequency Trading, 4/1/2014
   http://www.bloomberg.com/bw/articles/2014-04-01/what-michael-lewis-gets-wrong-about-high-frequency-trading

   Appendix A: first several lines from CQ (consolidated Quotes) from TAQ
   symbol	date	time	bid	ofr	bidsiz	ofrsiz	mode	EX	MMID
   A	20040401	8:00:02	30.62	32.64	1	1	12	P	 
   A	20040401	8:11:40	29.68	33.58	20	20	12	P	 
   A	20040401	8:12:56	30.7	33.58	2	20	12	P	 
   A	20040401	8:30:02	0	0	0	0	12	T	BRUT
   A	20040401	8:30:02	1	100	1	1	12	T	CAES
  A	20040401	8:30:02	0	0	0	0	12	T	DATA
  A	20040401	8:30:02	0	0	0	0	12	T	MADF

  Table 1: structure of a binary index file. The size (bit) of an index file is 22 with 4 variables.
   #	Name of the variable	Meaning	Size	Type
   1	Ticker	Stock symbol	10	Character
   2	Date	Trading date	4	Integer
   3	Begrec	Beginning record	4	Integer
   4	Endrec	Ending record	4	Integer

  Table 2: Structure of binary CT (Consolidated Trade) file. The size is 29 with 8 variables.
   #	Name of the variable	Meaning	Size	Type
   1	Time 	Trading time	4	Integer
   2	Price	Trading price	8	Float
   3	Tseq	Sequence number 	4	Integer
   4	Size	Trading size	4	Integer
   5	G127	G127 rule	2	Integer
   6	CORR	Correction 	2	Integer
   7	COND	Sale condition	4	Character
  8	Ex	Exchange	1	Character

  Table 3: Structure of a binary CQ (Consolidated Quote) file. The size is 39 with 9 variables.
  #	Name of the variable	Meaning	Size	Type
  1	Time 	Trading time	4	Integer
  2	Bid	Bid price	8	Float
  3	Ofr	Ask price  	8	Float
  4	Qseq	Sequence number	4	Integer
  5	Bidsiz	Bid size	4	Integer
  6	Asksiz	Ask size 	4	Integer
  7	MODE	quote condition  	2	Integer
  8	EX	Exchange	1	Character
  9	MMID	NASDAQ market maker	4	Character
 
//////////////////////////////////////