Official Python client library for Quantdle
Project description
Quantdle Python Client
A user-friendly Python client for downloading financial market data from Quantdle. This client simplifies the process of accessing historical market data by handling all the complexity of data downloading, extraction and processing.
Features
- Simple Data Access: Download historical market data with just a few lines of code
- High Performance: Parallel downloads for faster data retrieval
- Multiple Formats: Support for both pandas and polars DataFrames
- Smart Chunking: Automatically handles large date ranges to avoid timeouts
- Robust Error Handling: Graceful handling of network issues and data errors
- Zero Configuration: Works out of the box with minimal setup
Installation
Install the package using pip:
pip install quantdle
For polars support, install with the optional dependency:
pip install quantdle[polars]
Quick Start
import quantdle as qdl
# Initialize the client with your API credentials
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Download data for EURUSD
df = client.download_data(
symbol="EURUSD",
timeframe="H1",
start_date="2023-01-01",
end_date="2023-12-31"
)
print(df.head())
Usage Examples
Different Symbols and Timeframes
import quantdle as qdl
# Initialize client once
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Download different symbols and timeframes
xau_data = client.download_data("XAUUSD", "D1", "2023-01-01", "2023-12-31")
eur_data = client.download_data("EURUSD", "H1", "2023-01-01", "2023-01-31")
Using Polars DataFrames
import quantdle as qdl
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Get data as a polars DataFrame
df = client.download_data(
symbol="XAUUSD",
timeframe="D1",
start_date="2023-01-01",
end_date="2023-12-31",
output_format="polars"
)
Listing Available Symbols
import quantdle as qdl
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Get all available symbols for your account
symbols = client.get_available_symbols()
print(f"Available symbols: {symbols}")
# Get information about a specific symbol
info = client.get_symbol_info("EURUSD")
print(f"EURUSD available from {info['available_from']} to {info['available_to']}")
Downloading Large Date Ranges
The client automatically handles large date ranges by splitting them into smaller chunks:
import quantdle as qdl
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Download 10 years of data - will be automatically chunked
df = client.download_data(
symbol="EURUSD",
timeframe="H1",
start_date="2014-01-01",
end_date="2023-12-31",
chunk_size_years=5 # Download in 5-year chunks
)
Advanced Options
import quantdle as qdl
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
# Customize download behavior
df = client.download_data(
symbol="EURUSD",
timeframe="M5",
start_date="2023-01-01",
end_date="2023-12-31",
max_workers=8, # Increase parallel downloads
show_progress=True, # Show progress bars
chunk_size_years=3 # Smaller chunks for more frequent updates
)
Available Timeframes
M1- 1 minuteM5- 5 minutesM15- 15 minutesM30- 30 minutesH1- 1 hourH4- 4 hoursD1- 1 day
DataFrame Structure
The returned DataFrame contains the following columns:
| Column | Type | Description |
|---|---|---|
| timestamp | datetime | Candle timestamp |
| open | float | Opening price |
| high | float | Highest price |
| low | float | Lowest price |
| close | float | Closing price |
| volume | int | Trading volume |
| spread | int | Average spread of the bar |
| spreadmax | int | Maximum spread of the bar |
| spread_open | int | Opening spread of the bar |
Error Handling
The client includes robust error handling:
import quantdle as qdl
client = qdl.Client(
api_key="your-api-key",
api_key_id="your-api-key-id"
)
try:
df = client.download_data(
symbol="INVALID",
timeframe="H1",
start_date="2023-01-01",
end_date="2023-12-31"
)
except Exception as e:
print(f"Error downloading data: {e}")
Performance Tips
- Use parallel downloads: The
max_workersparameter controls the number of parallel downloads - Choose appropriate chunk sizes: Larger chunks mean fewer API calls but longer wait times
- Cache downloaded data: Save DataFrames locally to avoid re-downloading
- Use polars for large datasets: Polars DataFrames are more memory-efficient for large datasets
API Rate Limits
Please be aware of Quantdle's API rate limits. The client automatically handles chunking to avoid timeouts, but you should still be mindful of making too many requests in a short period.
Development & Testing
Running Tests
The project has comprehensive test coverage with unit tests, integration tests, and end-to-end tests.
# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run tests with coverage
pytest --cov=quantdle
# Run only unit tests (fast)
pytest -m unit
# Run only integration tests (may be slow)
pytest -m integration
# Run tests in parallel for speed
pytest -n auto
Code Quality
We maintain high code quality standards:
# Format code with black
black quantdle tests
# Lint with flake8
flake8 quantdle
# Type checking with mypy
mypy quantdle
Test Coverage
Our comprehensive test suite includes:
- Unit Tests: Fast, isolated tests for individual functions and classes
- Integration Tests: Tests that verify modules work together correctly
- Mock Testing: Extensive use of mocks to test API interactions without real API calls
- Performance Tests: Tests for large dataset handling and memory efficiency
- Error Handling Tests: Comprehensive error condition testing
Current test coverage is maintained above 85% with detailed reporting available in CI/CD.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Run the test suite (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Requirements
- Python 3.9 or higher
- pandas >= 1.3.0
- requests >= 2.25.0
- tqdm >= 4.60.0
- polars >= 0.16.0 (optional)
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues with the client, please open an issue on GitHub.
For questions about Quantdle's data or API access, please contact Quantdle support.
Project details
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 quantdle-1.0.4.tar.gz.
File metadata
- Download URL: quantdle-1.0.4.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a47efb7a1bed4590542af0e9ec74b66ee9e92fb3a38fd9a51c93c6b2cf2314c9
|
|
| MD5 |
6dbcaa924a7d5c2293990592cf0cfa93
|
|
| BLAKE2b-256 |
cc0fe7fd60e13abc843c89bb18f0f0a81539f94caaabbed210d9181159370bce
|
File details
Details for the file quantdle-1.0.4-py3-none-any.whl.
File metadata
- Download URL: quantdle-1.0.4-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01b7f4a49b2a8f939dc05163de48b34d62d8d7d899b3ea9c1533886fb3fcaeac
|
|
| MD5 |
b2b70c904684557d80091702f50d28c5
|
|
| BLAKE2b-256 |
41bc39407eab1a20c3d1adf0eb2d9d66f9e32f554370ccc25836e2e1d4584bf7
|