Saturday, September 3, 2011

Dynamic Memory

- catch bad_alloc exception

- check the returned address, ie, if it's 0

Friday, September 2, 2011

Array and Pointer

- an array can be considered as a constant pointer; eg,

int *p;
int a[5];

we could do p = a, but not a = p;

another example,

int a[5];
int *p;

p=a; *p=10;
p++; *p=20;
p=&a[2]; *p=30;
p=a+3; *p=40;
p=a; *(p+4)=50;

- void pointer

- null pointer

- pointers to function: usually being used as a parameter

static in C++

- use static inside a function (or a loop)

- use static in a class (static member, and static member function)

- use static as a global variable inside a file

Saturday, August 27, 2011

ETFs

- fund managers: ETFs, eg, 2823 HK, 2800 HK, INDI SP

- fund managers: trade the constitutes of the ETFs

- broker: execution services; in some cases of India and China, participate notes

- P-Notes: P-Notes <-> underlying

- booking issues

Saturday, June 25, 2011

books/articles to read

- portfolio rebalance: MSCI rebalance, Russell rebalance

- exchange traded funds: from product structure, sales, trading, transaction service

Sunday, May 22, 2011

some trading rules for KRX

- no IOC for short sell orders

- sunshine policy for program orders during expiration date, ie, disclose the orders by no later than 14:45 KST

- random end rules: it will be trigger when final call price deviates by more than 3% from its previous price (last price published at 14:40 KST), and the call execution time will be extended to a point (5min max) randomly decided by the trading system; this only applies on expiration date

- pre-disclosure and post-disclosure rules on expiry date

Sunday, February 27, 2011

FIX (I)

FIX (financial information exchange) protocol is the global protocol used for Electronic trading of different asset classes e.g Equity, Fixed Income FX (foreign exchange) , Derivatives Futures and Options and its knowledge is essential to understand Electronic trading and FIX messages. I have listed some of the very common but informative questions asked in fix protocol interview question, this list is by no means complete and only contains questions on top of my mind, I would encourage reader to post any question they have been asked and I will include in this list, Please feel free to ask any other question related to FIX (financial information exchange) protocol I would be happy to answer those. FIX messaging is term used to describe communication using FIX protocol.

If you are java developer looking for FIX + Java jobs then having a look on these FIX (financial information exchange) protocol interview snippets can benefit you in interview. usually for a FIX (financial information exchange) protocol job interviewer test whether candidate has actually worked in FIX protocol or not and whether he is familiar with various FIX tags and different FIX protocol version or not. SinceFIX (financial information exchange) versions differ significantly form one version to other knowledge of FIX tags and there value for a particular version is very important. There are lots of jobs available for Core Java and FIX (financial information exchange) protocol developer even if you had worked in FIX for 1 year you could be very much sought after in job market.

FIX (financial information exchange) protocol interview questions



What is the difference between ClOrdID and OrderID?

In FIX (financial information exchange) protocol ClOrdId is a unique id assigned by buy-side while the later is assigned by sell-side. OrderID normally remains same for a message chain (e.g. on Cancel and mod orders) while ClOrdID changes with Cancel and Modification.


What is difference between TransactTime and Sending Time?

