Share this

Depth chart: A visual guide to market liquidity and order flow

Highsoft Avatar

by

10 minutes read

Depth chart - A visual guide to market liquidity and order flow

In the dynamic world of financial markets, understanding liquidity and order flow is crucial for traders, investors, and market analysts. One of the most powerful tools for visualizing this information is the market depth chart. Whether you’re trading cryptocurrencies, stocks, or commodities, depth charts provide valuable insights into the current state of the market, helping you make more informed trading decisions.

Market depth charts display the cumulative buy and sell orders at different price levels, offering a visual representation of supply and demand. By showing the volume of pending orders, these charts reveal the market’s structure and potential price movements.

In this article, we’ll explore how depth charts work, what they reveal about market dynamics, and how to implement them using Highcharts.

To see more examples and get an even better understanding of the opportunities Highcharts offers, please head over to the demo section of our website or read up on the technical documentation on how to get started. Once you get the hang of it, the API reference will help you customize your charts in no time.

Whether you’re a developer working with JavaScript, .NET, React or other common frameworks, we’re confident you’ll find the inspiration you need.

Highcharts also integrates seamlessly with popular languages such as Python, R, PHP and Java, as well as mobile platforms like iOS and Android. Additional support for frameworks like Svelte, Angular, and Vue, makes it a versatile tool for various development environments.

 

What is a market depth chart?

A market depth chart, also known as an order book visualization, displays the cumulative volume of buy orders (bids) and sell orders (asks) at various price points. The vertical axis represents the cumulative volume, while the horizontal axis shows the price. Bids are typically displayed on the left side of the current market price, and asks on the right, creating a visual representation of the order book.

The depth chart serves as a window into market liquidity, showing how much buying and selling pressure exists at different price levels. This information can be invaluable for understanding market sentiment, identifying potential support and resistance levels, and planning entry or exit points for trades.

Key components of a depth chart

Understanding the components of a depth chart is essential for interpreting the information it provides. Let’s break down the main elements:

  • Bid curve (usually green or blue): Represents the cumulative volume of buy orders at each price point below the current market price. The steeper this curve, the more buying interest exists near the current price.
  • Ask curve (usually red): Shows the cumulative volume of sell orders at each price point above the current market price. A steep ask curve indicates significant selling pressure near the current price.
  • Current market price: Often represented by a vertical line separating the bid and ask sides of the chart, indicating where the most recent trades have occurred.
  • Price axis: The horizontal axis showing the range of prices for pending orders.
  • Volume axis: The vertical axis displaying the cumulative volume of orders at each price level.

Interpreting depth charts for market analysis

Depth charts provide several valuable insights for market participants. By analyzing the shape, steepness, and overall structure of the curves, traders can gauge market sentiment and potential price movements.

A balanced depth chart with similar volumes on both the bid and ask sides suggests a market in equilibrium, where buying and selling pressure are relatively equal. In contrast, a significant imbalance between bids and asks can indicate potential price movements. For example, if the bid side shows substantially more volume than the ask side, it suggests strong buying pressure that could drive prices higher.

The steepness of the curves also provides important information. Steep curves indicate high liquidity near the current price, suggesting that the price may be stable in the short term. Conversely, shallow curves or “walls” (large orders at specific price points) can indicate potential support or resistance levels where price movements might stall or reverse.

Market depth charts can also reveal potential market manipulation. For instance, large orders that suddenly appear and disappear (known as “spoofing”) can artificially skew the depth chart and mislead other traders about true market sentiment.

Use cases for depth charts

Depth charts serve various purposes across different market participants:

For traders, depth charts help identify optimal entry and exit points based on liquidity and potential support/resistance levels. They also assist in understanding whether large orders might impact price movements when executed.

For investors, these charts provide insights into market sentiment and liquidity conditions, which can inform longer-term investment decisions. Understanding the market structure helps investors gauge whether their orders might move the market, especially for larger positions.

For market makers and liquidity providers, depth charts are essential tools for identifying opportunities to provide liquidity where it’s needed, helping them place competitive orders that can be filled profitably.

For exchanges and market operators, visualizing order book data helps monitor market health and detect potential irregularities or manipulative activities.

Building a depth chart with Highcharts

