# Binance Data Downloader | Binance数据下载器
[English](#overview) | [中文](#binance数据下载器)
A powerful command-line tool for downloading cryptocurrency data from Binance's public data repository.
## Overview
Binance Data Downloader is a Python-based utility that allows you to easily download historical cryptocurrency data from [Binance's public data repository](https://data.binance.vision/?prefix=data/). The tool provides a user-friendly interface to browse and download various types of market data, including spot,futures and option trading data, with options for different time intervals and trading pairs.
## Features
- **Interactive Data Selection**: Browse and select from available data types, intervals, symbols, and trading pairs
- **Command-line Automation**: Specify parameters directly via command-line arguments for automated downloads
- **Concurrent Downloads**: Download multiple files simultaneously for faster data retrieval
- **Checksum Verification**: Verify file integrity using checksums
- **Automatic Extraction**: Extract downloaded ZIP files automatically
- **Date Range Filtering**: Download only data within a specific date range
- **Proxy Support**: Use a proxy for downloads if needed
- **Detailed Logging**: Get comprehensive information about the download process
## Installation
### Using pip
```bash
pip install binance-data-downloader
```
### Using uv
uv is a powerful package management and execution tool. It simplifies the process of managing and running Python packages. To install binance-data-downloader using uv, you can use the following command:
Use uvx (recommended):
The uvx command invokes a tool without installing it.
Tools are installed into temporary, isolated environments when using uvx.
```bash
uvx binance-data-downloader
```
or use uv add:
```bash
uv add binance-data-downloader
```
This command adds the binance-data-downloader package to your uv environment.
### From Source
If you prefer to install from the source code, you can follow these steps:
```bash
git clone https://github.com/BaigeiMaster/binance-data-downloader.git
cd binance-data-downloader
pip install .
```
## Usage
### Interactive Mode
Simply run the command without any arguments to enter interactive mode:
```bash
binance-data-downloader
```
For interactive mode, there are two parameters to specify:
1. Whether to extract files (--extract)
2. Whether to verify checksums (--verify-checksum)
If no arguments are provided, files are not extracted by default and checksums are not verified.
The tool will guide you through selecting:
1. Data type (spot, futures, etc.)
2. Interval (daily, monthly, etc.)
3. Symbol type (klines, trades, aggTrades, etc.)
4. Trading pair (BTCUSDT, ETHUSDT, etc.)
5. Time interval for klines data (1m, 5m, 15m, etc.)
6. Date range (optional)
### Command-line Arguments
For automated downloads or interactive mode, you can specify parameters directly:
```bash
binance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m --start-date 2023-01-01 --end-date 2023-01-05 --verify-checksum --extract --extract-dir ./release/klines
```
### Available Options
```
--proxy Proxy URL
--retry-count Number of retries for failed downloads (default: 3)
--max-concurrent-downloads Maximum number of concurrent downloads (default: 5)
--max-concurrent-extractions Maximum number of concurrent extractions (default: 5)
--output-dir Output directory (default: ./downloads)
--verify-checksum Whether to verify the checksum (default: false)
--extract Extract files after downloading (default: false)
--use-default-extract-dir Use default extract directory (default: creates a new directory with'_extracted' suffix)
--extract-dir Directory to extract files to
--log-level Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
--data-type Pre-select data type (e.g., spot)
--interval Pre-select interval (e.g., daily, monthly)
--symbol Pre-select symbol (e.g., klines, aggTrades)
--trading-pair Pre-select trading pair (e.g., BTCUSDT)
--time-interval Pre-select time interval for klines (e.g., 1m, 5m)
--start-date Start date for filtering files (YYYY-MM-DD)
--end-date End date for filtering files (YYYY-MM-DD)
```
## Examples
### Download Daily Klines Data for BTCUSDT
```bash
binance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m
```
### Download with Date Range and Extraction
```bash
binance-data-downloader --data-type spot --interval daily --symbol trades --trading-pair ETHUSDT --start-date 2023-01-01 --end-date 2023-01-31 --extract
```
### Download with Custom Output Directory and Proxy
```bash
binance-data-downloader --data-type futures --interval um/daily --symbol aggTrades --trading-pair BTCUSDT --output-dir ./my_data --proxy http://myproxy:8080
```
## Project Structure
The project is organized as follows:
```
binance-data-downloader/
├── src/ # Source code
│ ├── cli/ # Command-line interface
│ │ ├── cli.py # Main CLI application
│ │ └── __init__.py
│ ├── directory_tree/ # Directory tree providers
│ │ ├── base.py # Abstract base class for directory tree providers
│ │ ├── binance.py # Binance-specific directory tree provider
│ │ └── __init__.py
│ ├── downloader/ # File downloaders
│ │ ├── base.py # Abstract base class for downloaders
│ │ ├── checksum.py # Checksum verification
│ │ ├── http_downloader.py # HTTP downloader implementation
│ │ └── __init__.py
│ └── __init__.py
├── tests/ # Unit tests
│ ├── test_cli.py # CLI tests
│ ├── test_directory_tree.py # Directory tree tests
│ ├── test_downloader.py # Downloader tests
│ └── __init__.py
├── __init__.py # Package initialization
├── main.py # Entry point script
├── pyproject.toml # Project metadata and dependencies
├── setup.py # Setup script for installation
├── MANIFEST.in # Package manifest
└── LICENSE # License file
```
### Key Components
- **CLI Module**: Handles user interaction, command-line arguments, and orchestrates the download process.
- **Directory Tree Module**: Provides an interface to browse Binance's data repository structure.
- **Downloader Module**: Manages file downloads, checksum verification, and file extraction.
The application follows a modular design with clear separation of concerns:
1. The `BinanceDirectoryTreeProvider` fetches the directory structure from Binance's data repository.
2. The `HttpDownloader` handles downloading files, verifying checksums, and extracting ZIP files.
3. The `CliApp` class ties everything together, providing both interactive and command-line interfaces.
## License
MIT License
---
# Binance数据下载器
*中文文档*
一个强大的命令行工具,用于从Binance公共数据仓库下载加密货币数据。
## 概述
Binance数据下载器是一个基于Python的实用工具,允许您轻松地从[Binance公共数据仓库](https://data.binance.vision/?prefix=data/)下载历史加密货币数据。该工具提供了一个用户友好的界面,用于浏览和下载各种类型的市场数据,包括现货、期货和期权交易数据,并提供不同的时间间隔和交易对选项。
## 功能特点
- **交互式数据选择**:浏览并选择可用的数据类型、时间间隔、符号和交易对
- **命令行自动化**:通过命令行参数直接指定参数,实现自动下载
- **并发下载**:同时下载多个文件,加快数据检索速度
- **校验和验证**:使用校验和验证文件完整性
- **自动解压**:自动解压下载的ZIP文件
- **日期范围过滤**:仅下载特定日期范围内的数据
- **代理支持**:如果需要,可以使用代理进行下载
- **详细日志**:获取有关下载过程的全面信息
## 安装
### 使用pip
```bash
pip install binance-data-downloader
```
### 使用uv
uv是一款功能强大的包管理和执行工具,简化了 Python 包的管理和运行流程。使用uv安装binance-data-downloader,可以使用以下命令:
#### 使用uvx(推荐):
该命令在不安装工具的情况下调用工具。
使用时,工具会安装到临时的、隔离的环境中。
```bash
uvx binance-data-downloader
```
#### 或者使用uv add:
```bash
uv add binance-data-downloader
```
此命令将binance-data-downloader包添加到您的uv环境中。
### 从源代码安装
若您倾向于从源代码安装,可按以下步骤操作:
```bash
git clone https://github.com/BaigeiMaster/binance-data-downloader.git
cd binance-data-downloader
pip install .
```
## 使用方法
### 交互模式
只需在不带任何参数的情况下运行命令即可进入交互模式:
```bash
binance-data-downloader
```
对于交互模式,有两个参数需要指定:
1. 是否解压文件 (--extract)
2. 是否验证校验和 (--verify-checksum)
若不带任何参数,默认不解压文件,不验证校验和。
该工具将引导您完成以下选择:
1. 数据类型(现货、期货等)
2. 时间间隔(每日、每月等)
3. 符号类型(K线、交易、聚合交易等)
4. 交易对(BTCUSDT、ETHUSDT等)
5. K线数据的时间间隔(1分钟、5分钟、15分钟等)
6. 日期范围(可选)
### 命令行参数
对于自动下载或交互模式,您可以直接指定参数:
```bash
binance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m --start-date 2023-01-01 --end-date 2023-01-05 --verify-checksum --extract --extract-dir ./release/klines
```
### 可用选项
```
--proxy 代理URL
--retry-count 失败下载的重试次数(默认:3)
--max-concurrent-downloads 最大并发下载数(默认:5)
--max-concurrent-extractions 最大并发解压数(默认:5)
--output-dir 输出目录(默认:./downloads)
--verify-checksum 是否验证校验和 (默认: False)
--extract 下载后解压文件 (默认:False)
--use-default-extract-dir 使用默认的解压目录 (默认:创建具有'_extracted'后缀的同一层级文件夹)
--extract-dir 解压文件的目录
--log-level 日志级别(DEBUG、INFO、WARNING、ERROR、CRITICAL)
--data-type 预选数据类型(例如,spot)
--interval 预选时间间隔(例如,daily、monthly)
--symbol 预选符号(例如,klines、aggTrades)
--trading-pair 预选交易对(例如,BTCUSDT)
--time-interval 预选K线的时间间隔(例如,1m、5m)
--start-date 过滤文件的开始日期(YYYY-MM-DD)
--end-date 过滤文件的结束日期(YYYY-MM-DD)
```
## 示例
### 下载BTCUSDT的每日K线数据
```bash
binance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m
```
### 下载指定日期范围的数据并解压
```bash
binance-data-downloader --data-type spot --interval daily --symbol trades --trading-pair ETHUSDT --start-date 2023-01-01 --end-date 2023-01-31 --extract
```
### 使用自定义输出目录和代理下载
```bash
binance-data-downloader --data-type futures --interval um/daily --symbol aggTrades --trading-pair BTCUSDT --output-dir ./my_data --proxy http://myproxy:8080
```
## 项目结构
项目组织如下:
```
binance-data-downloader/
├── src/ # 源代码
│ ├── cli/ # 命令行界面
│ │ ├── cli.py # 主CLI应用程序
│ │ └── __init__.py
│ ├── directory_tree/ # 目录树提供者
│ │ ├── base.py # 目录树提供者的抽象基类
│ │ ├── binance.py # Binance特定的目录树提供者
│ │ └── __init__.py
│ ├── downloader/ # 文件下载器
│ │ ├── base.py # 下载器的抽象基类
│ │ ├── checksum.py # 校验和验证
│ │ ├── http_downloader.py # HTTP下载器实现
│ │ └── __init__.py
│ └── __init__.py
├── tests/ # 单元测试
│ ├── test_cli.py # CLI测试
│ ├── test_directory_tree.py # 目录树测试
│ ├── test_downloader.py # 下载器测试
│ └── __init__.py
├── __init__.py # 包初始化
├── main.py # 入口点脚本
├── pyproject.toml # 项目元数据和依赖项
├── setup.py # 安装脚本
├── MANIFEST.in # 包清单
└── LICENSE # 许可证文件
```
### 核心组件
- **CLI模块**:处理用户交互、命令行参数,并协调下载过程。
- **目录树模块**:提供浏览Binance数据仓库结构的接口。
- **下载器模块**:管理文件下载、校验和验证和文件解压。
应用程序遵循模块化设计,职责明确分离:
1. `BinanceDirectoryTreeProvider`从Binance的数据仓库获取目录结构。
2. `HttpDownloader`处理文件下载、校验和验证以及ZIP文件解压。
3. `CliApp`类将所有组件连接在一起,提供交互式和命令行界面。
## 许可证
MIT许可证
Raw data
{
"_id": null,
"home_page": "https://github.com/BaigeiMaster/binance-data-downloader",
"name": "binance-data-downloader",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "cryptocurrency, data, downloader, binance",
"author": "Zhaorong Dai",
"author_email": "Zhaorong Dai <13710247598@163.com>",
"download_url": "https://files.pythonhosted.org/packages/a7/2e/58fc2b9b0ee34df829b739a92788486161128a9df12877245351d2386d6a/binance_data_downloader-0.2.0.tar.gz",
"platform": null,
"description": "# Binance Data Downloader | Binance\u6570\u636e\u4e0b\u8f7d\u5668\n\n[English](#overview) | [\u4e2d\u6587](#binance\u6570\u636e\u4e0b\u8f7d\u5668)\n\nA powerful command-line tool for downloading cryptocurrency data from Binance's public data repository.\n\n## Overview\n\nBinance Data Downloader is a Python-based utility that allows you to easily download historical cryptocurrency data from [Binance's public data repository](https://data.binance.vision/?prefix=data/). The tool provides a user-friendly interface to browse and download various types of market data, including spot,futures and option trading data, with options for different time intervals and trading pairs.\n\n## Features\n\n- **Interactive Data Selection**: Browse and select from available data types, intervals, symbols, and trading pairs\n- **Command-line Automation**: Specify parameters directly via command-line arguments for automated downloads\n- **Concurrent Downloads**: Download multiple files simultaneously for faster data retrieval\n- **Checksum Verification**: Verify file integrity using checksums\n- **Automatic Extraction**: Extract downloaded ZIP files automatically\n- **Date Range Filtering**: Download only data within a specific date range\n- **Proxy Support**: Use a proxy for downloads if needed\n- **Detailed Logging**: Get comprehensive information about the download process\n\n## Installation\n\n### Using pip\n\n```bash\npip install binance-data-downloader\n```\n\n### Using uv\nuv is a powerful package management and execution tool. It simplifies the process of managing and running Python packages. To install binance-data-downloader using uv, you can use the following command:\n\nUse uvx (recommended):\nThe uvx command invokes a tool without installing it.\nTools are installed into temporary, isolated environments when using uvx.\n\n```bash\nuvx binance-data-downloader\n```\n\nor use uv add:\n\n```bash\nuv add binance-data-downloader\n```\nThis command adds the binance-data-downloader package to your uv environment.\n\n### From Source\nIf you prefer to install from the source code, you can follow these steps:\n\n```bash\ngit clone https://github.com/BaigeiMaster/binance-data-downloader.git\ncd binance-data-downloader\npip install .\n```\n\n## Usage\n\n### Interactive Mode\n\nSimply run the command without any arguments to enter interactive mode:\n\n```bash\nbinance-data-downloader\n```\n\nFor interactive mode, there are two parameters to specify:\n\n1. Whether to extract files (--extract)\n2. Whether to verify checksums (--verify-checksum)\n\nIf no arguments are provided, files are not extracted by default and checksums are not verified.\n\n\nThe tool will guide you through selecting:\n1. Data type (spot, futures, etc.)\n2. Interval (daily, monthly, etc.)\n3. Symbol type (klines, trades, aggTrades, etc.)\n4. Trading pair (BTCUSDT, ETHUSDT, etc.)\n5. Time interval for klines data (1m, 5m, 15m, etc.)\n6. Date range (optional)\n\n### Command-line Arguments\n\nFor automated downloads or interactive mode, you can specify parameters directly:\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m --start-date 2023-01-01 --end-date 2023-01-05 --verify-checksum --extract --extract-dir ./release/klines\n```\n\n### Available Options\n\n```\n--proxy Proxy URL\n--retry-count Number of retries for failed downloads (default: 3)\n--max-concurrent-downloads Maximum number of concurrent downloads (default: 5)\n--max-concurrent-extractions Maximum number of concurrent extractions (default: 5)\n--output-dir Output directory (default: ./downloads)\n--verify-checksum Whether to verify the checksum (default: false)\n--extract Extract files after downloading (default: false)\n--use-default-extract-dir Use default extract directory (default: creates a new directory with'_extracted' suffix)\n--extract-dir Directory to extract files to\n--log-level Log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)\n--data-type Pre-select data type (e.g., spot)\n--interval Pre-select interval (e.g., daily, monthly)\n--symbol Pre-select symbol (e.g., klines, aggTrades)\n--trading-pair Pre-select trading pair (e.g., BTCUSDT)\n--time-interval Pre-select time interval for klines (e.g., 1m, 5m)\n--start-date Start date for filtering files (YYYY-MM-DD)\n--end-date End date for filtering files (YYYY-MM-DD)\n```\n\n## Examples\n\n### Download Daily Klines Data for BTCUSDT\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m\n```\n\n### Download with Date Range and Extraction\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol trades --trading-pair ETHUSDT --start-date 2023-01-01 --end-date 2023-01-31 --extract\n```\n\n### Download with Custom Output Directory and Proxy\n\n```bash\nbinance-data-downloader --data-type futures --interval um/daily --symbol aggTrades --trading-pair BTCUSDT --output-dir ./my_data --proxy http://myproxy:8080\n```\n\n## Project Structure\n\nThe project is organized as follows:\n\n```\nbinance-data-downloader/\n\u251c\u2500\u2500 src/ # Source code\n\u2502 \u251c\u2500\u2500 cli/ # Command-line interface\n\u2502 \u2502 \u251c\u2500\u2500 cli.py # Main CLI application\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 directory_tree/ # Directory tree providers\n\u2502 \u2502 \u251c\u2500\u2500 base.py # Abstract base class for directory tree providers\n\u2502 \u2502 \u251c\u2500\u2500 binance.py # Binance-specific directory tree provider\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 downloader/ # File downloaders\n\u2502 \u2502 \u251c\u2500\u2500 base.py # Abstract base class for downloaders\n\u2502 \u2502 \u251c\u2500\u2500 checksum.py # Checksum verification\n\u2502 \u2502 \u251c\u2500\u2500 http_downloader.py # HTTP downloader implementation\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u2514\u2500\u2500 __init__.py\n\u251c\u2500\u2500 tests/ # Unit tests\n\u2502 \u251c\u2500\u2500 test_cli.py # CLI tests\n\u2502 \u251c\u2500\u2500 test_directory_tree.py # Directory tree tests\n\u2502 \u251c\u2500\u2500 test_downloader.py # Downloader tests\n\u2502 \u2514\u2500\u2500 __init__.py\n\u251c\u2500\u2500 __init__.py # Package initialization\n\u251c\u2500\u2500 main.py # Entry point script\n\u251c\u2500\u2500 pyproject.toml # Project metadata and dependencies\n\u251c\u2500\u2500 setup.py # Setup script for installation\n\u251c\u2500\u2500 MANIFEST.in # Package manifest\n\u2514\u2500\u2500 LICENSE # License file\n```\n\n### Key Components\n\n- **CLI Module**: Handles user interaction, command-line arguments, and orchestrates the download process.\n- **Directory Tree Module**: Provides an interface to browse Binance's data repository structure.\n- **Downloader Module**: Manages file downloads, checksum verification, and file extraction.\n\nThe application follows a modular design with clear separation of concerns:\n\n1. The `BinanceDirectoryTreeProvider` fetches the directory structure from Binance's data repository.\n2. The `HttpDownloader` handles downloading files, verifying checksums, and extracting ZIP files.\n3. The `CliApp` class ties everything together, providing both interactive and command-line interfaces.\n\n## License\n\nMIT License\n\n---\n\n# Binance\u6570\u636e\u4e0b\u8f7d\u5668\n\n*\u4e2d\u6587\u6587\u6863*\n\n\u4e00\u4e2a\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u4eceBinance\u516c\u5171\u6570\u636e\u4ed3\u5e93\u4e0b\u8f7d\u52a0\u5bc6\u8d27\u5e01\u6570\u636e\u3002\n\n## \u6982\u8ff0\n\nBinance\u6570\u636e\u4e0b\u8f7d\u5668\u662f\u4e00\u4e2a\u57fa\u4e8ePython\u7684\u5b9e\u7528\u5de5\u5177\uff0c\u5141\u8bb8\u60a8\u8f7b\u677e\u5730\u4ece[Binance\u516c\u5171\u6570\u636e\u4ed3\u5e93](https://data.binance.vision/?prefix=data/)\u4e0b\u8f7d\u5386\u53f2\u52a0\u5bc6\u8d27\u5e01\u6570\u636e\u3002\u8be5\u5de5\u5177\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7528\u6237\u53cb\u597d\u7684\u754c\u9762\uff0c\u7528\u4e8e\u6d4f\u89c8\u548c\u4e0b\u8f7d\u5404\u79cd\u7c7b\u578b\u7684\u5e02\u573a\u6570\u636e\uff0c\u5305\u62ec\u73b0\u8d27\u3001\u671f\u8d27\u548c\u671f\u6743\u4ea4\u6613\u6570\u636e\uff0c\u5e76\u63d0\u4f9b\u4e0d\u540c\u7684\u65f6\u95f4\u95f4\u9694\u548c\u4ea4\u6613\u5bf9\u9009\u9879\u3002\n\n## \u529f\u80fd\u7279\u70b9\n\n- **\u4ea4\u4e92\u5f0f\u6570\u636e\u9009\u62e9**\uff1a\u6d4f\u89c8\u5e76\u9009\u62e9\u53ef\u7528\u7684\u6570\u636e\u7c7b\u578b\u3001\u65f6\u95f4\u95f4\u9694\u3001\u7b26\u53f7\u548c\u4ea4\u6613\u5bf9\n- **\u547d\u4ee4\u884c\u81ea\u52a8\u5316**\uff1a\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u76f4\u63a5\u6307\u5b9a\u53c2\u6570\uff0c\u5b9e\u73b0\u81ea\u52a8\u4e0b\u8f7d\n- **\u5e76\u53d1\u4e0b\u8f7d**\uff1a\u540c\u65f6\u4e0b\u8f7d\u591a\u4e2a\u6587\u4ef6\uff0c\u52a0\u5feb\u6570\u636e\u68c0\u7d22\u901f\u5ea6\n- **\u6821\u9a8c\u548c\u9a8c\u8bc1**\uff1a\u4f7f\u7528\u6821\u9a8c\u548c\u9a8c\u8bc1\u6587\u4ef6\u5b8c\u6574\u6027\n- **\u81ea\u52a8\u89e3\u538b**\uff1a\u81ea\u52a8\u89e3\u538b\u4e0b\u8f7d\u7684ZIP\u6587\u4ef6\n- **\u65e5\u671f\u8303\u56f4\u8fc7\u6ee4**\uff1a\u4ec5\u4e0b\u8f7d\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u5185\u7684\u6570\u636e\n- **\u4ee3\u7406\u652f\u6301**\uff1a\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7406\u8fdb\u884c\u4e0b\u8f7d\n- **\u8be6\u7ec6\u65e5\u5fd7**\uff1a\u83b7\u53d6\u6709\u5173\u4e0b\u8f7d\u8fc7\u7a0b\u7684\u5168\u9762\u4fe1\u606f\n\n## \u5b89\u88c5\n\n### \u4f7f\u7528pip\n\n```bash\npip install binance-data-downloader\n```\n\n### \u4f7f\u7528uv\nuv\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5305\u7ba1\u7406\u548c\u6267\u884c\u5de5\u5177\uff0c\u7b80\u5316\u4e86 Python \u5305\u7684\u7ba1\u7406\u548c\u8fd0\u884c\u6d41\u7a0b\u3002\u4f7f\u7528uv\u5b89\u88c5binance-data-downloader\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\n\n#### \u4f7f\u7528uvx\uff08\u63a8\u8350\uff09\uff1a\n\u8be5\u547d\u4ee4\u5728\u4e0d\u5b89\u88c5\u5de5\u5177\u7684\u60c5\u51b5\u4e0b\u8c03\u7528\u5de5\u5177\u3002\n\u4f7f\u7528\u65f6\uff0c\u5de5\u5177\u4f1a\u5b89\u88c5\u5230\u4e34\u65f6\u7684\u3001\u9694\u79bb\u7684\u73af\u5883\u4e2d\u3002\n\n```bash\nuvx binance-data-downloader\n```\n\n#### \u6216\u8005\u4f7f\u7528uv add\uff1a\n\n```bash\nuv add binance-data-downloader\n```\n\n\u6b64\u547d\u4ee4\u5c06binance-data-downloader\u5305\u6dfb\u52a0\u5230\u60a8\u7684uv\u73af\u5883\u4e2d\u3002\n\n### \u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\n\u82e5\u60a8\u503e\u5411\u4e8e\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\uff0c\u53ef\u6309\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a\n\n```bash\ngit clone https://github.com/BaigeiMaster/binance-data-downloader.git\ncd binance-data-downloader\npip install .\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u4ea4\u4e92\u6a21\u5f0f\n\n\u53ea\u9700\u5728\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u547d\u4ee4\u5373\u53ef\u8fdb\u5165\u4ea4\u4e92\u6a21\u5f0f\uff1a\n\n```bash\nbinance-data-downloader\n```\n\n\u5bf9\u4e8e\u4ea4\u4e92\u6a21\u5f0f\uff0c\u6709\u4e24\u4e2a\u53c2\u6570\u9700\u8981\u6307\u5b9a\uff1a\n\n1. \u662f\u5426\u89e3\u538b\u6587\u4ef6 (--extract)\n2. \u662f\u5426\u9a8c\u8bc1\u6821\u9a8c\u548c (--verify-checksum)\n\n\u82e5\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\uff0c\u9ed8\u8ba4\u4e0d\u89e3\u538b\u6587\u4ef6\uff0c\u4e0d\u9a8c\u8bc1\u6821\u9a8c\u548c\u3002\n\n\u8be5\u5de5\u5177\u5c06\u5f15\u5bfc\u60a8\u5b8c\u6210\u4ee5\u4e0b\u9009\u62e9\uff1a\n1. \u6570\u636e\u7c7b\u578b\uff08\u73b0\u8d27\u3001\u671f\u8d27\u7b49\uff09\n2. \u65f6\u95f4\u95f4\u9694\uff08\u6bcf\u65e5\u3001\u6bcf\u6708\u7b49\uff09\n3. \u7b26\u53f7\u7c7b\u578b\uff08K\u7ebf\u3001\u4ea4\u6613\u3001\u805a\u5408\u4ea4\u6613\u7b49\uff09\n4. \u4ea4\u6613\u5bf9\uff08BTCUSDT\u3001ETHUSDT\u7b49\uff09\n5. K\u7ebf\u6570\u636e\u7684\u65f6\u95f4\u95f4\u9694\uff081\u5206\u949f\u30015\u5206\u949f\u300115\u5206\u949f\u7b49\uff09\n6. \u65e5\u671f\u8303\u56f4\uff08\u53ef\u9009\uff09\n\n### \u547d\u4ee4\u884c\u53c2\u6570\n\n\u5bf9\u4e8e\u81ea\u52a8\u4e0b\u8f7d\u6216\u4ea4\u4e92\u6a21\u5f0f\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9a\u53c2\u6570\uff1a\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m --start-date 2023-01-01 --end-date 2023-01-05 --verify-checksum --extract --extract-dir ./release/klines\n```\n\n### \u53ef\u7528\u9009\u9879\n\n```\n--proxy \u4ee3\u7406URL\n--retry-count \u5931\u8d25\u4e0b\u8f7d\u7684\u91cd\u8bd5\u6b21\u6570\uff08\u9ed8\u8ba4\uff1a3\uff09\n--max-concurrent-downloads \u6700\u5927\u5e76\u53d1\u4e0b\u8f7d\u6570\uff08\u9ed8\u8ba4\uff1a5\uff09\n--max-concurrent-extractions \u6700\u5927\u5e76\u53d1\u89e3\u538b\u6570\uff08\u9ed8\u8ba4\uff1a5\uff09\n--output-dir \u8f93\u51fa\u76ee\u5f55\uff08\u9ed8\u8ba4\uff1a./downloads\uff09\n--verify-checksum \u662f\u5426\u9a8c\u8bc1\u6821\u9a8c\u548c (\u9ed8\u8ba4: False)\n--extract \u4e0b\u8f7d\u540e\u89e3\u538b\u6587\u4ef6 (\u9ed8\u8ba4\uff1aFalse)\n--use-default-extract-dir \u4f7f\u7528\u9ed8\u8ba4\u7684\u89e3\u538b\u76ee\u5f55 (\u9ed8\u8ba4\uff1a\u521b\u5efa\u5177\u6709'_extracted'\u540e\u7f00\u7684\u540c\u4e00\u5c42\u7ea7\u6587\u4ef6\u5939)\n--extract-dir \u89e3\u538b\u6587\u4ef6\u7684\u76ee\u5f55\n--log-level \u65e5\u5fd7\u7ea7\u522b\uff08DEBUG\u3001INFO\u3001WARNING\u3001ERROR\u3001CRITICAL\uff09\n--data-type \u9884\u9009\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982\uff0cspot\uff09\n--interval \u9884\u9009\u65f6\u95f4\u95f4\u9694\uff08\u4f8b\u5982\uff0cdaily\u3001monthly\uff09\n--symbol \u9884\u9009\u7b26\u53f7\uff08\u4f8b\u5982\uff0cklines\u3001aggTrades\uff09\n--trading-pair \u9884\u9009\u4ea4\u6613\u5bf9\uff08\u4f8b\u5982\uff0cBTCUSDT\uff09\n--time-interval \u9884\u9009K\u7ebf\u7684\u65f6\u95f4\u95f4\u9694\uff08\u4f8b\u5982\uff0c1m\u30015m\uff09\n--start-date \u8fc7\u6ee4\u6587\u4ef6\u7684\u5f00\u59cb\u65e5\u671f\uff08YYYY-MM-DD\uff09\n--end-date \u8fc7\u6ee4\u6587\u4ef6\u7684\u7ed3\u675f\u65e5\u671f\uff08YYYY-MM-DD\uff09\n```\n\n## \u793a\u4f8b\n\n### \u4e0b\u8f7dBTCUSDT\u7684\u6bcf\u65e5K\u7ebf\u6570\u636e\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol klines --trading-pair BTCUSDT --time-interval 1m\n```\n\n### \u4e0b\u8f7d\u6307\u5b9a\u65e5\u671f\u8303\u56f4\u7684\u6570\u636e\u5e76\u89e3\u538b\n\n```bash\nbinance-data-downloader --data-type spot --interval daily --symbol trades --trading-pair ETHUSDT --start-date 2023-01-01 --end-date 2023-01-31 --extract\n```\n\n### \u4f7f\u7528\u81ea\u5b9a\u4e49\u8f93\u51fa\u76ee\u5f55\u548c\u4ee3\u7406\u4e0b\u8f7d\n\n```bash\nbinance-data-downloader --data-type futures --interval um/daily --symbol aggTrades --trading-pair BTCUSDT --output-dir ./my_data --proxy http://myproxy:8080\n```\n\n## \u9879\u76ee\u7ed3\u6784\n\n\u9879\u76ee\u7ec4\u7ec7\u5982\u4e0b\uff1a\n\n```\nbinance-data-downloader/\n\u251c\u2500\u2500 src/ # \u6e90\u4ee3\u7801\n\u2502 \u251c\u2500\u2500 cli/ # \u547d\u4ee4\u884c\u754c\u9762\n\u2502 \u2502 \u251c\u2500\u2500 cli.py # \u4e3bCLI\u5e94\u7528\u7a0b\u5e8f\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 directory_tree/ # \u76ee\u5f55\u6811\u63d0\u4f9b\u8005\n\u2502 \u2502 \u251c\u2500\u2500 base.py # \u76ee\u5f55\u6811\u63d0\u4f9b\u8005\u7684\u62bd\u8c61\u57fa\u7c7b\n\u2502 \u2502 \u251c\u2500\u2500 binance.py # Binance\u7279\u5b9a\u7684\u76ee\u5f55\u6811\u63d0\u4f9b\u8005\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 downloader/ # \u6587\u4ef6\u4e0b\u8f7d\u5668\n\u2502 \u2502 \u251c\u2500\u2500 base.py # \u4e0b\u8f7d\u5668\u7684\u62bd\u8c61\u57fa\u7c7b\n\u2502 \u2502 \u251c\u2500\u2500 checksum.py # \u6821\u9a8c\u548c\u9a8c\u8bc1\n\u2502 \u2502 \u251c\u2500\u2500 http_downloader.py # HTTP\u4e0b\u8f7d\u5668\u5b9e\u73b0\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u2514\u2500\u2500 __init__.py\n\u251c\u2500\u2500 tests/ # \u5355\u5143\u6d4b\u8bd5\n\u2502 \u251c\u2500\u2500 test_cli.py # CLI\u6d4b\u8bd5\n\u2502 \u251c\u2500\u2500 test_directory_tree.py # \u76ee\u5f55\u6811\u6d4b\u8bd5\n\u2502 \u251c\u2500\u2500 test_downloader.py # \u4e0b\u8f7d\u5668\u6d4b\u8bd5\n\u2502 \u2514\u2500\u2500 __init__.py\n\u251c\u2500\u2500 __init__.py # \u5305\u521d\u59cb\u5316\n\u251c\u2500\u2500 main.py # \u5165\u53e3\u70b9\u811a\u672c\n\u251c\u2500\u2500 pyproject.toml # \u9879\u76ee\u5143\u6570\u636e\u548c\u4f9d\u8d56\u9879\n\u251c\u2500\u2500 setup.py # \u5b89\u88c5\u811a\u672c\n\u251c\u2500\u2500 MANIFEST.in # \u5305\u6e05\u5355\n\u2514\u2500\u2500 LICENSE # \u8bb8\u53ef\u8bc1\u6587\u4ef6\n```\n\n### \u6838\u5fc3\u7ec4\u4ef6\n\n- **CLI\u6a21\u5757**\uff1a\u5904\u7406\u7528\u6237\u4ea4\u4e92\u3001\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u5e76\u534f\u8c03\u4e0b\u8f7d\u8fc7\u7a0b\u3002\n- **\u76ee\u5f55\u6811\u6a21\u5757**\uff1a\u63d0\u4f9b\u6d4f\u89c8Binance\u6570\u636e\u4ed3\u5e93\u7ed3\u6784\u7684\u63a5\u53e3\u3002\n- **\u4e0b\u8f7d\u5668\u6a21\u5757**\uff1a\u7ba1\u7406\u6587\u4ef6\u4e0b\u8f7d\u3001\u6821\u9a8c\u548c\u9a8c\u8bc1\u548c\u6587\u4ef6\u89e3\u538b\u3002\n\n\u5e94\u7528\u7a0b\u5e8f\u9075\u5faa\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u804c\u8d23\u660e\u786e\u5206\u79bb\uff1a\n\n1. `BinanceDirectoryTreeProvider`\u4eceBinance\u7684\u6570\u636e\u4ed3\u5e93\u83b7\u53d6\u76ee\u5f55\u7ed3\u6784\u3002\n2. `HttpDownloader`\u5904\u7406\u6587\u4ef6\u4e0b\u8f7d\u3001\u6821\u9a8c\u548c\u9a8c\u8bc1\u4ee5\u53caZIP\u6587\u4ef6\u89e3\u538b\u3002\n3. `CliApp`\u7c7b\u5c06\u6240\u6709\u7ec4\u4ef6\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u63d0\u4f9b\u4ea4\u4e92\u5f0f\u548c\u547d\u4ee4\u884c\u754c\u9762\u3002\n\n## \u8bb8\u53ef\u8bc1\n\nMIT\u8bb8\u53ef\u8bc1\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A command-line tool for downloading cryptocurrency data from Binance",
"version": "0.2.0",
"project_urls": {
"Bug Tracker": "https://github.com/ZhaorongDai/binance-data-downloader/issues",
"Homepage": "https://github.com/ZhaorongDai/binance-data-downloader"
},
"split_keywords": [
"cryptocurrency",
" data",
" downloader",
" binance"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2c80738db69e5b15c68d6a0963dd7aeee51018c5c45f0c55892c5ea153aaa6e8",
"md5": "00380c48ac9c644b470cc9252caad7ff",
"sha256": "cfbcb998a74da304090770432db142c53c2743bbfd1d23957b19bbdfa27c5a3e"
},
"downloads": -1,
"filename": "binance_data_downloader-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "00380c48ac9c644b470cc9252caad7ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 28108,
"upload_time": "2025-08-21T03:48:52",
"upload_time_iso_8601": "2025-08-21T03:48:52.600867Z",
"url": "https://files.pythonhosted.org/packages/2c/80/738db69e5b15c68d6a0963dd7aeee51018c5c45f0c55892c5ea153aaa6e8/binance_data_downloader-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a72e58fc2b9b0ee34df829b739a92788486161128a9df12877245351d2386d6a",
"md5": "cc54d3f93afe0f7ea263225bb3598bc2",
"sha256": "37b12fbbb1b3474656d2f789600e8d2603a75d65beafbc25df1c33fa12f40fea"
},
"downloads": -1,
"filename": "binance_data_downloader-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "cc54d3f93afe0f7ea263225bb3598bc2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 24699,
"upload_time": "2025-08-21T03:48:55",
"upload_time_iso_8601": "2025-08-21T03:48:55.093381Z",
"url": "https://files.pythonhosted.org/packages/a7/2e/58fc2b9b0ee34df829b739a92788486161128a9df12877245351d2386d6a/binance_data_downloader-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-21 03:48:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BaigeiMaster",
"github_project": "binance-data-downloader",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "binance-data-downloader"
}