TransactTime: Time of execution/order creation (expressed in UTC (Universal Time Coordinated, also known as 'GMT')
SendingTime: Time of message transmission (always expressed in UTC (Universal Time Coordinated, also known as 'GMT')


What is TradeBust and Trade Cancel?
Some times exchange wants to cancel a trade , if exchange is using FIX protocol then it sends execution report (MsgType=8) and ExecType=H(Cancel) , this is called TradeBust , after this earlier trade will not go for settlement and deemed as cancelled. In other times exchange (or execution party) wants to correct either TradePrice or Trade Quantity in that case they send execution report (MsgType=8) and ExecType=G (Correct), this is called Trade Correct.

As per FIX (financial information exchange) protocol
A Cancel on an execution (trade bust, ExecType (150) = Trade Cancel) happening the same day of the trade will result in CumQty (14) and DayCumQty (425) each decreasing by the quantity busted, and LeavesQty (151) increasing by the quantity busted. OrderQty (38) and DayOrderQty (424) will remain unchanged. If the business rules allow for a trade bust to be reported on a later date than the trade being busted, the OrderQty (38) and DayCumQty (425) will remain unchanged, the LeavesQty (151) and DayOrderQty (424) will increase by the quantity busted, and the CumQty (14) will decrease by the quantity busted.

What do you mean by Funari OrderType?

Funari is a special order type normally used in Japanese and Korean exchange where unexecuted quantity of a limit order turned as Market order during Market close, it is denoted as OrdType=I in FIX (financial information exchange) protocol.

What are differences between FIX 4.0 and FIX 4.2?
In FIX 4.0 we had tag called ExecTranType which describe Execution type in FIX 4.2 this tag is merged with ExecType (tag 150) and now OrdStatus will show status of order instead of Execution type. Later versions of FIX (financial information exchange) protocol is now 5.0 or even higher.

What do you mean by Sashinari & Hikenari order types?

These are again special order types available in Japanese exchanges added on FIX (financial information exchange) protocol later.
Sashinari (Limit market order) = First, this is treated as a limit order. However, if all or part of the order is still unexecuted, then the remaining quantity is changed to market order at "day's" closing (O-hike).
Hikenari (Market order on close) = this order type can be placed either for closing of morning session or closing of afternoon session. However, if an order is placed for closing of morning session and there are still unexecuted quantities, then the remaining quantity (not expired at morning close) is treated as a market order for "the opening of afternoon session".
If an order is placed during afternoon session, it is treated as a market order on afternoon close

Sashinari and Hikenari are available in TOCOM exchange.


What are header tags in FIX (financial information exchange) Protocol?
Header tags are certain special tags in FIX (financial information exchange) protocol which comes in the beginning of a FIX Message.
Only the first few fields of the header must be in sequence, see FIX (financial information exchange) Spec Volume 1. "The first three fields in the standard header are BeginString (tag #8) followed by BodyLength (tag #9) followed by MsgType (tag #35)."
Also "General message format is composed of the standard header followed by the body followed by the standard trailer."
Fields of the header thus must not appear in the body, if they then FIX engine will not be able to parse and understand message and will complain about it.


What is difference between DMA orders and CARE orders?

These are general concept irrespective of FIX (financial information exchange) protocol. DMA orders are Direct to Market order means it will not touched by any trader or salesperson on broker side while CARE orders also called as Broker Intervention (BI) orders will be touched by Trader or salesperson on broker side.
So if a Trader has any view on Market he can take advantage of that while working with BI order.


What is the difference between Application level Reject (MsgType=8 and ExecType=8) and Session level reject (MsgType=3)?
FixEngine will reject any message which doesn't confirm FIX protocol i.e. some mandatory tags missing e.g. MsgType with Session level reject , application will not get that message for processing , while application e.g. OMS or Execution System will reject message based on Business logic or FIX (financial information exchange) Protocol trade life cycle with application level Reject (MsgType=8 and ExecType=8).

What is FIX Messaging?
FIX messaging is term used to describe communication using FIX protocol. So if two FIX engines are communicating with each other using financial information exchange protocol we call it as they are communicating using FIX messaging.

Sunday, January 16, 2011

algo trading strategies

- Implementation Shortfall

- VWAP

- TWAP

- POV (Participate)

- Iceberg

- dagger

market knowledge and trading rules - MYX

market knowledge and trading rules - BSE

market knowledge and trading rules - NSE

market knowledge and trading rules - TWSE

market knowledge and trading rules - KOSDAQ

market knowledge and trading rules - KOSPI

1. Korea exchanges
- there're several markets
- for equities, there're KOSPI and KOSDAQ markets

2. trading hour (Mon-Fri excluding public holiday; local time)
- quotation receiving hours: 0800-1500
- trading hours: 0900-1500

- it also has off-hours session
i) pre-hours: 0730-08-30 quotation receiving hours; 0730-0830 trading hours
ii) post-hours: 1500-1800 quotation receiving hours; 1510-1800 trading hours