Go directly to the Highcharts demo page for “Depth chart” to view its code, play around with different theme colors or edit it on JSFiddle or Codepen.
 

 

Now, let’s explore how to create this interactive market depth chart using Highcharts. Our example will visualize the market depth for an ETH-BTC trading pair, showing the cumulative volume of bids and asks at different price points.

The implementation consists of three main parts: loading the required libraries, setting up the HTML container and CSS styling, and configuring the Highcharts chart with our data.

 

1. Load the required files and create a container to hold the chart

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<div id="container"></div>

This code includes the core Highcharts library and the accessibility module, which enhances the chart’s accessibility for users with disabilities. The empty container div will hold our chart.

 

2. Add some CSS to control the dimensions of the container

#container {
    min-width: 310px;
    max-width: 1040px;
    height: 400px;
    margin: 0 auto;
}

These CSS rules define the chart container’s dimensions and center it on the page. The responsive design ensures the chart looks good on various screen sizes, with a minimum width to maintain readability and a maximum width to prevent it from becoming too stretched on large displays.

 

3. Implement the JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'area',
        zooming: {
            type: 'xy'
        }
    },
    title: {
        text: 'ETH-BTC Market Depth'
    },
    xAxis: {
        minPadding: 0,
        maxPadding: 0,
        plotLines: [{
            color: '#888',
            value: 0.1523,
            width: 1,
            label: {
                text: 'Actual price',
                rotation: 90
            }
        }],
        title: {
            text: 'Price'
        }
    },
    yAxis: [{
        lineWidth: 1,
        gridLineWidth: 1,
        title: null,
        tickWidth: 1,
        tickLength: 5,
        tickPosition: 'inside',
        labels: {
            align: 'left',
            x: 8
        }
    }, {
        opposite: true,
        linkedTo: 0,
        lineWidth: 1,
        gridLineWidth: 0,
        title: null,
        tickWidth: 1,
        tickLength: 5,
        tickPosition: 'inside',
        labels: {
            align: 'right',
            x: -8
        }
    }],
    legend: {
        enabled: false
    },
    plotOptions: {
        area: {
            fillOpacity: 0.2,
            lineWidth: 1,
            step: 'center'
        }
    },
    tooltip: {
        headerFormat: '<span style="font-size=10px;">Price: ' +
            '{point.key}</span><br/>',
        valueDecimals: 2
    },
    series: [{
        name: 'Bids',
        data: [
            [
                0.1524,
                0.948665
            ],
            [
                0.1539,
                35.510715
            ],
            [
                0.154,
                39.883437
            ],
            [
                0.1541,
                40.499661
            ],
            [
                0.1545,
                43.262994000000006
            ],
            [
                0.1547,
                60.14799400000001
            ],
            [
                0.1553,
                60.30799400000001
            ],
            [
                0.1558,
                60.55018100000001
            ],
            [
                0.1564,
                68.381696
            ],
            [
                0.1567,
                69.46518400000001
            ],
            [
                0.1569,
                69.621464
            ],
            [
                0.157,
                70.398015
            ],
            [
                0.1574,
                70.400197
            ],
            [
                0.1575,
                73.199217
            ],
            [
                0.158,
                77.700017
            ],
            [
                0.1583,
                79.449017
            ],
            [
                0.1588,
                79.584064
            ],
            [
                0.159,
                80.584064
            ],
            [
                0.16,
                81.58156
            ],
            [
                0.1608,
                83.38156
            ]
        ],
        color: '#03a7a8'
    }, {
        name: 'Asks',
        data: [
            [
                0.1435,
                242.521842
            ],
            [
                0.1436,
                206.49862099999999
            ],
            [
                0.1437,
                205.823735
            ],
            [
                0.1438,
                197.33275
            ],
            [
                0.1439,
                153.677454
            ],
            [
                0.144,
                146.007722
            ],
            [
                0.1442,
                82.55212900000001
            ],
            [
                0.1443,
                59.152814000000006
            ],
            [
                0.1444,
                57.942260000000005
            ],
            [
                0.1445,
                57.483850000000004
            ],
            [
                0.1446,
                52.39210800000001
            ],
            [
                0.1447,
                51.867208000000005
            ],
            [
                0.1448,
                44.104697
            ],
            [
                0.1449,
                40.131217
            ],
            [
                0.145,
                31.878217
            ],
            [
                0.1451,
                22.794916999999998
            ],
            [
                0.1453,
                12.345828999999998
            ],
            [
                0.1454,
                10.035642
            ],
            [
                0.148,
                9.326642
            ],
            [
                0.1522,
                3.76317
            ]
        ],
        color: '#fc5857'
    }]
});

 

