Class Algorithms

java.lang.Object
com.bank.trading.execution.Algorithms
All Implemented Interfaces:
Runnable

public class Algorithms extends Object implements 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 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()
      Specified by:
      run in interface Runnable
    • addData

      public void addData(Event event)
      Add data to the trading service
      Parameters:
      event - The event to be added to the trading service.
    • changeLamportAddress

      public void changeLamportAddress(InetSocketAddress newLamportSocketAddress)
      Change the address of the lamport service.
      Parameters:
      newLamportSocketAddress - the new socket address for the lamport service.
    • changeExecutionAddress

      public void changeExecutionAddress(InetSocketAddress newExecutionAddress)
      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.