- Dec/31 is a holiday; if it falls in a holiday or Saturday, one previous business day closest to the Dec/31

3. quotations
- quotations are trading orders placed to Exchange Trading System by member firms whether it be customer orders or proprietary trading orders

- quotation types
i) limit quotation
ii) market quotation
iii) limit-to-market-on-close quotation
iv) immediately executable limit quotation
v) best limit quotation

- KRX member firms may entail following conditions to limit quotation, market quotation, and immediately executable limit quotation
i) IOC (immediate or cancel) - part of whole qty
ii) FOK (fill or kill) - entire qty

- the price at market closing is determined by individual auction at a single price method (call auction)

- cancellation & correction of quotations
i) cancel part or entire quantity; if partial cancel, the submitted time of the initial quotation shall be valid for execution priority
ii) correction refers to change of price; KRX member firm may correct price to the partial or entire quotation; execution priority for the corrected part will be the correction submit time

4. trading unit is 10 (or 1 if base price of issue on that day is above KRW 50,000); trading unit for off-hour session is 1;

5. ticks

- minimum price intervals at which quotations can be made. it's determined by trading efficiency (system capacity) and lower transaction cost (tight spreads)

Share price (KRW)Tick size
lower than 1,0001
1,000 - 5,0005
5,000 - 9,99010
10,000 - 49,95050
50,000 - 99,900100
100,000 - 499,500500
higher than 500,0001000


6. daily price limit

- for KOSPI market, it's 15% (disregard the residual amounts so that all the price limits are set as available tick size)

7. prices

- base price: previous close price
- open price: is determined by the quotations received during 0800-0900 period (single price call auction method)

7. settlement

- T+2

9. for more details

eng.krx.co.kr

an example on how to compute the opening & closing price

On many exchanges, the single price determined for the Opening and Closing Routine Price is based on the following methodology:
- A buy (sell) order may be executed at a lower (higher) price.
- The cumulative buy volume at any price is the buy quantity at that price, plus the sum of the buy quantities at all higher prices.
- The cumulative sell volume at any price is the sell quantity at that price, plus the sum of the sell quantities at all lower prices.
- A sell (buy) pressure occurs when the cumulative sell (buy) volume exceeds the buy (sell) volume at a particular price.
- The tradable volume at any price is the smaller of the cumulative buy/sell volume.
- The price overlap is the range of prices where tradable volumes are possible.
- The equilibrium is the price range within the price overlap where buy pressure changes to sell pressure.

The equilibrium price is one of the following:
- The price within the equilibrium that has the largest trade volume, or
- If there is no unique price, the average of all prices within the equilibrium with the maximum trade volume, or
- The average is rounded to the next multiple of the minimum price multiple for this stock in the direction of the previous day.
- If there is no settlement price, the average price is rounded to the next highest price multiple.


In this case, the Opening price will be $0.285 with 5,000 shares being matched (as 5,000 is the higher of the two tradable volumes when the sell pressure changes to buy pressure).

market knowledge and trading rules - SGX

1. trading hour (Mon-Fri excluding public holiday; local time)
- pre-open routine: 0830 - 0900 (pre-open 0830-0859; non-cancel 0859-900)
- morning session: 900 - 1230 (adjust phase 1230-1359; non-cancel 1359-1400)
- afternoon session: 1400 - 1700
- pre-close routine: 1700 - 1706 (pre-close 1700-1705; non-cancel 1705-1706)

- half-day trading on eves of Christmas, New Year and Lunar New Year, ie, pre-open 830-900, normal trading session 900-1230, and pre-close 1230-1236
- when a holiday falls on Sunday, the following Monday will be a public holiday

2. pre-open, adjust phase and pre-close routines break down
- they are aimed at increasing efficiency and transparency of the marketplace, so as to facilitate smooth price movements during the opening and closing sessions of trading

- pre-open period (0830-0859)
i) order input, mod, cancel
ii) no order match yet
- non-cancel period (0859-0900)
i) no order input, mod, cancel
ii) order that can be matched are executed based on a single "opening" price computed by SGX trading system
iii) unmatched orders will flow into regular trading session

