A lightweight Python module for downloading Binance futures market data with caching support
Project description
Cached Binance Futures Data Downloader
A lightweight Python module for downloading Binance futures market data with efficient caching support.
Features
- Download Binance futures data for different timeframes
- Support for custom start and end periods
- Efficient caching mechanism with automatic system document folder integration
- Handles Binance API rate limits automatically
- Supports various timeframes (1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M)
- Minimal dependencies with pure Python implementation
Installation
pip install cached-binance-data
Dependencies
- python-binance>=1.0.16: Core Binance API functionality
- requests>=2.26.0: HTTP requests handling
- python-dateutil>=2.8.2: Date manipulation utilities
- pytest>=7.0.0: Testing framework (development only)
Quick Start
from cached_binance_data import BinanceDataDownloader
# Initialize downloader (uses system document folder by default)
downloader = BinanceDataDownloader()
# Or specify a custom cache directory
# downloader = BinanceDataDownloader(cache_dir="path/to/cache")
# Download XRPUSDT data for a specific period
data = downloader.download(
symbol="XRPUSDT",
timeframe="1m",
start_time="2024-01-01",
end_time="2024-01-31"
)
# Data is returned as a list of [timestamp, high, low, open, close, volume]
print(f"Downloaded {len(data)} data points")
Cache Structure
By default, data is cached in your system's document folder under binance_data/:
- Windows:
C:/Users/<username>/Documents/binance_data/ - macOS:
/Users/<username>/Documents/binance_data/ - Linux:
~/Documents/binance_data/or~/binance_data/
Cache files are stored with the following format:
SYMBOL_TIMEFRAME_STARTDATE_ENDDATE.csv
Example: XRPUSDT_1M_20240101_20240131.csv
You can specify a custom cache directory when initializing the downloader:
downloader = BinanceDataDownloader(cache_dir="path/to/cache")
Features
- Automatic data chunking for large date ranges
- Smart caching system with system integration
- Handles rate limits gracefully
- Supports all Binance futures trading pairs
- Efficient CSV-based caching for better compatibility
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cached_binance_data-0.2.0.tar.gz.
File metadata
- Download URL: cached_binance_data-0.2.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04f00353abbb208f6d6c1339b7a0b5eb105ed8b96c722549e26a56e0edecaa0c
|
|
| MD5 |
5cdb07735b993f983431c7a6f3f5e0ae
|
|
| BLAKE2b-256 |
6080ee0ad05ab66052bec22656a5101b1c53e21e259e013a3257c0e10e57d271
|
File details
Details for the file cached_binance_data-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cached_binance_data-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a131ed76e7b9d8919ab876e85fc1caa136c7809aa440e53950c23b7804913f7
|
|
| MD5 |
73d19f2cea2db416dc215aeb65df6c50
|
|
| BLAKE2b-256 |
1ced1de6d549b82298cf4640e8aa3bf4d69b9a85ff39eb0720db3181aaa8066a
|