-1

I need to some how get the tick data for BTCUSDT for specific days. This is the raw tick data, the ( Last Price ) I will attach an image of a chart from TV and the price that shows on the right that moves up and down every second, I need that price but I need it for 1 month.

I have tried the following sites to obtain it but I am probably missing something or just dont know how to get the BTCUSDT 1 second raw tick data for 1 month.

Binance Data Collection

https://github.com/binance/binance-public-data

https://pypi.org/project/binance-historical-data/

enter image description here

I just need to know how to obtain Binance BTCUSDT 1 second raw tick data (last price) for the month of July would be great.

Optimus Prime
  • 43
  • 1
  • 11

1 Answers1

0

Binance provides some of its historical trading data on the binance.vision domain. Specifically, the 1 second klines for BTCUSDT pair can be found here: https://data.binance.vision/?prefix=data/spot/daily/klines/BTCUSDT/1s/

Here's a sample bash script that downloads and unpacks the raw data for the whole month:

#!/bin/bash
for i in $(seq -f "%02g" 1 31) # zero-padded days 01, 02, 03, ... 31
do
    # month of july 2023, day number is the `i` variable
    archiveName="BTCUSDT-1s-2023-07-${i}.zip"
    # download the .zip, extract it (saves .csv), and remove the .zip
    wget "https://data.binance.vision/data/spot/daily/klines/BTCUSDT/1s/${archiveName}" && unzip "./${archiveName}" && rm "./${archiveName}"
done

As mentioned in their GitHub readme, each of the the .csv lines contains the following field values:

Open time Open High Low Close Volume Close time Quote asset volume Number of trades Taker buy base asset volume Taker buy quote asset volume Ignore

So for example, the file BTCUSDT-1s-2023-07-01.csv containing this first line

1688169600000,30471.99000000,30472.00000000,30471.99000000,30472.00000000,0.54114000,1688169600999,16489.61790060,31,0.52320000,15942.95040000,0

enables you to calculate this:

  • From millisecond timestamp 1688169600000 (July 1st, 2023 0:00:00 UTC)
  • To millisecond timestamp 1688169600999 (July 1st, 2023 0:00:00.999 UTC)
  • Full candle
    • Open price 30471.99 USDT for 1 BTC
    • Close price 30472.00 USDT for 1 BTC
    • Close is higher than open => candle is green
  • Knots
    • Lowest price 30471.99 USDT for 1 BTC
      • Same as open price of green candle => no knot below
    • Highest price 30472.00 USDT for 1 BTC
      • Same as close price of green candle => no knot above
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • thank you for your excellent description Petr, so just to understand what you are saying: The first column in the spreadsheet (csv) is the EPOCH time stamp and the 2nd column is the opening price displayed on the chart above. So for example if you notice my image above (orignal question) I would be able to get the EPOCH time from the csv as to when the price was 25899. So at any given point in time, using the EPOCH timestamp I can see what the price was for the coin on every second? The price displayed on the image above. – Optimus Prime Aug 22 '23 at 16:21
  • @OptimusPrime Yes - the CSVs enable you to get the epochs by the price. The same price might be present in multiple epochs, so its up to your decision if you're looking for the first occurrence of the price / last occurrence / time ranges / etc. You can either loop through all the epochs and search for the price occurrence - or you can insert the data into a searchable database and filter using database queries (SQL for example; preferred for larger data sets)... Same is possible the other way around: You can query a specific epoch and retrieve the price in that epoch. – Petr Hejda Aug 22 '23 at 18:05