- lunch break hours (1230-1359)
i) order input, reduce in qty or cancel
ii) no order matching
- adjust phase non-cancel period (1359-1400)
i) no order input, mod or cancel
ii) orders that can be matched will be executed at a single price computed based an algorithm set by SGX trading system

- pre-close (1700-1705)
i) order input, mod or cancel
ii) no order match
- non-cancel period (1705-1706)
i) no order input, mod or cancel
ii) orders that can be match will be executed at a single "closing" price
iii) unmatched orders will be discarded

3. types of orders
- limit order


4. epic codes for all Singapore listed stocks are alphanumeric; stocks can be quoted in SGD and USD; stocks can only be traded in board lots of 1,000 in Ready market; however odd lot can also be trading in Unit Share Market (Odd Lot Market)

5. ticks

- dependent on the current share price (need to double verify with exchange website)

Share price (S$)Tick size
lower than 1.000.005
1.00 - 9.990.01
higher than 10.000.02


6. tolerance level

- 6 ticks

7. settlement

- T+3
- T+2 (standalone FX transactions)

8. supported FIX message types

- administrative message types (logon, logout, heartbeat, test request etc)
- trading message types (new order single, execution report, order cancel request etc)
- market status and security status types (security definition, trading session status etc)
- other message types (news, business message request)
- for details, check exchange website

9. for more details

www.sgx.com

Saturday, January 15, 2011

market knowledge and trading rules - HKSE

1. trading hour (Mon-Fri excluding public holiday; local time)
- pre-open auction session: 930 - 1000
- morning session: 1000 - 1230
- extended morning session: 1230 - 1430 (for extended trading securities only)
- afternoon session: 1430 - 1600

- half-day trading (ie, no extended morning and afternoon sessions) on eves of Christmas, New Year and Lunar New Year

2. pre-open session break down

a) 930 - 945 (order input period)
- input of both at-auction limit orders and at-auction orders
- orders mod or cxl

b) 945 - 950 (pre-order matching period)
- input of at-auction orders only
- no order mod or cxl

c) 950 - 958 (order matching period)
- orders are matched at the final Indicative Equilibrium Price

d) 958 - 1000 (blocking period)
- a break between pre-open and continuous trading sessions; no order input, mod or cxl

e) at the end of pre-open session, all unmatched orders shall be cancelled and deleted from the exchange automatically except for those at-auction limit orders whose specified price does not deviate 9 times or more from nominal price at that time

3. cancellation of orders

- orders entered in the morning session is permitted to cancel from 30 minutes before the afternoon trading session of the same trading day

4. trade prices

- closing price: median of last five nominal price at 15-second interval from 1559 to 1600.
- previous closing price
- open price: indicative equilibrium price
- day low price
- day high price
- bid price
- ask price
- current bid price
- current ask price

5. indicative equilibrium price (IEP) and indicative equilibrium volume (IEV)

- IEP is the price at which the max number of shares (IEV) can be traded if matching occurs at that time point; they're continuously re-calculated and updated each when a new order comes in during the order input period of the pre-opening session


6. types of orders

- at-auction limit order (orders with specified price during pre-open session)
- at-auction order (orders without specified price during pre-open session)
- limit order (only limit orders permitted during continuous trading session)
-- limit order
-- enhanced limit order
-- special limit order

7. epic codes for all HK listed stocks are numeric; different stocks have different board lots

8. ticks

- dependent on the current share price

Share price (HK$)Tick size
0.01 - 0.250.001
0.25 - 0.500.005
0.50 - 10.000.01
10.00 - 20.000.02
20.00 - 100.000.05
100.00 - 200.000.10
200.00 - 500.000.20
500.00 - 1,000.000.50
1,000.00 - 2,000.001.00
2,000.00 - 5,000.002.00
5,000.00 - 9,995.005.00

9. tolerance level

- 24 ticks (or 9 ticks for 1 bid/ask made in pre-open session)

10. settlement

- T+2

11. for more details

www.hkex.com.hk