algorithmic execution

####    background & glossary    #### 
##  misc vocab 
risk = volatility = stddev of returns 
portfolio (aka program or basket) trading : it's a brokerage service. often cheaper than 'single stock trading' each name indivdually. broker side usually just leverages the economy of scale to offer this at cheaper commission fee. 
systematic/quantitative tarding : systematic simply refers to some sort of technical rule based (liely automated) decision makinig, and quant trading refers to some quant model based trading. e.g. stat arb. 
often these are discussed in the context of 'investment decision making / strategies' as opposed to execution algorithm. 
HFT : high frequency trading, aka short term intraday trading. it can refer to the frequency of hours to nano seconds. 
EMS: execution mgmt system 
OMS: order mgmt system 
delta 1 product: e.g. cash/equity. exposure is linearly proportionate to your position size. 
agency trader : aka sales trader. zero-risk trader. 
prop/principal trader : aka risk trader. (there once was a group of traders in every investment bank that does pure prop trading, competing with other investors on the market. but nowadays, those are frowned upon in banks, so most are shut down or spinned off as hedge fund or operating as electronic market making desk. but also we do have risk traders within banks. for example, suppose a big client wants to do a block trading at vwap. sure you can just handle it as agency trading, using algo execution. but one other way is to negotiate and agree with the client that you undertake it as principal. now the risk transferred to you. in fact, banks like morgan stanley offer benchmark-guarantee trades to investors. e.g. vwap-guarantee, close-price-guarantee. this we can still say it is really just market making. because they are facilitating client order exec by managing principal positions/inventory) 
blind risk bid: a blind bid is when (often institutional) investors simply specify criteria such as beta/volatility/exposure of a target portfolio, then it is up to the executing BD to buy whatever securities to satisfy that instruction. 
agency cross: when a broker matches a buy order from one client with a sell order from another client. 
##  electronic trading  -  execution service 
stocks, bonds and other financial assets have been traded manually in the past for centuries. 
i.e. companies, goverment issues them, and investors buy and sell, negotiate, enter into agreement/contract, sign papers, and so on. 
people used to read news papers or call banks, for example, to know stock price, or place orders. 
now, while some of these traditonal methods still exists today, the platform has been made electronic, which facilitates efficiency in speed/cost (and opportunities for automation and adoptioin of machine based trading), and it also allows for better records tracking/archiving. 
but the underlying market mechanism/microstructure is the same. 
to trade (i.e. buy/sell) stock, an investor needs a licensed intermediary (broker/dealer) to the market. and there is post-trade process of clearing/settlement. 
sometimes people distinguish BD as follows: 
broker : agency trader 
dealer : principal trader 
suppose you are a buy-side PM for a pension fund, or a hedge fund, or an insurance company. based on your alpha research, backtesting/optimization, risk control, which gives you an overall investment decision/strategy, you need to trade to achieve a target portfolio daily (or hourly or weekly or whatever time horizon). then which BD (broker/dealer) to you send you orders to? even for a simple limit order like "buy 1000 shares of IBM by EOD below XYZ price", different BD shows vastly different execution quality. there is a whole lot of complexity that goes into execution. e.g. slicing, scheduling, routing (e.g. you dont wanna reveal your patterns). so selecting BD for execution is an important task. (in fact, aside from standard PMs, buy-side may have full time trader whose job is to take care of execution.) 
execution service is a big business area. and the commission fee is often commenstrate to how many shares/orders are executed. 
##  what execution methods are available ? 
(1) human trader (aka high touch): manually executing, deciding venues, deciding order types, limit, schedule, slicing, etc 
(2) algo execution platform (aka low touch): automated algorithmic execution. (scheduling, slicing, plus intelligent order routing, etc) 
historically, algo execution existed for sell-side internal traders to off load their work, but because it became so sophistiated, its quality became so good, that they decided to open it up to investors. (obviously, information privacy is a concern, and needs to be protected from DB's other traders who can otherwise exploit client order info.) 
(3) DMA (direct market access. aka zero touch): lets investors to send orders directly (from investor's OMS/EMS) to exch order books, via BD's infra which usually facilitates limit/rule/risk check, reporting/clearing/settlement, etc. DMA basically gives investors more direct control over their orders. (but obviously they need to have their own OMS/EMS) 
-- sponsored access: DMA without pre-trade risk accessment, often for the sake of low latency. (still uses BD's MPID) 
-- direct strategy access (DSA): basically an extension of DMA. investor's OMS/EMS have direct access to BD's algorithm. so investors can choose which algo to use for each order, whereas in the usual algo execution service, investors only send instructions. 
(4) "crossing" network: 
- a kind of ATS (alternative trading system) that offers an electronic order matching/execution, at a fixed time of the day, (like several fixed times during the day, or after mkt close, or at EOD, etc) at some target price (like mkt close price, EOD vwap, EOD mid price, etc). 
- characteristics 
-- very low commission (e.g. 1~2 cents per share or lower) 
-- anonimity (aka dark pool, dark liquidity) : in terms of two things 
   1. market impact cost : this is great for investors who want to do block trading, because he can hide order size (even price), thus not worry about impact cost like he would have to in traditional public quoating venues, thus sometimes achieve better price in crossing network/ATS. 
 note: sometimes people distinguish btwn "crossing network" and "ATS" based on whether matching/execution happens at various set timings of the day (e.g. ITG's Posit) or continuously (e.g. Liquidnet). some people don't make the distinction because both offer the above two advantages. 
   2. information privacy : because investors can bypass BD, their order info is protected (plus leads to lower fee also). 
-- execution not guaranteed. (i.e. requires close monitoring/managing of orders. like re-routing orders to other venues to guarantee execution as needed) 
- as yet another liquidity venue, some crossing network/ATS allows sell-side participants too. 
note: the word "cross" is an overloaded term. some exch simply mean auction trade by crossing. similarly we say order book (or simply the market) is crossed if askPx < bidPx (which is normal during auction period, but it's an outage if it happens during continuous trading hours. btw, locked mkt, aka locked order book means when askPx == bidPx) in many mkts including ASX, a cross trade generally means a trade in which buy/sell orders were matched within the same BD's client pool. you might think of it as netting. 
(5) ECN : automated continuous order matching/executing system. e.g. Instinet. although ECNs behave just like stock exchange, SEC requires ECNs to register as "broker-dealer", not as "exchange". what this means is while only member firms can trade in "stock exchange", individual investors can trade directly at ECNs. ECN is a form of ATS per SEC. but unlike crossing network/ATS we discussed, ECN usually displays quotes / order book publicly, i.e. "lit" venue, aka lit market.  confusingly enough, some people refer to ECNs as "secondary exchanges". 
note: "broker-dealer" is also an overloaded word. from regulator/SEC perspective, all of banks, crossing network, ATS, ECN are BD entities. but from buy-side investor perspective, we may say "dark pool is a great way to trade directly and anonymously with other buy-side investor without intermediary broker dealer." here notice BD refers to traditional sense of middleman BD. 
note: from buy-side investor perspective, (3),(4),(5) are all "direct" trading. we may hear DLA (direct liquidity access) which is basically a service (by some broker) that combines (3) & (4) via some SOR (smart order router) technology. 
note: SOR is an important topic in algorithmic execution, to be revisited in depth later. it basically tries to decide order routing (which venue, including both lit and dark) for best execution, based on market data (e.g. price, liquidity, spread, order book, trade frequency, volatility, volume, any other historical data), fees/rebates and randomization factors. SOR obviously became important since the advent of various execution venues (i.e. fragmented liquidity) 
==> fragmentation of exec venues, introduction of so many order types, increased transparency of order book, other regulatory changes, all led to this unprecedented complexity. "algo execution" will look at all possible venues of liquidity for best execution for client orders. 
ASIDE: how many seats are available and much is a seat (license to trade directly) at NYSE ? 
- according to wikipedia 
- "In 1953, the number of seats was set at 1,366. These seats were a sought-after commodity as they conferred the ability to directly trade stock on the NYSE, and seat holders were commonly referred to as members of the NYSE. The NYSE now sells one-year licenses to trade directly on the exchange. Licenses for floor trading are available for $40,000 and a license for bond trading is available for as little as $1,000 as of 2010." 
- here, essentially, member = seat = license to trade directly at the exchange. 
##  what are common execution algorithms ? 
(many benchmark-based approaches) 
- vwap 
- twap 
- pov (percentage of volume) 
- implementation shortfall, aka arrival(decision) price. here we basically define "(impact) cost" = avg execution price - arrival price 
- moc (mkt on close) 
- liquidity based benchmark : driven by 1. the advent of so many alternative exec venues, ECNs, ATSs. 2. increased order book/depth transparancy 
- hybrid of above (it becomes important to ultimately customize/adapt to each client's requirements) 
note: as above, there are several well standardized algos, but their performance is diff btwn brokers, because (1) each broker has its own quant predictive model of market factors (e.g. price/volume/volatility) and (2) various brokers have diff quality of technology infra. 
---> there exists a whole suite of TCA (transaction cost analysis), aka posttrade analysis. 
---> notice "cost" is the key component of performance. cost in terms of mkt impact, timing risk, commission, etc (more on this later) 
- avg execution price    # it is obviously important to consider its the stddev (i.e. volatility) 
- fill ratio             # these 
- speed of execution     # can be in a trade-off relation to avg execution price 
---> each investor has his priority, so algo selection is important. (client can hand-pick which algo to use, along with other instructions, or BD can decide based on client order size, asset liquidity/volatility, other pre-trade analytics) 
##  efficient 'execution' frontier 
recall "implementation shortfall" aka arrival price benchmark. here it is really a trade-off between cost and risk. 
 "efficient frontier" is typically depicted as "return as a function of risk". 
 but in execution service, we think about this in terms of cost VS risk. 
 trading quickly/aggressively (like all at once) incurs bigger impact cost, while trading slowly (more passively) incurs less cost but exposes orders to more price volatility, i.e. risk. 
  |           ...           |  . 
r |       ...              c|   .. 
e |    ...                 o|     \.. 
t |   .                    s|        \.. 
  |    .                   t|           \... 
  |-----------------        |------------------ 
        risk                       risk 
###  SOR (smart order routing) 
###   market microstructure   ### 

# prerequisite background vocab 

- primary mkt 
  - equity : IPO 
  - gov bond : specialized auction 
  - debt : new debt offering by syndacate banks 
- secondary mkt 
  - equity : exch, ECNs, ATSs 
  - bond : OTC, inter-dealer mkt 
- buy side VS sell side 
- broker (facilitate/agency) VS dealer (prop) 
- liquidity cost ≅ trading cost 
-- generally the biger trade volume mean more liquidity (i.e. lower liquidity cost) 
-- so if you are in execution service, then predicting volume means predicting trade cost, so you can execute at lower trade cost 
-- some characterize liquidity as a function of such factors as: 
   - order book depth/size 
   - spread 
   - others (like diversity, like if diverse investor views exist) 
- lot size 
- tick size 
##  market structure 
- market type 
  - trade mechanism 
    - quote driven  (various forms exist. like multi-MM consolidated orderbook, or individual MM two-way quote display, OTC RFQ/negotiated/advertized, etc) 
    - order driven 
    - hybrid 
  - trade frequency 
    - continuous 
    - periodic call auction 
    - request based 
- order type 
- trade protocls 
- transparency 
- OTC trade 
==> lets look at components in detail 

# [trade mechanism] 

(1) quote driven : MM displayes two way quotes (= essentially maintaining limit orders) 
(2) order driven : participants can place orders on order book 
(3) hybrid of (1) & (2) 
e.g.  Nasdaq used to be (1), but now (3) 
      euronext used to be (2), but now (3) 
OTC & quote drivern mkts tend to be more opaque. 

# [trade frequency] 

- continous trade (aka continuous auction) 
- periodic trade. i.e. call auction (e.g. finding a single price that maximizes exec volume, reduces price volatility than continuous auction when there is uncertainty in the mkt) (frequency can be anywhere from every 10 seconds to once a day) 
- request based trade (e.g. OTC, broker negotiated trades, i.e. bilateral trading, as opposed to multi-lateral trading like above) 
trading hours : usually consists of 
               - open/morning auction 
               - continuous trading 
               - close/evening auction 
note: there may be variations, like lunch break, half-day, extended hours, intra-day volatility auction (for individual names), so on. 
      TSE's closing auction is instant as of 15:00, which is a little unique. 
- study shows price discovery is more efficient by batching orders in periodic call auctions. 
  (less volatility, more pooling of liquidity for even illiquid instruments, hence "open/close/intraday" auctions because open or close or whenever a big news comes out is the most volatile timings) 
- similarly we have circuit breaker (aka trading halt) to stabilize market when there is otherwise too much volatility 
note: crossing and uncrossing in auction context are the same. confusing indeed. 
note: randomized auction crossing is commonly used in some markets, like ASX, NZX, Moscow, where they say, for example, "auction cross will happen between xx:yy:00 and xx:yy:59". the idea being so that they can load balance the system capacity, with each name opening at random timing rather than all thousands of names at once. 
note: in call auction, common data is "indicative auction price/size" and "order imbalance" which is the delta of sum(askOrders)-sum(bidOrders) 
even for the same asset class, the exch may divide into segments, based on e.g. liquidity. 
some mkts only do auction only for open (or close). or only do auction for a certain subset (like major index consituents), so on. 
(sometimes they newly start doing it where they didn't, so be cognizant when doing historical analysis) 

# [order type] 

- market order    (takes liquidity) 
- limit order     (adds liquidity) 
 - called "marketable" if it can be filled immediately 
 - called "at the market" if it is at NBBO price. (i.e. your bid/ask order is best bp/ap) aka "making the market" 
- stop (loss) order        # after reaching a certain threshold, it becomes mkt order 
- stop (loss) limit order  # after reaching a certain threshold, it becomes limit order 
each venue may have many many custom order types/conditions. (IOC, GTC, FOK, AON, etc) 

# [trade protocols/rules] 

- trading hours, open/close/intraday auction, circuit breaker condition 
- ticksize, lotsize, daily limit price 
- order priority (price, time, size aka pro-rata, etc)    // commonly, equity mkt = price/time priority, and futures mkt = price/size priority 
- overnight corp action adjustment, official close price logic 
note: pro-rata here means, if 3 orders are at the same price, and the size is order A = 100, B = 80, C = 50, 
      then the execution size is allocated to their ratio 10:8:5 for each. 

# [transparency] 

- quote (pre trade) 
  - price, size, time (other info like owner of the order may be revealed depending on the exch) 
- trade (post trade) 
  - price, size, time (other info like trade condition may be revealed depending on the exch) 
==> how transparent do we make all the info ? 
it's common that full order book is not revealed. 
especially "dark pool" ATSs tend to have very opaque order book, some allow "hidden order" 
this is good for block trades (large order) because you can place your large orders without displaying that order size to the rest of the world. 
but then it is harder to discover the right market price for the instrument. 
--> the answer is usually you have transparent place like stock exch by which you know the fair market price, and then you place your block order to ATSs. this assumes the instrument is fairly liquid. 
NOTE: the trend is order price is better discovered with transparency, but size is better discovered with opacity. 
ATS (e.g. dark pool) uses various price discovery/order matching methods. some are periodic auction, opaque continuous crossing, negotiated (when two IOI match, they enter into negotiation mode to discuss price/size), advertized (only a loose IoI is advertized, with price/range, but no size) 

# [OTC trades]  fragmentation VS centralization 

ADR lets you trade foreign instruments in the US. that's a form of OTC from primary mkt's perspectives in their home countries. 
some ATS/ECN may operate outside primary mkt hours. but price/liquidity may be worse. 
some ATS/ECN offer additional features, e.g. lower ticksize, lower fee, more special order types, diff degree of transparency, more rebate for liquidity maker/taker, etc 
ECN (in north america) ≈ MTF (in EU) 
many ATS/ECNs lead to "fragmentation" - its ramification is that (as of 2015) you can only really support price priority, and not time priority. 
also you get more complexity, like ISO that effectively lets you violate NBBO. 
some countries have only one exch, no secondary venues. i.e. centralization which leads to its own benefits. like economies of scale, if everybody trades at one place than multiple fragmented venues, you can probably reduce the cost/fee per trade to cover the same technology infra. 
some ATS uses primary mkt's mid point as criteria for matching orders. e.g. mkt orders (when both sides are available) are filled at primary mkt's mid point. limit orders are filled on aditional condition that it's better than primary mkt's mid point price. 
in terms of fragmentation/diversification of execution venues, (in mifid term) there is SI (systematic internalizer) which is like a risk/principal trading that fills client orders to improve client's execution quality. essentially client-facing market making. just like exch-facing market making, if you do it right, you make money. 
bond market has no central exchange but has an extensive inter broker/dealer network, which pretty much offers a centralized order book. 
historically, we cycle between fragmentation and centralization. (some venue wins and takes over others, get more centralized, then less competition leads to the increased cost, then other venues get spawned) 
###  reporting, clearing & settlement 
- reporting to both buyer & seller, and also regulatory authority as needed. 
- clearing is just a preparatory step before settlement. clearing agency validates both parties have assets/funds. 
- settlement is the actual exchange. mostly just book keeping. settlement date used to be T+5, but now T+1 (eventually likely T+0) 
==> getting increasingly automated. also, there is a "central counter-party" service where you basically pay some fee and CCP becomes the intermediary risk owner. so buyer just delivers funds to (and gets assets from) CCP, and the seller delivers assets to (and get paid by) CCP. 
###  TCM & TCA (trade cost measurement & analysis) 
explicit cost 
- broker fee/commission 
- tax 
implicit cost (harder to measure) 
- spread cost 
-- quote spread: ap-bp 
-- effective spread: mp-tp 
-- realized spread: mp5-tp    // mp5 is mp 5 min after tp happened 
- mkt impact 
-- temp (includes spread cost) 
-- perm (one way is to observe overall order imbalance) 
- timing cost : longer you wait, more volatility of price & liquidity, i.e. more risk 
- delay cost : price change between when the decision was made and when an order is sent. 
              (it may take a bit of time to decide which venue to send an order, which algo to pick, etc) 
- opportunity cost / price trend : when you didnt trade when mkt condition / price trend was favarable 

# [common benchmark] 

- open price 
- arrival price 
- decision price (when investor decides to send orders) 
- prev close 
- vwap 
- twap 
- ohlc average 
- close price 
###  electronic trading 
has led to cost reduction, automation, easier access, increased capacity (for handling bigger order size/trading volume), low latency. 
==> naturally led to bigger order size/trading volume. 
easier access: used to be a clear distinction btwn brokers & clients but now clients can, for example, place orders directly to exch via DMA, or some ATS facilitates client-to-client (inter-client) platform. so the distinction is now blurry. 
note: avg trade size has decreased over the years, because algo trading does more granular order slicing to minimize market impact. (also reduced per-trade cost resulting from electronic trading incentivized such a trend also) 
###   order types    ### 
lets think about "immediate cost" for mkt orders:  (ap-bp) * 0.5 
- assume your mkt order size is less than bas, bbs 
- because if you buy at ap, and immediately sell at bp, then you did 2 trades, and lost ap-bp overall. 
- so you cost per trade is (ap-bp) * 0.5 
- obviously, if your mkt order size is bigger than bas, bbs, then you walk deeper into the book, so your cost increases. 
##  order conditions 
- GFD (good for the day) : often the default type. this is GTC set at EOD 
- GTC (good till cancel) 
- GTD (good till date) : GTC at a particular yyyymmdd 
- GAT (good after time/date) : trigger after a specific time (rare, often a feature of order scheduler) 
- many other variants. e.g. good this week/month. good till expire (for futures) 
[on auction/open/close] 
- participate in a particular session 
- next auction: trigger at next auction trade (morning, intraday, close) 
- MOO (mkt on open), LOO (limit on open)   // configurable to make residual remain on order book or cancel 
- MOC (mkt on close), LOC (limit on close) 
[fill insruction] 
- IOC (immediate or cancel) limit order : aka execute-and-eliminate, immedaite-liquidity-access, fill-and-kill 
-- allows partial fill 
- FOK (fill or kill) : IOC with 100% fill requirement. it should be called fill all immediately or cancel 
- AON (all or none) : FOK with no immediacy requirement. NON-displayed on order book (exch has to track this on other conditional order book) 
- there are variants. like IOC (or AON) with min-vol requirement 
- Minimum Quantity Order  # aka Minimum Acceptable Quantity (MAQ) 
-- a limit order with a condition that it executes only when at least a specified amount by a customer can be filled. 
-- NON-displayed 
[linked/contingent order] 
- OCO (one cancels other): suppose you have a long pos on some name, and placed a sell order at a high price (to gain profit) but also placed a stop loss sell order. if one executes, the other should be immediately canceled. OCO lets you instruct the linkage. 
- OTO (one triggers other): e.g. if your buy order gets filled, then it triggers stop loss sell order. 
[directed order] 
- directed to a specific MM/BD 
[preference order] 
- you can specify the preference for particular MM 
[routing instruction] 
- regNMS/NBBO rule to ensure clients the best price. but this means clients may get charged with routing fee & veneu-specific fee (like fee for liquidity taker) 
-- do-not-route : destination venue cannot route the order to other venues. only exec locally. (aka do-not-ship, post-no-preference) 
-- directed routing: dest venue routes it to other specific venue. you can do this if you don't have direct membership to the ultimate dest venue. but the routing venue may charge routing fee. 
-- ISO (inter mkt sweep order) : when you instruct (just execute everything in one venue, rather than routing to other venue to meet NBBO) 
-- flash order : you send orders then cancel within milliseconds (like 30ms), so you may attract others to a certain venue. obviously controversial. being deprecated. 
- odd lot 
- short sell (uptick rule: you can only short sell when uptick (or even tick)) 
- settlement type (cash settlement for T+0, instead of T+1/3 so you can claim dividend rights) 
- anonimity of orders 
[hybrid order] 
- MTL (market to limit) order : mkt order that becomes limit order at the best price if any residual (not filled) 
- MwP (market with protection) order: mkt order that is converted to limit order for protection. 
                                     (CME forces all mkt order to be MwP) 
[conditional order] 
- stop order       # after tp reaching a threshold price, then becomes mkt order 
- stop limit order # after tp reaching a threshold price, then becomes limit order 
NOTE: conceptually, stop order is to stop/cut "loss" order. so if you are long, and your stop (loss) order should trigger once price goes below the threshold, 
to ensure loss-cut. (FAQ: why dont we just send a limit order ? because stop order is hidden until it is triggered/activated) 
NOTE: as you can imagine, once you manage to bring the price down, then many investors' stop loss order trigger to sell, further bringing down the price, at that point you can buy back, then you make money. this type of manipulative trade pattern is well monitored by exch/regulator. 
NOTE: typical exam question: 
execution at: 
below best ask | above best bid 
buy limit      | sell limit 
sell stop      | buy stop 
sell stop limit| buy stop limit 
- "trailing stop order" 
-- instead of absolute tp, we set the trigger condition as "if tp drops by more than X (dollars or percent) since order placement" 
-- commonly used to close out position, and lock in profit. 
- "contingent order"   # aka "if-touched order" 
-- the opposite of stop order 
-- if certain tp reached, then activate mkt (or limit) order to buy/sell, commonly used to enter into position. 
-- if tp goes below threshold, then buy. or if tp goes above, then sell. 
-- (some venues lets you set some other asset price as trigger. like some stock index) 
- buy downtick order : only buy when tp2 > tp1 
- sell uptick order : only sell when tp2 < tp1 
[hidden order] 
- stop order is kind of a hidden order 
- a completely hidden order is a limit order not displayed on order book. it is controversial, because it leads to uncertainty, wider visible spread, less transparency. (but ATS/dark pool thrive on opacity because it lets investors hide their big order) 
-- you can discover/detect/ping hidden liquidity by sending sample IOC 
-- hidden order is usually given lower priority than visible order at the same price 
- iceberg order  (aka drip order. aka reserve order) 
-- exch slices a big order into pieces and activates/displays them one by one as they get filled. 
-- if your order scheduler / trading engine is smart, can you implement iceberg without using exch iceberg order type? 
--- yes & no. essentially the same, but exch iceberg is immediate upon crossing on order book, while your custom icerberg slicing requires the trade confirmation which usually has bigger latency. but it lets you do a more elaborate price adjustment, etc 
[discretionary order] 
- not-held order : gives trader a complete discretion as to how to work the order (timing, price) 
- discretionary order : another limit order but with a discretionary range to go up/down. 
-- e.g. a buy limit order at $12.46 with a discretionary range of $0.03, meaning he is willing to pay up to $12.49. 
NOTE: displayed price will be $12.46. and once a match-able order comes on the other side, then a discretionary order becomes IOC. (some venues like nasdaq, nyse arca support min quantity also). note: usually other visible orders take priority than your discretionary order. 
- pegged order 
-- a limit order with dynamic price. e.g. peg on bp (or ap or mp) with some offset (which can be tick or absolute dollar amount). like a bid order 1 tick below best bid price. when some big-enough sell orders come in, filling orders (higher priority than yours) then also filling yours, only then your pegged order can be filled. 
-- you can peg your buy order on ap with an offset too. also, venues like NYSE support min quantity so your pegged lim price change doesnt get triggered by a small order. 
-- primary peg.  # pegged to the same side of the best bid/ask price. always displayed. 
e.g. a primary peg to sell at $10.00. then if best ask is beyond $10.00, like $10.05, $10.09, the order pegs to $10.05, $10.09 accordingly. but if best ask goe\ 
s below $10.00, then the peg stays at $10.00. 
-- market peg    # pegged to the opposite side of the best bid/ask price. i.e. marketable. this is immediately executed (assuming enough size) 
-- midpoint peg  # always UN-displayed (may exec at "sub penny" increment) 
NOTE: both primary peg and midpoint peg can have an "offset" amount. then BOTH (including primary peg) becomes "not-displayed" 
[routed order type] 
- passthru order: an order that allows routing to other venues to seek liquidity. essentially, a passthru order is IOC at the original dest venue then sent as a limit order to the subsequently routed venue. 
- also we can make passthru orders more elaborate by routing over multiple hops. i.e. venue 1 -> 2 -> 3 which may include lit (exch) or dark venues (ATSs/darkpool). e.g. Nasdaq offers, for example, 
-- MOPP : route to other regNMS for displayed size, then residual to Nasdaq 
-- DOTI : sweep nasdaq, then route residual to NYSE/AMEX 
-- SKIP : sweep nasdaq, then route residual to regNMS venues, then back to nasdaq 
-- SCAN : sweep nasdaq, then route residual to alt venues (incl regNMS, ATSs), then back to nasdaq 
-- STGY : SCAN in a loop 
-- others 
note: as above, as order type becomes elaborate, the distinction btwn order type and trading strategy becomes blurry. 
[firm/committed VS uncommitted/negotiated order type] 
- firm/committed order means ready to execute immediately 
- uncommited order type (allowed in some ATSs) means, when the order finds a match, you (as the owner of the uncommitted order) get to take a moment to review and reply yes or no.  to prevent unfaithful behavior, ATSs will usually keep some score of success rate of uncommitted order senders. so yes, uncommitted order is like IOI. 
- negotiated orders : a kinf of uncommited order, semantically speaking. but usually this means bilateral negotiation mode orders when a potential match is found. two parties enter into negotiation. again, some score tracking is there to identify unfaithful participants. two parties can be any participants in ATSs. could be investors or BD. 
[contingent order types] 
at this point, you can combine all order types to come up with elaborate order instructions. 
- linked order (aka "OR order") : e.g. if order A is filled, then reduce the size of order B by the size of order A. 
- contingent order: this is a further sophisticated version of linked order where you can even configure dependency of orders across diff assets. people do this to buy spread btwn muliple legs futures. e.g. you buy september contract and sell december contract, then you bought the spread. your order price & size may be dynamically adjust in order to buy spread at $4, for example. 
- implied order: buying/selling spread became common that deriv exch offers a separate order book for spreads. 
 a buy order for Sept 1000 contracts at $123, and a sell order for Dec 900 contracts at $123.5, then we say there is an implied order of Sept-Dec spread 900 contracts at $0.5 (size is whichever the smallest of the two outright orders) 
 similarly, if you have a buy order for sept, a sell order for dec, and some actual order for spread sept-dec, then you can derive "implied order" for one of the two ourrights (sept or dec). 
 "implied orders" are a big thing - a big portion of futures trading (10~40% dependeing on the venue) is done on implied orders. 
###   common exec algos    ### 
##  categories 
here is one way to categorize 
(1) impact-driven (≈ scheduled, static, structured, but not always) : aims to min impact 
   - twap (time), vwap (vol), pov (vol), min impact (impact) 
(2) cost-driven : balancing (1) & (3) : aims to min cost (including impact, timing risk, price trend) 
   - implementation shortfall 
   - adaptive shortfall 
   - mkt on close 
(3) risk-driven (opportunistic - more dynamic, reacting to mkt conditions like price/risk/liquidity): 
   - liquidity seeking 
   - price inline 
   - pair/spread trade 
##  common parameters 
[startTime, endTime (or duration)] 
- usually specified. default can be now (or mkt open) for startTime, and mkt close (of today or a later date if multi-day order). 
[must fill] 
- if yes, it will try to be aggressive as needed to fill 100% (at the expense of impact/cost) 
- aggressive/neutral/passive 
[volume pct limit (max & min)] 
- max vol pc means never trade more than x% of actual mkt vol 
- min means at least trade this much. (again, may come at the expense of impact/cost) 
- generally dont try to control signalling risk by this paramter alone. use a more elaborate min-impact or liquidity-seeking algo. 
[limit price] 
- for some floor/cap protection. especially if the algo is not price-sensitive, it'll be useful to have limit price specified. 
- whether to participate in open/intraday/close auction. if yes, at what percentage for the order. etc 
###  (1) impact-driven algos 
often primary focus is on order slicing in such a way that minimizes impact (on asset's price). 
simplistic twap/vwap algo just follows pre-determined schedule based on statistically projected trajectory. i.e. no regard for actual live price/volume. 
whereas pov actually considers live volume data, and min-impact algo gets even more elaborate. 
##  (1.1) TWAP 
to achieve TWAP, uniformly execute volume across startTime-endTime duration. this usually means keep sending slices of order in some time interval. 
|         .        // target volume profile/schedule 
|       . 
|     . 
|   . 
| . 
------------- time 
but volume distribution is not uniform, so you may get behind or ahead of the target trajectory. then we can adjust the urgency (aggressive/neutral/passive) of your order. if we are ahead, we may afford to put in some passive order to improve exec price (lower impact costs) or avoid gaming attempts by competitors. (though the question becomes are we trying to achieve TWAP or beat TWAP benchmark ?) 
to avoid "signalling" risk (i.e. gaming attempt by others), your TWAP algo may inforporate some randomization on order size, order transmission interval, etc. 
some variants of TWAP algo may adjust its schedule based on market price. (but it effectively becomes price-inline algo) 
common params: 
- startTime,endTime 
- rigidity of tracking: how close do we stay with the target volume schedule ?  (one way to control this is via urgency param) 
- interval frequency: how frequently do we trade ? do we allow randomization to vary intervals ? 
##  (1.2) VWAP 
in a way, VWAP is a true reflection of mkt. easy to compute. so VWAP benchmark is extremely popular. 
unlike TWAP where we needed to uniformly distribute target volume schedule across the target time window, for VWAP, we dont know ahead of time what the volume distribution looks like. so volume prediction becomes important. 
for liquid names, historical data gives a reasonable estimate. you just assign weights for each time interval. (i.e. this simplistic version VWAP algo doesnt consider current mkt price/volume) 
the overall performance is a function of how well we predict volume distrib & how well we keep stay on course of the volume schedule. 
some variants of VWAP algo monitor and adapt to current mkt conditions (price/volume, short term trend, etc) but then it effectively becomes a new hybrid algo that incorporates VWAP & POV and other dynamic algos. 
common params: 
- startTime, endTime 
- rigidity of tracking: just like TWAP 
- dynamic adj: we may adjust order if we have some extra insights/expectation of mkt condition trend. one param may be "tilt" which lets you tilt your volume distrib earlier or later or toward certain intervals. (again this makes VWAP algo no longer VWAP algo in a pure sense) 
==> in general, if you have no specific view, then just go with VWAP, otherwise choose alternative algos. 
##  (1.3) POV     // aka volume-inline 
trading schedule for twap & vwap may be relatively predetermined, but is more dynamically determined for POV, as we react to live mkt volume. 
note: you have to account for your own participation to compute the realized percentage. 
if your target is 20%, and you see 10000 shares traded. then if you trade 2000 shares, your participation rate is: 
  2000 / (10000 + 2000) = 17% 
so your real target percentage (excluding your own trade) is  1/(1-p) - 1  where p = 0.2 in this case.  so 1/(1-0.2) - 1 = 0.25 
  2500 / (10000 + 2500) = 20% 
if multiple BDs' POV compete, you get ripple effect of driving up volume. this is dangerous, especially POV has no inherent price dependency/sensitivity. so controlling limit price is important. 
note: when limit price is set, perticipation rate should only consider volume that fell within the limit price reach. otherwise, if most of the mkt volume happened outside your limit price, and once the mkt price comes back within your limit price reach, you'd have to participate crazy a lot. 
to avoid signalling risk, you may have to vary order placement pattern, urgency (aggressive/neutral/passive) etc 
fragmented mkts make it harder to track. i.e. multiple order books (available volume) to track. 
in general, we always want to minimize impact cost. e.g. one huge block trade can throw off our participation schedule. then aggressively trying to catch up immediately may not be a good idea. so we protect against it with safegurads with limit price, or comparing target trade volume with currently available volume on order book (i.e. checking liquidity), or by setting volume filter based on trade types (e.g. exclude block trade, or consider only primary mkt volume, etc). 
 to this end, some POV variants may use volume prediction, price adaptive logic (even comparing against other assets price within the same index sector, ETF, etc) 
common params: 
- startTime,endTime 
- POV target percentage 
- rigidity of tracking : how far behind/ahead of schedule can we get? 
-- its sub controlling param may be urgency of aggressive/neutral/passive for each order. 
-- we may have to get aggressive for illiquid assets, as it's harder to catch up once getting behind. 
-- aggressive means we may control "tilt" param to tilt participation rate more toward earlier. 
- limit price 
- volume filter based on trade types 
-- we may want to exclude certain trades (OTC, block trades, secondary VS primary mkt volume, etc) when we consider the total eligible volume of which to participate. 
note: e.g. you wan to buy 2000 shares of IBM, with POV 5% with some startTime,endTime window. you may achive 2000 well before endTime or if endTime comes while keeping in track with 5% POV rate. so you may want to configure extra param to decide whether to go exceed 5% in such a case to aggressively achieve 2000 or not. 
##  (1.4) minimal impact 
think about how to minimize impact cost of twap,vwap,pov. following mkt data based benchmark may reveal trading pattern i.e. signalling risk. 
one way to stay stealthy is to use dark pool/ATS (and hidden order types & IOC in lit venues) 
common param: 
- visibility: how much of your order to work in stealth mode. 100% means completely dark. (but that leads to uncertainty of exec) 
-- often we use a combination like 80% dark, 20% lit, to strike the right balance. 
-- to aid with that decision, BDs use models to estimate the probability of how much is likely to be filled at ATS, as well as impact cost models. 
    (at this point, it overlaps with other cost-based liquidity-based algos) 
###  (2) cost-driven algos 
algos that try to minimize transaction cost. 
 |  . 
c|   ..              // cost == mkt impact cost 
o|     \..           // risk == time == volatility == stddev of price 
s|        \.. 
t|           \... 
so we need to strike the right balance by considering investors urgency, priority. 
##  (2.1)  IS       // implementation shortfall   aka  ArrivalPrice algo 
it's just a benchmark defined as   shortfall = cost = arrivalPrice - avgExecPrice 
where arrivalPrice is usually tp or mp as of order arrival. 
(i.e. it's a very well predetermined benchmark, and we favor trading as early as possible to reduce timing risk, while not trying to incur too much mkt impact cost) 
while many variants exist, a common IS algo tries to determine optimal trading horizon (i.e. decides endTime), based on some intricate cost analysis/estimate model that considers such factors as 
- order size, liquidity 
- volatility 
- spread 
- startTime,endTime constraints 
- urgency 
e.g. a smaller size order, more urgency (i.e. aggressive), smaller spread, higher volatility 
     --> IS tends to give a shorter trading horizon 
to minimize timing risk, IS tends to tilt toward the beginning. i.e.start aggressive. 
once optimal trading horizon is determined, then the rest can be variants of vwap,pov algos. 
vwap is more static, so we just decide optimal trade schedule. 
pov is more dynamic, so we decide optimal participation rate. (in theory, more adaptable to changing mkt conditions) 
optimal participation rate is a function of mkt impact & timing risk 
some IS variatns may re-optimize trading horizon. 
overall, the quality of cost model is critical. some tries to estimate cost, by monitoring/predicting short-term price volatility, or even considering implied volatility from options mkt to gauge intraday volatility. 
common params: 
- benchmark price : arrivalPrice 
- urgency (aka timing risk tolerance) 
- startTime,endTime: optimal trading horizon is decided within this constraint 
- limit price, volume limit, etc 
##  (2.2)  adaptive shortfall 
an IS algo with adaptive behavior. specifically reacting to mkt conditions (e.g. price, order book depth, liquidity) 
there are typical strategies. 
aggressive-in-the-money (AIM) : buys aggressively when mkt price goes down (thinking it will revert up soon) 
   passive-in-the-money (PIM) : buys passively when mkt price goes down (thinking it will keep going down) 
                                (i.e. buys aggressively when mkt price goes up, thinking it will keep going up) 
note: this is still an IS algo, so there is the usual step of estimating optimal trading horizon (deciding endTime), for some target participation rate, then the above AIM/PIM aspect kicks in, merely as extra feature, to dynamically adjust (in real time) its volume schedule/participation rate, which makes the whole algo more opportunistic. if you really want an algo that predominantly focuses on price movement, then go for other algo like price-inline algo, 
it really depends on price trend (and other mkt conditions), but AIM tends to get better price with higher risk. 
common param: 
 - adaptation type : AIM or PIM 
##  (2.3)  departure price algo / mkt on close algo 
unlike arrivalPrice algo that decides optimal endTime (for a given startTime), departurePrice algo decides optimal startTime (for a given endTime) for a given order. 
if you set departurePrice = closePrice (which is a very common benchmark, as it's used for many data calc, like daily return, NAV), then it's effectively mkt on close algo. 
departure price is not known. departurePrice algo estimates optimal trading horizon (i.e. startTime in this case) given some target participation rate, based on some intricate model that considers data like volatility, volume, etc. 
recall target participation rate is decided based on mkt impact & timing risk. let's say pov target 20%, and based on historical & realtime volume, a model can predict volume, and decide optimal startTime. 
common param: 
 - urgency (risk tolerance): aggressive/neutral/passive. aggressive means avoid timing risk at the expense of mkt impact. so this means pick startTime close to endTime. 
 - auction participation percentage: how much trade is allowed in auction for this order ?  0~100% 
###  (3) opportunistic algos 
algos that try to exploit favorable mkt conditions (price, liquidity/volume/orderbook depth, volatility, or other factors) 
##  (3.1) price-inline algo   // PI 
recall POV adapts to mkt volume. PI has some underlying impact-driven algo (like vwap/twap/pov) with additional functionality to adapt to current mkt price (compared to some benchmark price - which is often arrival mp) 
e.g. for a buy order, if cp is much less than benchmark, then it is deemed favorable, vice versa. 
note: some flavor of PI may use a more elaborate benchmark like momentum, or sector index/etf price, etc. 
recall AS algo. for price adaptive feature, PI uses essentially the same AIM/PIM strategies. i.e. AIM means trade agggressive when price is favorable (aka in the money), while PIM trades passively when price is favorable. so AIM/PIM part will control order size/frequency (participation rate) of the underlying impact driven algo. 
common param: 
 - benchmark: usually mp 
 - adaptation strategy: AIM or PIM 
 - adaptation threshold: how much of underlying algo's schedule (order size/frequency or participation rate) can PI alter ? 
 - (base participation rate) : if using POV as underlying algo 
 - price level: specifies price level/interval by which to adjust order size/frequency or participation rate. 
                e.g. every $0.3 or 15 bps, adjust order size by X 
##  (3.2) liquidity-driven algo       // a fascinating topic 
more liquid ≈ more volume, more orderbook depth, narrower spreads 
recall how POV reacts when traded volume increases. liquidity-seeking algo can similarly react when liquidity (based on more factors like orderbook depth, narrower spreads, etc) changes, to adjust order size/frequency or participation rate. 
fragmented mkts (multiple venues) make liquidity-seeking hard.  we can build aggregated (virtual) orderbook, but need to account for how diff venues have diff fee structure & latency characteristics. 
recall such aggr orderbook only facilitates price priority, and no longer time priority. so, commonly, instead of time attribute, we attribute "probability" for each price level. i.e. how likely to get filled.   (so we get price-probability priority setup) 
  [aggr buy] 
price size prob 
 103  5000  60% 
 102   900  79% 
 101  3000  14%   // hidden 
 100  1400  90% 
  99   600  83% 
  98  1800   4%   // hidden 
often BD quants build a fancy model to estimate/predict the above probability, based on (a lot of) historical data. 
yes, even hidden liquidity (hidden orders or dark pool) can be predicted. 
to track the presence of hidden orders, you need to analyze reported trades & order book states (to build a predictive model) 
to exploit hidden order liquidity, BD can send "liquidity ping" IOC/FOK order. 
also, in terms of liquidity-driven algo, signaling risk is always a concern (especially illiquid assets). so commonly, BDs e.g. (1) use IOC/FOK/iceberg and dont use plain limit order, (2) cross aggressively only when desirable liquidity becomes available, (3) cross only portion of such liquidity to keep best price unaffected, so as to not expose our appetite. 
(this is a complex topic, more details later) 
common param: 
 - visibility: how much of order size can be exposed on lit venue. to be stealthy, use IOC type of order andor opaque ATS/darkpool 
 - some benchmark : e.g. to determine how 'favorable' mkt condition is. 
##  (3.3)  pair-trading algo        // two-leg trading 
suppose, thru historical quant stat data analysis, you identify two assets (price) are highly positively correlated. lets say ABC & XYZ. 
pair-trading is you buy ABC & sell XYZ. in theory, this is a mkt neutral strategy. because the risk from each trade offsets other. 
the benefit being you are protected from mkt wide movement. 
to flatten your position, you just reverse the buy/sell legs of the same pair. 
what you did is you essentially bought their spread.  pair-trading aims at stat arb. one approach is mean reversion method. you calc historical mean of the spread, and if the spread decreases by more than 2-stddev from the historical mean, then it's your chance to buy that spread cheap. similarly if the spread widens a lot, say by more than 2-stddev from the mean, then it's your chance to sell the spread. 
obviously, historical correlation may not predict future correlation. (two assets correlation can change legitimately) 
NOTE: instead of absolute spread the price, their ratio of their price is also commonly used. (essentially the same thing) 
NOTE: what "price" ? - it can be any combinations of tp,ap,bp,mp, etc (commonly tp or mp) 
to be purely "mkt neutral", both legs must be cash balanced. i.e. you buy/sell the same dollar amount in both legs. 
if one asset is significantly illiquid than the other, then trading on the liquid asset really should depend on the trading of the iiliquid asset. but you can control their dependency from each other by some parameter. 
common param: 
 - spread/ratio : mean, threshold (like ±2 stddev) 
 - leg linkage: some form of linkage logic to group two legs of the pair trading order 
 - dependency level: to control how independently two legs can trade 
 - others : e.g. if dollar amount is specified, you may wanna add other cap like you cannot buy more than 15% of the total volume. etc 
###  (4) other exec algos 
as algo exec expands from equity to asset class (futures, options, derivs, bonds, etc), new flavors of exec algos emerge, especially focusing on the characteristics that are not common in equity asset class. 
bond price is affected by interest rates. 
options price is affected by implied volatility. 
##  (4.1) multi-leg trading algo 
we've already seen 2-leg trading. we can further generalize this for more advanced trading strategies. e.g. basket/portfolio trading. 
in bond trading: 
 - coupon "roll" : buy new issue, and sell current issue. 
 - barbelll : buy both long & short maturity issues. 
 - butterfly: buy both long & short matruity issues, and sell intermediate maturity issue. 
in futures trading, spread trading is so common, many exchanges offer a dedicated order book. 
 - spread bull(bear) : buy(sell) near contract, sell(buy) 2nd nearest contract. 
 - butterfly spread long(short): buy(sell) nearest & 3rd nearest contracts, sell(buy) 2nd nearest contract. 
 - condor spread long(short): buy(sell) nearest & 4th neatest contracts, sell(buy) 2nd & 3rd nearest contracts. 
options trading get more complex, as you have put/call, diff strike price, etc 
 - collar : buy put & sell call at higher strike price 
 - straddle : buy call & put at the same price. (so if underlying asset price goes up/down drastically, you profit. 
 - strangle : buy call at a price, buy put at lower price. 
there are many well established techniques. hedging (beta, delta, gamma, etc), arbitrage (dividend, index, futures, options, ADR) 
multi-leg algo can have each leg being diff asset. 
more details later. 
##  (4.2) volatility-driven algo 
there are models for option pricing, based on such factors as underlying asset price volatility, time to expiry, interest rate. 
call option price c(s,t) = sn(d) - k*e^(-rt) * n(d - σ * sqrt(t)) 
            ln(s/k)+(r + σ^2 / 2) 
where d =  ----------------------- 
                 σ * sprt(t) 
      s = underlying asset price 
      t = time to expiry 
    n() = standard normal cumulative distrib function 
      σ = asset price volatility 
      r = interest rate 
      k = strike price 
===> given current mkt option price, and other data (underlying asset price, interest rate, etc) we can derive "implied volatility" which trader often use to make decisions. imp vol lets traders generalize across diff issues (with additional comlications). as algo exec services expands to cover deriv mkts, some exec algo that uses imp vol as benchmark will likely appear. 
for options trading, some venue offer GWAP (gamma weighted avg price) as benchmark which is VWAP that considers gamma (second deriv risk measure) that quantifies the degree of "delta" change relative to the change of underlying asset price. basically, there can be thousands of options contracts for one underlying asset (like IBM stock), and computing vwap for each contract is not helpful as each contract is not so liquid, so GWAP offers a way to take into consideration vwap of the underlying asset, and other factors. to deeply appreciate all this, you need solid foundation in options as a financial instrument. 
###    TCA  (transaction cost analysis)     ### 
one academic definition is, cost is something paid by buyer that is not received by seller. 
cost affects returns (obviously). so we want to measure/analyze it accurately, and minimize it. 
per-order cost typically ranges 5 ~ 50 bps (or more) of the value. 
one way to measure is by comparing actual trade VS paper(cost-less) trading. the diff in profit is the cost (aka slippage) 
[order layering tactics] 
scale order: when you want to buy 1000 shares of IBM, you may split a buy order of 300 shares at $33, another 500 shares at $32, then 200 at $31. this may be better than waiting for one slice to be filled then sending another because all your orders have time priority on the order book. but sometimes waiting gives you better price. to be discussed further. 
###  open end fund VS closed end fund       # aka open/closed end investment 
open end fund is what traditional mutual fund is. the fund manager can issue as many as they can sell (though many mutual funds dont sell unlimited qty) and usually price once per day at EOD. 
closed end fund is essentially ETF, with a fixed number of shares, being listed/traded on stock exchange., being dynamically priced real time by supply/demand 
###    market making    ###  aside 
a form of principal trading. 
according to dodd franck, volcker rule, there can be 3 forms of principal trading permitted in investment banks. 
(1) underwriting (like you are the bookrunner for IPO, and you can have principal pos for price stabilizing) 
(2) risk mitigating hedge. (to facilitate client order exec, BD may undertake principal positions, or some BD offer benchmark-guarantee trades on a principal basis. in these cases, the purpose is just best exec for client orders. but since principal position is held, to offset risk, you can do principal trading for risk mitigating hedge purpose) 
(3) market making 
you register as market maker (aka designated specialist in NYSE term, aka liquidity provider/facilitator in literature) in stock exchanges for specific names. then you are obligated to provide two-way quotes (ask & bid) continually, based on your RENTD (reasonably expected near term demand). this requires you manager your own principal position/inventory. but the spread is your profit, as well as any pnl from your position. (read series 55 notes for more details) 
so market making desk does this full time. but aside from this, there maybe what is called a risk trader who sits among sell-side sales trading desks when they decide to undertake client order on a principal basis, then it is still semantically 'market making' but here it is really just for the pure purpose of client facilitation, rather than being market making trading desk across stock exchanges in general. 

  1. 2018-10-13 23:42:03 |
  2. Category : financial
  3. Page View:

Google Ads