http://www.nytimes.com/2011/08/27/business/as-trade-volumes-soar-exchanges-cash-in.html
http://www.nytimes.com/2011/08/27/business/as-trade-volumes-soar-exchanges-cash-in.html
http://www.bloomberg.com/news/2012-01-23/stock-trading-is-lowest-in-u-s-since-2008.html
http://www.tabbgroup.com/PublicationDetail.aspx?PublicationID=346
Buy        Sell
50, $12   60, $10

60, $11   100, $11

30, $10   30, $12
Price: $10

Buy                     Sell
50, $12                60, $10

60, $11                100, $11

30, $10                30, $12
Price: $10

Buy                     Sell
60, $11                10, $10

30, $10                100, $11

                       30, $12
Price: $10

Buy                     Sell
60, $11                10, $10

30, $10                100, $11

                       30, $12
Price: $10

Buy                     Sell
50, $11                100, $11

30, $10                30, $12
Price: $11

Buy                     Sell
50, $11                100, $11

30, $10                30, $12
Price: $11

Buy                    Sell
30, $10                50, $11

                       30, $12
Not Validated               Validated               Processed




                Validator               Processor
Method                        Time in msec

        Single Thread                 300

        Single Thread w/ Lock         10.000

        2 Threads w/ Lock             224.000

        Single Thread w/ CAS          5.700

        2 Threads w/ CAS              30.000

        Single Thread w/ Volatile
                                      4.700
        Write




http://disruptor.googlecode.com/files/Disruptor-1.0.pdf
Queue (Lack of) Fairness


            50               Buy   Sell
                                   100
            60




Consumer         Consumer
 Thread 1         Thread 2
Queue (Lack of) Fairness


                             Buy   Sell
            50
                                   100




   60


Consumer         Consumer
 Thread 1         Thread 2
Queue (Lack of) Fairness
 Can you tell which order will be executed 1st?


                             Buy          Sell
                                          100




   60          50


Consumer    Consumer
 Thread 1    Thread 2
Validator   Processor
Processor thread pool per segment

Symbol=A-H    Symbol=I-S    Symbol=T-Z




Validator      Processor     Processor
Single Processor thread pool, pick random segment

      Symbol=A-H      Symbol=I-S     Symbol=T-Z




                      Processor
Single processor thread per segment

 Symbol=A-H    Symbol=I-S     Symbol=T-Z




 Processor      Processor      Processor
Shared thread pool, mark segments under processing (CAS)


                        Segment 1   Segment 2   Segment 3
Segment 1

Segment 2

Segment 3




                                    Processor
Shared thread pool, mark segments under processing (CAS)


                        Segment 1   Segment 2   Segment 3
Segment 1   X

Segment 2

Segment 3




                                    Processor
Shared thread pool, mark segments under processing (CAS)


                        Segment 1   Segment 2   Segment 3
Segment 1   X

Segment 2

Segment 3   X




                                    Processor
Shared thread pool, mark segments under processing (CAS)


                        Segment 1   Segment 2   Segment 3
Segment 1

Segment 2

Segment 3   X




                                    Processor
Segments are created and removed as needed




                          Processor
Segments are created and removed as needed

                    “GOOG”
“GOOG”




                             Processor
Segments are created and removed as needed

                    “GOOG”
“GOOG”




                             Processor
Segments are created and removed as needed

                   “GOOG”   “AAPL”
GOOG

AAPL




                            Processor
Segments are created and removed as needed

                   “GOOG”   “AAPL”      “AMZN”
GOOG    X

AAPL

AMZN




                            Processor
http://martinfowler.com/articles/lmax.html
http://www.nytimes.com/2011/08/27/business/as-trade-
volumes-soar-exchanges-cash-in.html
http://disruptor.googlecode.com/files/Disruptor-1.0.pdf
http://www.gigaspaces.com/wiki/display/XAP9/FIFO+Grouping

Trade and Event Processing at a Massive Scale - QCon NY 2012

Editor's Notes

  • #4 Algorithmic and high frequency trading
  • #10 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #11 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #12 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #13 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #14 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #15 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #16 Much more complicated than this example: Exchange vs Market maker / trader checking the target market is open to take orderschecking the order is valid for that marketchoosing the right matching policy for the type of ordersequencing the order so that each order is matched at the best possible price and matched with the right liquiditycreating and publicizing the trades made as a consequence of the matchupdating prices based on the new trades
  • #19 Mechanical sympathy
  • #20 Two principles – data with message, staged processing Locking with every write/takeMechanical sympathy
  • #21 Mechanical sympathy
  • #22 Mechanical sympathy
  • #26 Two principles – data with message, staged processing Locking with every write/takeMechanical sympathy
  • #27 Mechanical sympathy
  • #28 Mechanical sympathy
  • #29 Mechanical sympathy