A lightweight Go utility to fetch historical candle data (OHLCV) from the Bitget USDT-Futures exchange and save it directly to CSV files for analysis, backtesting, or record-keeping.
- Fetches high-granularity market data (1H and 4H timeframes).
- Automatically exports to structured CSV files.
- Supports custom trading pairs via command-line flags.
- Built-in utility to verify and format Unix timestamps.
- Zero external dependencies (uses standard library only).
This project provides a simple interface to the Bitget V2 API. It targets the USDT-MIX (Futures) market to retrieve Open, High, Low, Close, Base Volume, and Quote Volume data.
The application is designed for speed and reliability. It fetches the last 90 days of 4-hour candles and the last 1,000 hourly candles in a single execution. The data is stored in a local data/ directory, making it immediately available for tools like Excel, Python/Pandas, or R.
Ensure you have Go 1.26 or later installed on your system.
-
Clone the repository:
git clone https://github.com/zam/get-bitget-market-data.git cd get-bitget-market-data -
Build | run the main application:
go run main.go go build -o get-bitget-data main.goRun the compiled binary. By default, it fetches data for BTCUSDT.
./get-bitget-dataYou can specify any valid Bitget USDT-Futures symbol using the -symbol flag:
./get-bitget-data -symbol ETHUSDTThe program creates a data/ folder and populates it with:
1H.csv: Hourly candle data.4H.csv: 4-hour candle data.
The CSV format follows this structure:
UnixMS, Open, High, Low, Close, BaseVol, QuoteVol
The project includes a secondary tool to verify the integrity of the downloaded data and convert Unix milliseconds into human-readable RFC3339 timestamps.
To run the verification tool:
go run cmd/unix-verify.goThis will output the total row count and the start/end dates for each CSV file in the data/ directory.
- API Endpoint:
api.bitget.com/api/v2/mix/market/candles - Product Type: USDT-FUTURES
- Limit: Maximum of 1,000 candles per request.
- Storage: Data is overwritten on each run to ensure the latest market information is captured.