Dear Candidate,
Congratulations on being selected for the next round of interviews for the software engineering position at our company. As part of the interview process, we would like you to complete a take-home test. Please follow the instructions below carefully:
- You will find a zip file attached to this page named "abx_exchange_server".
- Download and unzip this file to access the contents.
- Enter the extracted folder.
- Run the command "node main.js" to start the ABX exchange server.
- Please ensure that you have Node.js version 16.17.0 or higher installed on your system.
Now that the server is up and running, your task is to develop a C# client application capable of requesting and receiving stock ticker data from the ABX exchange server. The goal of your C# client is to generate a JSON file as output. This JSON file should contain an array of objects, where each object represents a packet of data with increasing sequences. It is essential to ensure that none of the sequences are missing in the final JSON output.
The specifications for the "ABX Mock Exchange Client" are provided below:
<aside>
đź’ˇ
ABX Mock Exchange Server Specification
Introduction
This document provides a specification for developers who want to code a client to interact with the ABX mock exchange server. The ABX server simulates a stock exchange environment and allows clients to request data related to the order book.
Server Connection
- The ABX server operates on TCP protocol.
- Connect to the server using the hostname or IP address and port number (3000) where the server is running.
Data Transmission
- The server expects two types of calls: "Stream All Packets" and "Resend Packet".
- To send a request, create a payload according to the specified format and send it to the server.
Request Payload Format
- The request payload is a binary data structure.
- The payload consists of the following fields:
callType (1 byte): Indicates the type of call. Value 1 represents "Stream All Packets", and value 2 represents "Resend Packet".
resendSeq (1 byte): The sequence number of the packet to be resent (applicable only for callType 2).
Call Types
- Call Type 1: Stream All Packets
- Value: 1
- Purpose: Request to stream all available packets from the server.
- Response: The server will send packets for all available ticker symbols in the order book to the client.
- Disconnection: After sending the packets, the server will close the connection.
- Call Type 2: Resend Packet
- Value: 2
- Purpose: Request to resend a specific packet with a given sequence number.
- Parameters:
resendSeq (1 byte): The sequence number of the packet to be resent.
- Response: The server will send the requested packet to the client.
- Disconnection: After sending the packet, the server will not close the connection. It is the client’s responsibility to close the connection.
Response Payload Format
- The response payload consists of multiple packets, each containing specific fields of information.
- Each packet is of fixed size and follows the format:
- Field: Symbol (4 bytes)(ascii) - The ticker symbol (eg. MSFT). Endianness: Big Endian
- Field: Buy/Sell Indicator (1 byte)(ascii) - Indicates whether the order is for buying or selling (Eg. ”B” for buying, “S” for selling). Endianness: Big Endian
- Field: Quantity (4 bytes)(int32) - The quantity of the order. Endianness: Big Endian
- Field: Price (4 bytes)(int32) - The price of the order. Endianness: Big Endian
- Field: Packet Sequence (4 bytes)(int32) - The sequence number of the packet. Endianness: Big Endian
Handling Responses
- Upon receiving a response from the server, the client should parse the payload and extract the relevant information from each packet.
- The client should handle the fields with the assumption of big endian byte order.
Missing Sequences:
- When the server sends packets, it may skip some sequences.
- After completing the reception of all the data from the server and the server stops the connection, your code should request specific packets that were missed. This ensures that in the end, all the data is received without any missing sequences.
- Assume that the last packet is never missed
Recommendations and Best Practices
- Establish a reliable connection with the server before sending any requests.
- Handle potential network errors or disconnections gracefully to ensure the stability of the client application.
- Implement appropriate error handling and logging mechanisms to capture and report any issues that may arise during the communication with the server.
- Consider implementing data validation and integrity checks to ensure the received data is accurate and complete.
This specification provides the necessary details to develop a client application that can interact with the ABX mock exchange server and retrieve data from the order book.
</aside>
This specification provides you with the necessary details to develop a client application that can interact with the ABX mock exchange server and retrieve data from the order book.
abx_exchange_server zip file:
abx_exchange_server.zip
Instructions: