<p>I can't answer for the discrepancy that you're seeing, but the "right" way to calculate volume would be to add the "total" column from each trade that occurred during the period. That is, assuming that candle charts are based on stock market candle charts.</p>

<p>It doesn't surprise me that you're seeing this discrepancy, however. I've noticed a few different cryptocurrency APIs that have no idea how to calculate OHLCV data the right way. If your candle data isn't correct, then none of the traditional TA-Lib functions will mean anything!</p>

CC BY-SA 4.0
2018-06-28T08:14:13.480Z
2018-06-28T08:14:13.480Z
Laser-Lance
<p>How does Coinbase/GDAX calculate the "Volume" in candle data?</p>

<p>I'm pulling data from the GDAX API in 2 ways; 1, by requesting candles similar to <a href="https://api.gdax.com/products/BTC-USD/candles?start=2018-02-06&amp;granularity=60" rel="nofollow noreferrer">this endpoint</a>, and 2, by tallying up raw tick data from the GDAX WebSocket.</p>

<p>My problem is that when I try to create candle data from tick data, my volumes are very different than what GDAX reports for the same/similar periods. (See the blue and red outlines below...)</p>

<p>In my hand-made candles (shown below, highlighted red), I'm simply taking the sum of all the BTC transacted during that interval, but the numbers are much higher than what GDAX is reporting in similar periods.</p>

<p>What am I doing wrong?</p>

<p>Here's the format I'm using to make my candles:
<a href="https://i.sstatic.net/hpdqw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hpdqw.png" alt="Raw tick data"></a></p>

<p><img src="https://i.sstatic.net/Vb9O5.png" alt="Volume discrepancy?"></p>

<p>While researching this, I found <a href="https://www.quora.com/How-do-you-calculate-a-Bitcoin-Exchanges-30-day-trailing-volume" rel="nofollow noreferrer">this post</a> saying that Coinbase uses the # of transactions to calculate volume, but I tried that, and the numbers are still way off. I even tried dividing and multiplying the # of transactions with my calculated volume, but they're still way off.</p>

CC BY-SA 3.0
2018-02-13T09:08:23.343Z
Did you manage to find out the answer? I'm having the same issue
Nasir
CC BY-SA 3.0
2018-02-13T09:40:41.723Z
I've been digging heavily into this and I'm reaching the conclusion that GDAX tradeview shows the wrong volume for each candle. I calculated several of these items and they don't match (even though OHLC are correct). Another reason was that I check TradingView chart as well and their calculation also matches mine but not GDAX
Nasir
CC BY-SA 3.0
2018-02-13T19:27:11.523Z
@Nasir Glad I'm not the only one stuck here. Still no answer, but I did more investigating and have some ideas. The gray volume bars in the tradeview seem to be the sum of the live transaction amounts from the live ticker. It seems like everywhere else GDAX reports volume (such as in TradingView and the GDAX APIs), it's calculated differently. I noticed on TradingView they refer to the Volume as "Volume 20", so perhaps they're applying a rolling average?
user1399181
CC BY-SA 3.0
2018-02-13T21:46:47.587Z
Update: I just tried applying a bunch of rolling averages and emas to the Volume from Tick data, to see if it would match the volume from GDAX's candle data, with no luck.
user1399181
CC BY-SA 3.0
2018-02-14T13:53:38.370Z
I also tried it with the live ticker and it doesn't match. Clearly, the `sum(size)` of trades in an interval should be the volume but that just does not match the GDAX api. I have tested other exchanges and they are fine. so I take my calculated value as correct.
Nasir
CC BY-SA 3.0
2018-04-03T03:56:47.640Z
just curious.. what "tick data" did you use? I looked at GDAX's api doc and there seems to be a few channels and types of messages you can use.
Will Gu
<coinbase.com><volume>
How does Coinbase / GDAX calculate volume in historical candles?
user1399181
# How does Coinbase / GDAX calculate volume in historical candles?

(Asked by: username_0 on 2018-02-07)

How does Coinbase/GDAX calculate the "Volume" in candle data?

I'm pulling data from the GDAX API in 2 ways; 1, by requesting candles similar to [this endpoint](https://api.gdax.com/products/BTC-USD/candles?start=2018-02-06&granularity=60), and 2, by tallying up raw tick data from the GDAX WebSocket.

My problem is that when I try to create candle data from tick data, my volumes are very different than what GDAX reports for the same/similar periods. (See the blue and red outlines below...)

In my hand-made candles (shown below, highlighted red), I'm simply taking the sum of all the BTC transacted during that interval, but the numbers are much higher than what GDAX is reporting in similar periods.

What am I doing wrong?

Here's the format I'm using to make my candles:
[![Raw tick data](https://i.sstatic.net/hpdqw.png)](https://i.sstatic.net/hpdqw.png)

![Volume discrepancy?](https://i.sstatic.net/Vb9O5.png)

While researching this, I found [this post](https://www.quora.com/How-do-you-calculate-a-Bitcoin-Exchanges-30-day-trailing-volume) saying that Coinbase uses the # of transactions to calculate volume, but I tried that, and the numbers are still way off. I even tried dividing and multiplying the # of transactions with my calculated volume, but they're still way off.

**Tags:** coinbase.com, volume

> **Comments:**
> **username_1**: Did you manage to find out the answer? I'm having the same issue  
> **username_1**: I've been digging heavily into this and I'm reaching the conclusion that GDAX tradeview shows the wrong volume for each candle. I calculated several of these items and they don't match (even though OHLC are correct). Another reason was that I check TradingView chart as well and their calculation also matches mine but not GDAX  
> **username_0**: @username_1 Glad I'm not the only one stuck here. Still no answer, but I did more investigating and have some ideas. The gray volume bars in the tradeview seem to be the sum of the live transaction amounts from the live ticker. It seems like everywhere else GDAX reports volume (such as in TradingView and the GDAX APIs), it's calculated differently. I noticed on TradingView they refer to the Volume as "Volume 20", so perhaps they're applying a rolling average?  
> **username_0**: Update: I just tried applying a bunch of rolling averages and emas to the Volume from Tick data, to see if it would match the volume from GDAX's candle data, with no luck.  
> **username_1**: I also tried it with the live ticker and it doesn't match. Clearly, the `sum(size)` of trades in an interval should be the volume but that just does not match the GDAX api. I have tested other exchanges and they are fine. so I take my calculated value as correct.  
> **username_2**: just curious.. what "tick data" did you use? I looked at GDAX's api doc and there seems to be a few channels and types of messages you can use.  

---

## 1 answers

### Answer by username_3 on 2018-06-28. Score: 1

I can't answer for the discrepancy that you're seeing, but the "right" way to calculate volume would be to add the "total" column from each trade that occurred during the period. That is, assuming that candle charts are based on stock market candle charts.

It doesn't surprise me that you're seeing this discrepancy, however. I've noticed a few different cryptocurrency APIs that have no idea how to calculate OHLCV data the right way. If your candle data isn't correct, then none of the traditional TA-Lib functions username_2 mean anything!


---

