{"text_format":"1","workbook":"xlsx","n_sheets":16,"sheets":["In class","Order Routing","Exchange","Orderbook","Price-Time priority","Orderbook Structure","Chart1","Prob of fill","Market Order","Limit Order","Stop Loss","IOC","Iceberg","Pegging","Discretion","Pro-Rata basis"],"not_rendered":{"charts":3,"images":0,"macros":1,"external_links":0,"defined_names":0,"comments":0,"pivot_tables":0},"unopened":[{"sheet":"Chart1","index":6,"reason":"not_a_worksheet"}],"bounds":{"document_bytes":16777216,"sheet_cells":100000,"rows_first":2000,"rows_last":500,"rows_between":2000,"halvings":0,"cell_chars":16384,"cell_head_chars":4096},"cells_cut":0,"cells_raw":0,"read":"whole","date_system":"1900"}

{"sheet":"In class","index":0,"n_rows":35,"n_cols":6,"rows_kept":35,"cut":false,"hidden":false,"merged":[[6,2,6,3],[33,1,33,5],[34,1,34,4]]}
[null,null,"ALGO TRADING FIRM"]
[]
["Generating HYPOTHESIS (FINANCE)",null,"BACK-TEST (STATS and CODING)",null,null,"EXECUTION (CODING and FINANCE)"]
[]
[]
[]
[null,null,"Two Main stakeholder"]
[]
[null,"Individuals/Corporates:",null,"Institutions:"]
[null,"Traders/Investors",null,"Brokers, clearing houses,Exchanges"]
[]
[null,"Objective: To increase the PnL",null,"Objective: Increase profits + manage risks"]
[]
[]
[]
[null,null,"Hedge Fund Singapore"]
[]
[null,"$200 million/week"]
[]
[null,null,"BUY",null,"SELL"]
[null,"Monday"]
[null,"Buy Securities worth","$100 million",null,"$100 million "]
[]
[null,"The total traded value in a week is $200 million"]
[]
[null,"Broker A",null,"Broker B"]
[null,"saves 1 cent per $100 traded more than Broker B"]
[]
[null,"Broker A is 1bps better than Broker B"]
[null,{"$f":"200*1000000*0.0001","v":20000},"$ per week"]
[null,{"$f":"B30*52","v":1040000},"$ per year"]
[]
[null,"Hedge Fund's Returns:"]
[null,"Their returns would be x% +0.01% with broker A"]
[null,"1 bps is known as the broker alpha"]

{"sheet":"Order Routing","index":1,"n_rows":26,"n_cols":8,"rows_kept":26,"cut":false,"hidden":false,"merged":[]}
[]
[]
[]
[]
[]
[null,"Broker and You"]
[null,"Broker (Could be in-house too)"]
[null,"You"]
[null,null,null,null,"EXCHANGE"]
[]
[]
[]
[]
[]
[]
[null,"Market Adapter",null,null,null,null,null,"Order Router"]
[null,null,null,null,"Strategy"]
[]
[]
[]
[]
[]
[]
[null,"Broker 1 parses the feed/punches the order in 2 microseconds"]
[]
[null,"Broker 2 parses the feed/punches the order in 4 microseconds"]

{"sheet":"Exchange","index":2,"n_rows":50,"n_cols":7,"rows_kept":50,"cut":false,"hidden":false,"merged":[[37,1,37,2],[39,1,39,2],[37,5,37,6],[39,5,39,6]]}
[]
[null,null,null,"EXCHANGE"]
[]
[]
[]
[]
[]
[]
[]
[null,null,null,"Orders coming in"]
[null,null,null,"Buyers/Sellers"]
[]
[null,null,null,"Brokers/Institutions"]
[]
["ORDERS"]
["SBIN, Buy order, Price $100, Qty 8"]
["SBIN, Buy order, Price $99, Qty 4"]
["SBIN, Buy order, Price $98.5, Qty 4"]
["PNB, BUY order, Price $399, Qty 6"]
["SBIN, Sell order, Price $101.5, Qty 5"]
["SBIN, Sell order, Price $102, Qty 1"]
["PNB, Sell order, Price $400, Qty 10"]
["SBIN, Buy order, Price $97.5, Qty 3"]
["SBIN, Sell order, Price $103, Qty 2"]
[]
[]
[]
[]
[]
[]
[]
["ORDER BOOK of SBIN",null,null,null,"ORDER BOOK of PNB"]
[null,"Prices","Qty",null,null,"Prices","Qty"]
[]
[null,103,2]
[null,102,1]
[null,101.5,5,null,null,400,10]
[null,"SELL",null,null,null,"SELL"]
[]
[null,"BUY",null,null,null,"BUY"]
[null,"Prices","Qty",null,null,"Prices","Qty"]
[null,100,8,null,null,399,6]
[null,99,4]
[null,98.5,4]
[null,97.5,3]
[]
[]
["Market makers: They have strategies to determine the fair price of an asset (most of them would definitely use order book data to calcuate the fair price)"]
["Eg: if a market maker calculates the fair price of asset as $100"]
["So he would send a buy order at say $99.5 and a sell order at $100.5"]

