Architecture

Building an API for low latency trading

Architecture:

Design tenets:

  1. We have the following main entities in the system:
    1. Client Application
    2. Backend service
    3. Finance exchange server
  2. Client application invoke the API for retrieving the account information form the server. The account information data is stored in the Nosql database (mainly Cassandra). The API key can be decrypted to extract the user id, which is a primary key in the database. Apparently, this approach is preferred compared to the use of API key as primary key since primary key generally have constraint on the number of characters. 
  3. The order information is also stored in the Cassandra. In the flow, as the order come to the backend, it is dispatched to the exchange. After response from the exchange, it is persisted
  4. The securities information is saved to hdfs and open TSDB can be used to query by time
  5. Predictions jobs are run on the data with spark while ingesting from HDFS. Deep learning jobs can be written on Spark to predict the results
  6. All the micro services communicate with gRPC internally
  7. Aggregator service can be run on the same pod with order service

Authentication:

User is provided with the API key after subscribing to the platform which can be used for the trading 

API: –

GET /v1/info – Return the user information for a given user/key

POST /v1/order – order to market 

  • Type – buy/sell

GET /v1/transactions – shows the transactions for the user 

DELETE /v1/orders

  /v1/orders/{orderID}

Cancels all the pending orders or a given order 

GET /v1/assets (securities) – the prices of the securities at a given time

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button