Package com.bank.trading.execution
Class ExecutionService
java.lang.Object
com.bank.trading.execution.ExecutionService
- All Implemented Interfaces:
Runnable
Called by person or Algo to submit trade to market
This class will start a smart order router to route the order to the market on
another Thread in this server.
The service is bound by the controls executable that is passed to it.
This prevents extreme failures in the system and loss of money.
The service uses Zookeper algorithm for leader election.
The leader distributes the work to the other instances based of tickers.
Uses heartbeats to check if the leader is alive and leader will know if followers are alive.
-
Constructor Summary
ConstructorsConstructorDescriptionExecutionService(InetSocketAddress address, InetSocketAddress LamportAddress, byte[] controlsExecutable, List<InetSocketAddress> peers, Map<Order.Exchange, InetSocketAddress> exchangeAddresses) Constructor for the execution service. -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeLamportAddress(InetSocketAddress newLamportAddress) Change the current Lamport address.byte[]Get the current controls executable.voidrun()Main execution loop for the execution service.voidsetControlsExecutable(byte[] controlsExecutable) Set new controls executable for the execution service.booleansubmitTrade(Order order) Submit a trade order to the market.
-
Constructor Details
-
ExecutionService
public ExecutionService(InetSocketAddress address, InetSocketAddress LamportAddress, byte[] controlsExecutable, List<InetSocketAddress> peers, Map<Order.Exchange, InetSocketAddress> exchangeAddresses) Constructor for the execution service.- Parameters:
address- The address for the execution service.LamportAddress- The address for the Lamport clock service.controlsExecutable- The controls executable for the execution service.peers- List of peer addresses for the execution service.
-
-
Method Details
-
run
public void run()Main execution loop for the execution service. -
submitTrade
Submit a trade order to the market. This method will route then execute the order.- Parameters:
order- the order to be submitted.
-
setControlsExecutable
public void setControlsExecutable(byte[] controlsExecutable) Set new controls executable for the execution service.- Parameters:
controlsExecutable- the new controls executable to be set.
-
getControlsExecutable
public byte[] getControlsExecutable()Get the current controls executable.- Returns:
- byte array of the controls executable.
-
changeLamportAddress
Change the current Lamport address.
-