{"sheet":"Orderbook","index":3,"n_rows":72,"n_cols":9,"rows_kept":72,"cut":false,"hidden":false,"merged":[]}
[]
["9:45am","Stock","ABC"]
[null,null,"Order Book",null,null,null,null,null,"Assumption"]
["Level","Qty","Bid Price",null,"Ask Price","Qty",null,null,"If the market maker calculates that the fair  price is 100.2"]
[1,5,100,null,100.5,15]
[2,3,99.5,null,101,35,null,null,"bid offer @ 100"]
[3,10,99,null,101.5,5,null,null,"ask offer @100.4"]
[4,20,98.25,null,102.5,2]
[5,5,98,null,103,15,null,null,"If a taking strategy calculates the fair price at 100.2"]
[null,null,null,null,null,null,null,null,"It wont fire orders"]
[]
["A Buy order comes in @100.1 for 10 shares",null,null,null,null,null,null,null,"If a taking strategy calculates the fair price at 101"]
["10:00am",null,null,null,"Order Book"]
["Level","Qty","Bid ",null,"Ask","Qty"]
[1,10,100.1,null,100.5,15]
[2,5,100,null,101,35]
[3,3,99.5,null,101.5,5]
[4,10,99,null,102.5,2]
[5,20,98.25,null,103,15]
[null,5,98]
[]
[]
["A Sell order comes in @100.3 for 5 shares"]
["10:15am",null,null,null,"Order Book"]
["Level","Qty","Bid ",null,"Ask","Qty"]
[1,10,100.1,null,100.3,5]
[2,5,100,null,100.5,15]
[3,3,99.5,null,101,35]
[4,10,99,null,101.5,5]
[5,20,98.25,null,102.5,2]
[null,5,98,null,103,15]
[]
[]
["What happens if you place a buy order for 3 shares @ 101??"]
[]
["Order book after the trade"]
["10:30am",null,null,null,"Order Book"]
["Level","Qty","Bid ",null,"Ask","Qty",null,"You will get a fill of 3 shares at 100.3"]
[1,10,100.1,null,100.3,2]
[2,5,100,null,100.5,15]
[3,3,99.5,null,101,35]
[4,10,99,null,101.5,5]
[5,20,98.25,null,102.5,2]
[null,5,98,null,103,15]
[]
[]
["What happens if you place a sell order for 5 shares @ 99??"]
[]
[]
["Order book after the trade"]
["10:30am",null,null,null,"Order Book"]
["Level","Qty","Bid ",null,"Ask","Qty",null,"You will get a fill of 5 shares at 100.1"]
[1,5,100.1,null,100.3,2]
[2,5,100,null,100.5,15]
[3,3,99.5,null,101,35]
[4,10,99,null,101.5,5]
[5,20,98.25,null,102.5,2]
[null,5,98,null,103,15]
[]
[]
["You send a buy order@99.7 for 2 shares"]
[]
["Order book after the trade"]
["10:30am",null,null,null,"Order Book"]
["Level","Qty","Bid ",null,"Ask","Qty"]
[1,5,100.1,null,100.3,2]
[2,5,100,null,100.5,15]
[3,2,99.7,null,101,35]
[4,3,99.5,null,101.5,5]
[5,10,99,null,102.5,2]
[null,20,98.25,null,103,15]
[null,5,98]

