Summary: Create a ReactJS UI component to synchronize and display an order book using websocket updates.
Task Description: Your task is to implement an isolated UI component that represents an order book, displaying bids and asks by traders on an exchange. Utilize websocket updates to construct and update the order book (bids and asks array) in an optimized manner, avoiding memory leaks. Implement logic to handle network connection loss, automatically resubscribe, and manage lost packages based on incorrect sequence numbers. You don’t have to fully finish the assignment; spend at most one week on it.
Example Order Book UI:
Resources:
- Order book synchronization via websockets: Orderbook Synchronization
- Subscribing to websockets: Subscribing to Websockets
- Order book response data structure (OrderbookData): OrderbookData Structure
- Centrifuge-js SDK for websocket connection: Centrifuge-js SDK
- JWT for subscribing to public websocket channels:
- Testnet: wss://api.testnet.rabbitx.io/ws: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwIiwiZXhwIjo1MjYyNjUyMDEwfQ.x_245iYDEvTTbraw1gt4jmFRFfgMJb-GJ-hsU9HuDik
- Production: wss://api.prod.rabbitx.io/ws: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MDAwMDAwMDAwIiwiZXhwIjo2NTQ4NDg3NTY5fQ.o_qBZltZdDHBH3zHPQkcRhVBQCtejIuyq8V1yj5kYq8
Requirements:
- Use ReactJS for building the UI component.
- Integrate the Centrifuge-js SDK for websocket connections.
Technical Specifications:
- Develop a ReactJS UI component to represent the order book, including bids and asks.
- Establish a websocket connection using the Centrifuge-js SDK and subscribe to order book updates.
- Process the incoming websocket data to construct and maintain an optimized bids and asks array, ensuring efficient memory management (Orderbook Synchronization).
- Merge existing bids and asks with incoming websocket updates, keeping the order book up-to-date.
- Implement logic to handle network connection disruptions, including automatic reconnection and resubscription.
- Account for lost packages by verifying the correctness of sequence numbers in the websocket updates.
Deliverables:
- A ReactJS application containing the order book UI component.
- Source code with clear and concise comments explaining the implementation.
- A brief document outlining the approach taken, challenges faced, and possible improvements.
Evaluation Criteria: Your submission will be evaluated based on the following:
- Functionality: The UI component should accurately display and update the order book using websocket data.
- Code Quality: The source code should be clean, well-organized, and properly commented.
- Optimization: The application should handle memory efficiently and avoid memory leaks.
- Robustness: The solution should account for network disruptions and lost packages.