Package com.bank.trading.execution
Class Algorithms
java.lang.Object
com.bank.trading.execution.Algorithms
- All Implemented Interfaces:
Runnable
This class is responsible for the execution of the trading algorithms.
Data is streamed from lamport service and is used to execute the trading algorithms.
The decision of the system is sent to the execution service.
Uses heartbeats to check if the leader is alive.
Leader sends data to worker instances based on the tickers.
-
Constructor Summary
ConstructorsConstructorDescriptionAlgorithms(byte[] algExecutable, InetSocketAddress lamportSocketAddress, InetSocketAddress socketAddress, List<InetSocketAddress> peers, InetSocketAddress executionAddress) Constructor to initialize the trading algorithms with the executable and machine id. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd data to the trading servicevoidchangeAlg(byte[] algExecutable) Change the executable for the trading algorithms.voidchangeExecutionAddress(InetSocketAddress newExecutionAddress) Change the address of the execution service.voidchangeLamportAddress(InetSocketAddress newLamportSocketAddress) Change the address of the lamport service.byte[]getAlg()Get the executable for the algorithm.byte[]Get the executable for the controls.voidrun()voidsetControl(byte[] control) Set the controls for the trading algorithms.
-
Constructor Details
-
Algorithms
public Algorithms(byte[] algExecutable, InetSocketAddress lamportSocketAddress, InetSocketAddress socketAddress, List<InetSocketAddress> peers, InetSocketAddress executionAddress) Constructor to initialize the trading algorithms with the executable and machine id.- Parameters:
algExecutable- The executable for the trading algorithms.lamportSocketAddress- The socket address for the lamport service.socketAddress- The socket address for the execution service.peers- List of peer addresses for the lamport service.executionAddress- The socket address for the execution service.
-
-
Method Details
-
run
public void run() -
addData
Add data to the trading service- Parameters:
event- The event to be added to the trading service.
-
changeLamportAddress
Change the address of the lamport service.- Parameters:
newLamportSocketAddress- the new socket address for the lamport service.
-
changeExecutionAddress
Change the address of the execution service.- Parameters:
newExecutionAddress- the new socket address for the execution service.
-
changeAlg
public void changeAlg(byte[] algExecutable) Change the executable for the trading algorithms.- Parameters:
algExecutable- the new executable for the trading algorithms.
-
setControl
public void setControl(byte[] control) Set the controls for the trading algorithms.- Parameters:
control- the control parameters to be set for the trading algorithms.
-
getControls
public byte[] getControls()Get the executable for the controls.- Returns:
- the current controls executable.
-
getAlg
public byte[] getAlg()Get the executable for the algorithm.- Returns:
- the current algorithm executable.
-