{"sheet":"Price-Time priority","index":4,"n_rows":60,"n_cols":10,"rows_kept":60,"cut":false,"hidden":false,"merged":[]}
[]
["9:45am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["A Buy order comes in @99.5 for 10 shares"]
["10:00am",null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,13,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[null,10,99.5,null,null,"Your order will have a lower priority than "]
[3,10,99,101.5,5,"the rest of the 3 shares already at Level 2"]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["If a 3rd party sell order comes in @99 for 8 shares"]
[]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[null,10,99.5]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["the first 5 shares to get traded would be @100"]
[]
["Level","Qty","Bid ","Ask","Qty"]
[1,3,99.5,100.5,15]
[2,10,99.5,101,35]
[3,10,99]
[4,20,98.25,101.5,5]
[5,5,98,102.5,2]
[null,null,null,103,15]
[]
["The next 3 orders that get traded would be @99.5, but they won't be our shares"]
[]
["Level","Qty","Bid ","Ask","Qty",null,null,"Avg Trade Price",null,{"$f":"((H56*I56)+(H57*I57))/(SUM(I56:I57))","v":99.8125}]
[1,10,99.5,100.5,15,null,null,"Price","Qty"]
[2,10,99,101,35,null,null,100,5]
[3,20,98.25,null,null,null,null,99.5,3]
[4,5,98,101.5,5]
[5,null,null,102.5,2]
[null,null,null,103,15]

{"sheet":"Orderbook Structure","index":5,"n_rows":39,"n_cols":8,"rows_kept":39,"cut":false,"hidden":false,"merged":[]}
[]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty",null,null,"Question1"]
[1,2,100,101,1,null,null,"If I place a BUY order above 10% of the best ASK (or at Rs. 110) for 10 shares, What will be the best Ask price?"]
[{"$f":"A5+1","v":2},5,99.75,101.25,2,null,null,"The first 4 levels will get traded and therefore,"]
[{"$f":"A6+1","v":3},8,99.6,101.5,5,null,null,"The best Ask would be at 102 with 1 Qty left!"]
[4,10,99.25,102,3,null,null,"So this order removed $1 (102-101) from the top level!!"]
[5,9,98.8,102.5,3,null,null,"Question2"]
[6,11,98.5,103,2,null,null,"If I place a SELL order below 10% of the best BID (or at Rs. 90) for 10 shares, What will be the best BUY price?"]
[7,15,98.35,104,6,null,null,"The first 3 levels will get traded and therefore,"]
[8,7,98,104.5,7,null,null,"The best BID would be at 99.6 with 5 Qty left!"]
[9,9,97.8,105,8,null,null,"This order only removed $0.4 (100-99.6) from the top level!!"]
[10,5,97.5,106,9]
[]
[]
[null,null,null,null,null,null,null,"Structure of Order book on Buy Side and Sell Side"]
["Ask","Price","Cqty"]
[1,{"$f":"D5","v":101},{"$f":"E5","v":1}]
[{"$f":"A19+1","v":2},{"$f":"D6","v":101.25},{"$f":"SUM($E$5:E6)","v":3}]
[{"$f":"A20+1","v":3},101.5,{"$f":"SUM($E$5:E7)","v":8}]
[4,102,{"$f":"SUM($E$5:E8)","v":11}]
[5,102.5,{"$f":"SUM($E$5:E9)","v":14}]
[6,103,{"$f":"SUM($E$5:E10)","v":16}]
[7,104,{"$f":"SUM($E$5:E11)","v":22}]
[8,104.5,{"$f":"SUM($E$5:E12)","v":29}]
[9,105,{"$f":"SUM($E$5:E13)","v":37}]
[10,106,{"$f":"SUM($E$5:E14)","v":46}]
["Bid"]
[1,{"$f":"C5","v":100},{"$f":"B5","v":2}]
[{"$f":"A30+1","v":2},{"$f":"C6","v":99.75},{"$f":"SUM($B$5:B6)","v":7}]
[{"$f":"A31+1","v":3},99.6,{"$f":"SUM($B$5:B7)","v":15}]
[4,99.25,{"$f":"SUM($B$5:B8)","v":25}]
[5,98.8,{"$f":"SUM($B$5:B9)","v":34}]
[6,98.5,{"$f":"SUM($B$5:B10)","v":45}]
[7,98.35,{"$f":"SUM($B$5:B11)","v":60}]
[8,98,{"$f":"SUM($B$5:B12)","v":67}]
[9,97.8,{"$f":"SUM($B$5:B13)","v":76}]
[10,97.5,{"$f":"SUM($B$5:B14)","v":81}]

{"sheet":"Prob of fill","index":7,"n_rows":62,"n_cols":12,"rows_kept":62,"cut":false,"hidden":false,"merged":[]}
[]
["10:00am","Order Book"]
["Level","Bid ","Ask","Fair price (As calculated by the strategy)","Bid-ask spread"]
[1,100,100.5,{"$f":"AVERAGE(B4:C4)","v":100.25},{"$f":"C4-B4","v":0.5}]
[2,99.5,101,null,{"$f":"C5-B5","v":1.5}]
[3,99,101.5,null,2.5]
[4,98.25,102.5,null,4.25]
[5,98,103,null,5]
[]
["Ques: If I have to buy this stock at the best possible price, what price should I place my order at to maximize the profit?"]
["Assumption: Our Strategy has calculated the fair price as 100.25 and we will calculate the profits of our open positions from the the fair price."]
[]
["Case 1: Trade at Best Bid"]
[]
["Trade@","Fair Price"]
[100,100.25,"(As calculated by Strategy)"]
["profit is 25 cents"]
["if the prob of getting a trade @100 is 0.5"]
["Then my expected profit is:"]
[0.125,"=0.5*25cents"]
[]
["Case 2: Trade at 2nd Best Bid"]
[]
["Trade@","Fair Price"]
[99.5,100.25,"(As calculated by Strategy)"]
["profit is 75 cents"]
["if the prob of getting a trade @99.5 is 0.25"]
["Then my expected profit is:"]
[0.1875,"=0.25*75cents"]
[]
[]
["Level","Gains","Prob. of getting a fill","EV"]
[1,{"$f":"$D$4-B4","v":0.25},0.5,{"$f":"C33*B33","v":0.125},"=C14*B14"]
[2,{"$f":"$D$4-B5","v":0.75},0.25,{"$f":"C34*B34","v":0.1875}]
[3,{"$f":"$D$4-B6","v":1.25},0.1,0.125]
[4,{"$f":"$D$4-B7","v":2},0.04,0.08]
[5,{"$f":"$D$4-B8","v":2.25},0.02,4.4999999999999998E-2]
[]
[]
["From the ticks you can get the orderbook"]
["For each trade--> from the order book you know at what level that trade occured"]
[]
["10,00,000 qty was traded"]
[]
[500000,"Level 1",null,"prob of getting a fill at level 1 = 500000/1000000"]
[250000,"Level 2",null,"prob of getting a fill at level 2 = 250000/1000000"]
[100000,"Level 3"]
["..","…",null,null,null,null,"  "]
[]
[]
["Qty","Bid ","Ask","Level"]
[5,100,100.5,1]
[10,99.5,101,{"$f":"D52+1","v":2}]
[25,99,101.5,{"$f":"D53+1","v":3}]
[20,98.25,102.5,4]
[40,98,103,5]
[]
[]
["Sell order comes @ 99 for qty 40",null,null,"----->",null,"Price Traded","Qty Traded",null,null,"Average Trade Price",null,{"$f":"SUM(H60:H62)/SUM(G60:G62)","v":99.25}]
["@ Level 1: 5 shares got traded",null,null,null,null,100,5,{"$f":"G60*F60","v":500}]
["@ Level 2: 10 shares got traded",null,null,null,null,99.5,10,{"$f":"G61*F61","v":995}]
["@ Level 3: 25 shares got traded",null,null,null,null,99,25,2475]

{"sheet":"Market Order","index":8,"n_rows":49,"n_cols":7,"rows_kept":49,"cut":false,"hidden":false,"merged":[]}
[]
["10:00am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,13,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["A market order to sell 4 shares comes in"]
["10:05am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty",null,"Fill for 4 shares at 100"]
[1,1,100,100.5,15]
[2,13,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["A market order to sell 5 shares comes in"]
["10:10am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty",null,"Fill for 1 share at 100"]
[1,9,99.5,100.5,15,null,"Fill for 4 share at 99.5"]
[2,10,99,101,35]
[3,20,98.25,101.5,5]
[4,5,98,102.5,2]
[5,null,null,103,15]
[]
["Send a market order for selling 9 shares @10:10.001"]
["10:10.0001 removed buy order of 5 shares from 99.5 and moved them to 99"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,4,99.5,100.5,15]
[2,15,99,101,35]
[3,20,98.25,101.5,5]
[4,5,98,102.5,2]
[5,null,null,103,15]
[]
[]
[]
["Say the lag in the broker's terminal is 10 milliseconds"]
[]
["Fill for 4 shares at 99.5 and 5 shares at 99"]
[]
["5 shares that were first to come @99, they will get traded!!!"]

{"sheet":"Limit Order","index":9,"n_rows":53,"n_cols":8,"rows_kept":53,"cut":false,"hidden":false,"merged":[]}
[]
["9:45am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty",null,null,"A marketable Buy limit order would mean you have fired a limit order with price = 100.5"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
["CASE 1"]
["9:59am"]
["A Limit Buy order comes in @100.75 for 20 shares"]
[]
["10:00am",null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100.75,101,35,null,"Fill of 15 shares at 100.5"]
[2,5,100,101.5,5]
[3,13,99.5,102.5,2]
[4,10,99,103,15]
[5,20,98.25]
[null,5,98]
["CASE 2"]
["9:59am"]
["A Market Buy order comes in for 20 shares"]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,101,30,null,"15 fill at 100.5"]
[2,3,99.5,101.5,5,null,"5 fill at 101"]
[3,10,99,102.5,2]
[4,20,98.25,103,15]
[5,5,98]
[]
[]
["9:45am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
["9:59am"]
["Limit sell order for 12 shares @99.2"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,10,99,99.2,4,null,"Fill at 100 for 5 shares"]
[2,20,98.25,100.5,15,null,"Fill at 99.5 for 3 shares"]
[3,5,98,101,35]
[4,null,null,101.5,5]
[5,null,null,102.5,2]
[null,null,null,103,15]

{"sheet":"Stop Loss","index":10,"n_rows":49,"n_cols":7,"rows_kept":49,"cut":false,"hidden":false,"merged":[]}
[]
["9:45am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
["Say you have bought the share at $100"]
["And now you want to exectue a take profit and stop loss at $5"]
[]
["Book Profit: You want to sell the stock if the market prices reaches $105"]
["Book Loss: You want to sell the stock if the market price reaches $95"]
[]
["For take profit you can easily put a Sell limit order at $105"]
["9:46am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,15]
[2,3,99.5,101,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[null,null,null,105,1]
[]
[]
["But for loss you can't put a sell order at $95 right now because that will get executed!"]
["So you will place a special instruction with the broker that as soon as the market best ask/bid reaches $95 you fire a sell order at $95"]
["1:30pm"]
[null,null,"Order Book",null,null,null,"Limit sell stop loss order when the best ask reaches $95"]
["Level","Qty","Bid ","Ask","Qty"]
[1,12,95.1,95.5,10]
[2,4,95,96,15]
[3,8,94.5,96.1,20]
[]
["1:35pm"]
[null,null,"Order Book",null,null,null,"Here your stop loss will get fired"]
["Level","Qty","Bid ","Ask","Qty"]
[1,12,94.9,95,10]
[2,4,94.75,96,15]
[3,8,94.5,96.1,20]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,12,94.9,95,11]
[2,4,94.75,96,15]
[3,8,94.5,96.1,20]

{"sheet":"IOC","index":11,"n_rows":49,"n_cols":9,"rows_kept":49,"cut":false,"hidden":false,"merged":[]}
["Order Book",null,null,null,null,"Order Book"]
[null,"SBIN",null,null,null,null,"PNB"]
["Qty","Price","Price","Qty",null,"Qty","Price","Price","Qty"]
[10,100,100.1,20,null,50,100.15,100.2,20]
[10,99.95,100.15,50,null,40,100,100.5,10]
[]
["Fire IOC orders: ",null,null,null,null,"Benefit of IOC"]
["Buy order for SBIN @100.1",null,null,null,null,"I will either get both legs of my order executed, or none get executed!"]
["Sell order for PNB @100.15",null,null,null,null,"It won't happen that I am left with either a long SBIN or a short PNB"]
[]
["FOK Orders"]
["10:00:00am"]
["Order Book"]
[null,"Stock"]
["Qty","Price","Price","Qty"]
[10,100,100.1,20]
[10,99.95,100.15,50]
["10:00:01"]
["Fire an FOK buy order for 20 shares @100.1"]
["10:00:0.5"]
["Order Book"]
[null,"Stock"]
["Qty","Price","Price","Qty"]
[10,100,100.1,15]
[10,99.95,100.15,50]
[]
["Exchange will cancel your whole order and you will not get a partial fill"]
[]
["IOC Orders"]
["10:00:00am"]
["Order Book"]
[null,"Stock"]
["Qty","Price","Price","Qty"]
[10,100,100.1,20]
[10,99.95,100.15,50]
["10:00:01"]
["Fire an IOC order for 20 shares @100.1"]
["10:00:0.5"]
["Order Book"]
[null,"Stock"]
["Qty","Price","Price","Qty"]
[10,100,100.1,15]
[10,99.95,100.15,50]
[]
["Order Book"]
[null,"Stock"]
["Qty","Price","Price","Qty"]
[10,100,100.15,50,null,"You will get a partial fill of 15 shares @100.1 and rest of the 5 shares will get cancelled"]
[10,99.95]

{"sheet":"Iceberg","index":12,"n_rows":42,"n_cols":8,"rows_kept":42,"cut":false,"hidden":false,"merged":[]}
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,5,100,100.5,8]
[2,3,99.5,101.5,5]
[3,10,99,102.5,2]
[4,20,98.25,103,15]
[5,5,98]
[]
["10:00am : You fire a sell order @100.05 for QTY 100 with some hidden qty (iceberg order)"]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty (displayed)","Iceberg"]
[1,5,100,100.05,10,90,null,"Total qty was 100 (There is only one trader with the iceberg)"]
[2,3,99.5,100.5,8]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["If some trader fires a buy order @100.1 for 15 shares"]
["And he gets a fill of 15 shares at 100.05 ",null,null,null,"--->","Iceberg order at 100.05 with a qty greater than 15 shares!!!"]
["(Exchange will broadcast this information)"]
[]
["Step 1"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty","Iceberg"]
[1,5,100,100.05,0,85,null,"I get a fill at 100.05 for all 15 shares"]
[2,3,99.5,100.5,8,null,null,"Total qty left is 85"]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
[]
["Step 2"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty","Iceberg"]
[1,5,100,100.05,8,77]
[2,3,99.5,100.5,35]
[3,10,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]

{"sheet":"Pegging","index":13,"n_rows":43,"n_cols":10,"rows_kept":43,"cut":false,"hidden":false,"merged":[]}
[]
[]
[null,"Order Book"]
["Level","Bid ","Ask"]
[1,100,100.5]
[2,99.5,101]
[3,99,101.5]
[4,98.25,102.5]
[5,98,103]
[]
["At the buy side"]
["Pegging order: is a limit order where the price of the order is dependent on the price of a particluar level of the Order book"]
[]
["An order that is pegged at say Level 1"]
["Whatever the best bid is: I will fire an order 1 tick (5 cents more than the best bid), I will not consider my own bid when evaluating the best bid"]
["My order is pegged at level 1 bid"]
[]
["Example 1"]
["I will therefore fire my order at 100.05!!"]
["If the order at 100 moves to 100.1, then I would modify my order to 100.15!!"]
[]
["Example 2"]
["pegged at 2nd level--> I will fire the order at 99.55"]
[]
["An order that is pegged at say Level 2"]
["Whatever the second best bid is: I will fire an order 1 tick (5 cents more than the second best bid)"]
["My order is pegged at level 2 bid"]
[]
["Example 1"]
["I will therefore fire my order at 99.55!!"]
["If a new order enters at 100.2 , then I would modify my order to 100.05!!"]
[]
[]
[null,"My order was pegged to Level 2 (5 cents above the 2nd Level)"]
[null,"Order Book",null,null,null,null,"Order Book"]
["Level","Bid ","Ask",null,null,"Level","Bid ","Ask"]
[1,100,100.5,null,null,1,100.2,100.5,null,"Here I will fire an order at 100.05"]
[2,99.55,101,null,null,2,100,101]
[3,99.5,101.5,null,null,3,99.55,101.5]
[4,99,102.5,null,null,4,99.5,102.5]
[5,98.25,103,null,null,5,99,103]
[null,98,null,null,null,null,98.25]
[null,null,null,null,null,null,98]

{"sheet":"Discretion","index":14,"n_rows":78,"n_cols":9,"rows_kept":78,"cut":false,"hidden":false,"merged":[]}
[]
[]
[null,"Order Book"]
["Level","Bid ",null,"Ask"]
[1,100,null,100.5]
[2,99.5,null,101]
[3,99,null,101.5]
[4,98.25,null,102.5]
[5,98,null,103]
[]
["Discretion order"]
["You would give the broker/code a discretion: that it can modify the price of an order by a certain amount if it can get traded!"]
[]
["Example:"]
["You fire a Buy limit order at 100, with a discretion range of 10 cents"]
[]
["10:00am",null,null,"Order Book"]
[null,"Level",null,"Bid ","Ask","With a discretion range of 10 cents"]
[null,1,null,100,100.5,"Your code knows that it can modify the price till 100.1, if there is an ask at that price!!"]
[null,2,null,99.75,100.5]
[null,3,null,99.5,101]
[null,4,null,99,101.5]
[null,5,null,98.25,102.5]
[null,null,null,98,103]
["10:05:00"]
[null,null,null,"Order Book"]
[null,"Level",null,"Bid ","Ask"]
[null,1,null,100,100.1]
[null,2,null,99.75,100.5]
[null,3,null,99.5,101]
[null,4,null,99,101.5]
[null,5,null,98.25,102.5]
[null,null,null,98,103]
[]
["Then your discretion range will be used, and your order will be modfied to 100.1, so that it gets executed!"]
[]
[]
["What is the benefit of this?"]
["Think in term of Expected Value"]
[]
["Case 1: No discretion range is used."]
[]
["Case 2: Discretion range of 10 cents is used."]
[]
[]
["Given:"]
["Fair price is 100.25 (As calculated by your strategy)"]
[]
["0.5 is the prob of getting a trade at best bid"]
["profit= fair price - traded price",null,null,"(buy )"]
[]
[]
["EV for Case 1: "]
["EV = prob of getting traded * profit of trade",null,null,null,null,null,"profit","prob","EV"]
["=0.5 * 0.25",null,"=0.125",null,null,null,"100.25-100",0.5,0.125]
[]
["EV for Case 2: ",null,null,null,null,null,"profit","prob","EV"]
["EV = prob of getting traded * profit of trade",null,null,null,null,null,"100.25-100.1",1,0.15]
["=1 * 0.15",null,"=0.15"]
[]
[]
[]
[null,"10:00am",null,null,"Order Book"]
[null,null,"Level",null,"Bid ","Ask"]
[null,null,1,null,100.1,100.5]
[null,null,{"$f":"C65+1","v":2},null,100,100.5]
[null,null,{"$f":"C66+1","v":3},null,99.75,101]
[null,null,4,null,99.5,101.5]
[null,null,5,null,99,102.5]
[null,null,6,null,98.25,103]
[null,null,null,null,98]
["EV for Case 1: (if I put a limit order at 100.1)"]
["EV = prob of getting traded * profit of trade",null,null,null,null,null,"profit of trade"]
["=0.8 * 0.15",null,"=0.12",null,null,null,"100.25-100.1"]
[]
["EV for Case 2:  (if I put a limit order at 100)"]
["EV = prob of getting traded * profit of trade",null,null,null,null,null,"profit of trade"]
["=0.5 * 0.25",null,"=0.125",null,null,null,"100.25-100"]

{"sheet":"Pro-Rata basis","index":15,"n_rows":34,"n_cols":9,"rows_kept":34,"cut":false,"hidden":false,"merged":[]}
["PRO RATA BASIS Matching in ORDER BOOK "]
["9:45am"]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,2,100,100.5,15]
[2,6,99.5,101,35]
[3,12,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
["A sell order comes in for 10 shares @99"]
["10:00am"]
["Qty at level*order qty/total qty at all the levels the order would have interacted"]
["Total shares that could have traded were 20 (Qty at level 1+qty at level 2 + qty at level 3)"]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,1,100,100.5,15,null,"1 Fill at 100",null,"2*10/20"]
[2,3,99.5,101,35,null,"3 Fills at 99.5",null,"6*10/20"]
[3,6,99,101.5,5,null,"6 Fills at 99",null,"12*10/20"]
[4,20,98.25,102.5,2]
[5,5,98,103,15]
[]
[]
["A sell order comes in for 4 shares @99.5"]
["10:00am"]
[]
[null,null,"Order Book"]
["Level","Qty","Bid ","Ask","Qty"]
[1,1,100,100.5,15,null,"1 fill",null,"2*4/8"]
[2,3,99.5,101,35,null,"3 fills",null,"6*4/8"]
[3,12,99,101.5,5]
[4,20,98.25,102.5,2]
[5,5,98,103,15]