This JavaScript code configures our depth chart using Highcharts. Let’s break down the key components:

Chart configuration: We set the chart type to ‘area’ and enable xy-zooming, allowing users to zoom in on both axes for detailed analysis.

X-axis configuration: The x-axis represents price levels. We add a plotLine to indicate the current market price (0.1523 in this example) with a vertical gray line and a rotated label.

Y-axis configuration: We set up two y-axes linked together – one on the left and one on the right – displaying the cumulative volume. This dual-axis approach improves readability by showing volume labels on both sides of the chart.

Plot options: We configure the area series with a semi-transparent fill (fillOpacity: 0.2) and step center mode, which creates the characteristic stepped appearance of depth charts.

Tooltip: The tooltip shows the price and volume information when hovering over data points, with values formatted to two decimal places.

Series data: We define two series – ‘Bids’ in blue-green and ‘Asks’ in red. Each data point is an array containing [price, cumulative_volume]. The bid data shows buy orders below the current price, while ask data shows sell orders above it.

Enhancing your depth chart

The basic implementation provides a solid foundation, but there are several ways to enhance your depth chart for better user experience and additional insights:

Adding real-time updates

For active trading environments, real-time updates are essential. You can implement WebSocket connections to your data source to receive order book updates and dynamically adjust the chart. Highcharts provides methods like series.update() and point.update() to modify data without redrawing the entire chart.

Real-time updates keep traders informed about rapidly changing market conditions, especially during volatile periods when order book dynamics can shift dramatically within seconds.

Implementing interactive features

Enhanced interactivity can make your depth chart more valuable for analysis. Consider adding:

Volume at price indicators: Display the exact volume available at specific price points when hovering.

Price impact estimation: Calculate and show how much a given order size would impact the market price based on current depth.

Customizable time frames: Allow users to view historical depth data to analyze how liquidity has changed over time.

Comparison mode: Enable comparison of depth across different trading pairs or time periods to identify relative liquidity conditions.

Improving visual clarity

Clear visual representation is crucial for effective data interpretation. Consider these enhancements:

Color gradients: Use color intensity to represent order density at different price levels, highlighting areas of concentrated liquidity.

Logarithmic scaling: Implement optional logarithmic scales for both axes to better visualize markets with wide price ranges or volume disparities.

Visible spreads: Highlight the spread between the highest bid and lowest ask to emphasize the immediate trading costs.

Dark mode option: Provide a dark theme for reduced eye strain during extended trading sessions.

Conclusion

Market depth charts provide a powerful visual representation of order book data, offering valuable insights into market liquidity, sentiment, and potential price movements. By displaying the cumulative volume of buy and sell orders at different price levels, these charts help traders and analysts understand the current state of supply and demand in the market.

With Highcharts, implementing interactive and visually appealing depth charts becomes accessible to developers of all skill levels. The example provided in this article serves as a foundation that can be extended with real-time updates, additional interactive features, and integration with other market data visualizations.

Whether you’re developing a trading platform, creating analytical tools, or simply monitoring market conditions, depth charts are an essential component of the modern trader’s toolkit. By understanding how to interpret these visualizations and implementing them effectively, you can provide users with powerful insights into market structure and order flow dynamics.

As markets continue to evolve, the ability to visualize and analyze depth data will remain a crucial skill for traders and developers alike. By leveraging the capabilities of libraries like Highcharts, you can create sophisticated visualizations that transform complex order book data into clear, actionable insights.

 

 

Stay in touch

No spam, just good stuff

We're on discord. Join us for challenges, fun and whatever else we can think of
XSo MeXSo Me Dark
Linkedin So MeLinkedin So Me Dark
Facebook So MeFacebook So Me Dark
Github So MeGithub So Me Dark
Youtube So MeYoutube So Me Dark
Instagram So MeInstagram So Me Dark
Stackoverflow So MeStackoverflow So Me Dark
Discord So MeDiscord So Me Dark

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.