I asked six AI tools for a React order book. The top pick was last updated in 2023.
I build components for trading and finance screens. I asked six AI tools with web search for a good React order book component. Most of the answers pointed at the same few repos. The one they cited most was last updated in July 2023. Those repos did the job back then. But if you're building an exchange or a perps front end now, you probably want something that drops into a shadcn and Tailwind…
I inquired six AI tools equipped with web search to recommend a React order book component. The majority of recommendations converged on a few repositories, with one standing out as the most recently updated in July 2023. While these repositories served their purpose adequately, when developing for an exchange or perpetual front end today, it's crucial to select a component that not only integrates seamlessly into a shadcn and Tailwind project but also allows for customization.
To address this need, I have extracted an order book from my library and published it in a separate repository. Herein, I outline the functionalities an order book should possess and demonstrate how this particular component accomplishes them.
An order book must remain legible amidst a bustling market. Prices should be grouped according to the market's tick, and the ability to switch grouping is essential. Each price level should display a depth bar, enabling traders to discern walls without scrutinizing every individual number. The component must promptly respond to a trader's inquiry, providing the total size and value up to a specified price upon pointing at a level.
This vital information should be readily available before placing a substantial order. Furthermore, the figures displayed must be precise, presented in tabular numerals to maintain consistency across columns while prices fluctuate. Any discrepancies in numbers would render the order book unreliable.
To install the component, simply integrate it as a shadcn registry item within a React project utilizing Tailwind CSS. Execute the following command in the desired project directory:
npx shadcn@latest add @ssych/order-book
Once installed, the component becomes an integral part of your project, fully editable to suit your specific requirements. The order book accepts two arrays as props: bids and asks, each containing objects with price and size properties. The `feed` prop allows for the demonstration of a demo feed in documentation. When working with live levels from an exchange or WebSocket, ensure `feed` is set to `false`.
Please note that the component does not support virtualization for thousands of rows and is optimized for the number of levels displayed on a single screen. If a deep ladder is required, a data grid would be more suitable. The component is part of a broader ecosystem that includes a depth chart, time and sales tape, order ticket, and positions table.
For perpetual contracts, it is recommended to display the liquidation price before confirming the order to prevent the common user error of discovering it post-click. These components are all freely available under the MIT license and can be found at https://ssych.com/library/s/perps-dex. The repository containing the order book is accessible at https://github.com/savvasicevs/react-order-book.
Should you have experience in building exchange UIs, I would greatly appreciate your insights on any additional features that could enhance this order book component.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to