distributed trading system swe 622
DESCRIPTION
Distributed Trading System SWE 622. Charles Beach Sharita Green Scott Jones James Wolfe. Agenda. Prototype Design Exchange/Trader Communication High Level Implementation Details Clock Calculations Experiment Calculations. System Design. Evaluator. Trader1. TraderX. Logs. - PowerPoint PPT PresentationTRANSCRIPT
Distributed Trading System
SWE 622 Charles Beach
Sharita Green
Scott Jones
James Wolfe
Agenda
Prototype Design Exchange/Trader Communication High Level Implementation Details Clock Calculations Experiment Calculations
Evaluator
. . .
network
Exchange1
Trader1
System Design
ExchangeX
TraderX . . . Logs
TraderClientGoodsMap<good, price>
ExchangeEngine
network
Exec <main>
Buy/Sell
<RMI>Echo
Pub/Sub
Exchange
GUI
Trader
Exchange Design
Exec <main>
GUI
network
Exchange
ConfigFile
ExchangeInterface
Buy/Sell
<RMI>
Receive Echoes
<Pub/Sub>
Trader
TraderEngine
Trader Design
Communication
Traders communicate with Exchanges via RMI Register Buy Sell
Exchanges echo transactions to Traders via Pub/Sub.
Trader Registration
Exchange1 IP RMI-Port Topic Name
Exchange2 IP RMI-Port Topic Name
<Configuration File>
TraderEngine
ExchangeInterface <Exchange1>
ExchangeInterface <Exchange2>
ExchangeEngine ExchangeEngine
network
TraderClient<Trader1>
TraderClient<Trader1>
Exchange1 Exchange2
RMI: register()
Trader1
Exchange Transaction Echoes
Exchange
network
ExchangeInterface
TraderEngine
TraderGUI
ExchangeInterface
TraderEngine
TraderGUI
Trader1 TraderN
RMI: buy/sellTraderX
Pub/Sub
Publish/Subscribe
To send out updates about what products have been bought or sold we will be using Topic structure to publish messages to registered traders from the various exchanges.
Example Trader 1 registers with Exchange 1 and Trader 2 registers with Exchange 1 and Exchange 2. When Exchange 1 receives a buy or sell request it will send a message to the posted queue of Trader 1 and Trader 2. When Exchange 2 receives a buy or sell request it will send a message to Trader 2 queue.
Trader 1 Trader 2
Exchange 1 Exchange 2
Publish/Subscribe
An asynchronous messaging paradigm where senders (publishers) of messages are not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into classes, without knowledge of what (if any) subscribers there may be. Subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what (if any) publishers there are. This decoupling of publishers and subscribers can allow for greater scalability and a more dynamic network topology.
Wikipedia (http://en.wikipedia.org/wiki/Publish/subscribe)
Clock Calculations
Traders are responsible for calculating the clock differences between themselves and the Exchanges. Exchange timestamp passed back as part of the Trader registration. Timestamp is used to calculate the “time offset” relevant to its own clock.
Data Staleness Each transaction is time-stamped by the Exchange Trader applies its saved “time offset” for the given Exchange to determine the age of the data with
respect to its own clock. Staleness = Tt(now) – (Et(data) + offset)
Traders must invoke the Exchange RMI “register” method every 60 seconds. Time offset is re-calculated to keep up with the “clock skew” between the clocks.
RMI register
Trader Exchange
(ET)
Tt1
Tt2
Trader CalculationsTte = (Tt1 + Tt2) / 2
Offset = Et - Tte
EtTte
Offset Calculation
The Traders/Exchanges will output time stamped information to a log file. Exchanges
Requests from Traders for buying/selling goods. Trader registrations Processed Transactions Detection of Trader failures
Traders Received transaction events from Exchanges Requests to buy/sell goods Time offsets between clock and Exchange clocks.
A stand-alone application will be responsible for performing the Experiments. Process all of the log files Make latency calculations.
Processed Orders Detection of failures (Traders/Exchange crashes)
Clock calculations Clock Skew between Trader/Exchange clocks. Network Latency
Experiments
Planning the Implementation
Initial prototype implementation has been completed RMI and Pub/Sub communications.
Needs to be implemented Formalize the prototype. Time calculations to detect data staleness. Logging capability. Stand Alone application to perform experiment calculations.