Stop- and start-amount of candlesticks not equal

If you look at candlesticks, and disregard the wick, a candlestick is just an opening and closing time with a corresponding opening amount and a closing amount. The opening amount and closing amount should be exactly the same. But… I discovered I was wrong.

How can there be a gap between the closing amount of one candlestick and the opening amount of the next? Anyone?

My theory is that is had something to do with the opening en closing time. THEY ARE NOT THE SAME? Binance uses “inclusive end ranges” and not “exclusive end ranges”.

The API-docs shows these examples of a candlestick:

1499040000000, // Open time
1499644799999, // Close time

So I assume the next candlestick has a new round opening time. So there might be a difference between opening and closing of about 1ms. That is simple bad design, right?

If my theory is correct then it would explain the chats. I hope I am wrong. Does anyone know more?

Hi.
May I know why do you think the opening amount should be the same as the closing amount if the closing time of the previous candlestick’s timestamp follows exclusive end range?

Here is the rephrased definition of opening price and the closing price (Please suggest the other reference if this is not good enough):

  1. Opening price: first trades upon the opening of an exchange in a trading period ( https://www.investopedia.com/terms/o/openingprice.asp )
  2. Closing price: the last transacted price before the market officially closes ( https://www.investopedia.com/terms/c/closingprice.asp )

So, it is quite clear that no matter what kind of the timestamp range policy is applied, opening price may be different from the closing price because they are different transactions.

If we take a closer look at the timeline, it should be something like this:
market opens -> first transaction (opening price) -> some more transactions -> last transaction (closing price) -> market closes -> market opens again -> first transaction of the next candlestick (opening price) -> some more transactions …

Why would someone wanna skip a (small) period between candlestick? Then the chart would be missing information.

You are quoting from an article that is describing opening- and closing times of a market / stock exchange. That is not the same as opening- and closing times of a candlestick. The whole article you are referring to does not even mention the word “candlestick” or “kindle”.

I think there’s a misunderstanding of how Candlesticks works, hope the below helps to clarify:

1- Focusing on only open and close time of 2 days candlesticks:

[
    1623628800000, //14 June 2021 00:00:00 Open Time
    ...
    1623715199999, //14 June 2021 23:59:59.999 Close Time
    ...
],
[
    1623715200000, //15 June 2021 00:00:00 Open Time
    ...
    1623801599999, //15 June 2021 23:59:59.999 Close Time
    ...
]

At 14th of June, all trades within [00:00:00, 23:59:59.999] are included.
At 15th of June, all trades within [00:00:00, 23:59:59.999] are included.

Conclusions:
14th of June’s last trade at 23:59:59.999 is not the same as 15th of June’s first trade at 00:00:00.
Until start of 15th of June’s 00:00:00, all trades will belong to 14th of June, with no gap/missing milliseconds.

2 - You can’t see open/close amount (assuming you mean one day’s 1st and last trade’s quantity) in the candlestick:

[
1499040000000, // Open time
“0.01634790”, // Open price
“0.80000000”, // High price
“0.01575800”, // Low price
“0.01577100”, // Close price
“148976.11427815”, // Base asset volume
1499644799999, // Close time
“2434.19055334”, // Quote asset volume
308, // Number of trades
“1756.87402397”, // Taker buy base asset volume
“28.46694368”, // Taker buy quote asset volume
“17928899.62484339” // Ignore.
]

  1. So where goes the trade which happens at 23:59:59.999 and 500 micro seconds (this: 23:59:59.9995)? Because that time is past the end-time of de 14th of June but is before the 15th?
  1. My mistake. I used the word “Amount”, but I meant “Price”. The question remains the same: Why do I see candlesticks (i usually use the candlesticks of 15 minutes) which opening price is not the same as the closing price of the previous candlestick?

Hi Aisling, I added a picture for more clearity.

Still there?

I added a picture for more clearity.

Candlesticks are built from trades. 1 candle represents a group of trades, and has various attributes of a group of trades, including open/close price, trade volume, etc.

A trade can only belong to 1 group - 1 candle, otherwise it would be double-counted in various metrics like candle trade volume. Binance has 1ms resolution of trade timestamps, trades happening say 500micros after 999th millisecond are timestamped the same as ones happening on the 10th microsecond.

So, if last trade of previous candle has a different price from the first trade of the next candle, then open/close prices won’t match, as you have discovered. This is more common and visible on pairs with high spread and big zoom: if last trade of previous candle was one side (say a sell) and the first trade of the other candle was the other side (a buy) then prices will differ in spread, which is big and visible.

Does this make sense?