Configuration Reference¶
Global configuration options for qldata.
Configuration Methods¶
qd.config()¶
Set global configuration options.
import qldata as qd
qd.config(
data_dir="./market_data",
cache_enabled=True,
validation_enabled=True
)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
data_dir | str | ~/.qldata | Directory for cached data |
cache_enabled | bool | True | Enable disk caching |
validation_enabled | bool | True | Validate data on fetch |
qd.get_config()¶
Get the current configuration.
import qldata as qd
config = qd.get_config()
print(config)
# {'data_dir': '~/.qldata', 'cache_enabled': True, ...}
Utility Functions¶
import qldata as qd
# Get current data directory
data_dir = qd.get_data_dir()
print(f"Data directory: {data_dir}")
# Check if caching is enabled
if qd.is_cache_enabled():
print("Caching is ON")
# Check if validation is enabled
if qd.is_validation_enabled():
print("Validation is ON")
Environment Variables¶
qldata reads these environment variables at startup:
| Variable | Type | Default | Description |
|---|---|---|---|
QLDATA_DATA_DIR | str | ~/.qldata | Data directory path |
QLDATA_CACHE_ENABLED | bool | true | Enable caching |
QLDATA_VALIDATION_ENABLED | bool | true | Enable validation |
Exchange API Keys¶
For private endpoints (not required for market data):
| Variable | Description |
|---|---|
BINANCE_API_KEY | Binance API key |
BINANCE_API_SECRET | Binance API secret |
BYBIT_API_KEY | Bybit API key |
BYBIT_API_SECRET | Bybit API secret |
API Keys Not Required for Public Data
API keys are only needed for private endpoints (account, orders). Market data is fully public.
Configuration Files¶
YAML Configuration¶
Create qldata.yaml in your project root:
# qldata.yaml
data_dir: ./data
cache_enabled: true
validation_enabled: true
exchanges:
binance:
testnet: false
bybit:
testnet: false
TOML Configuration¶
Or use qldata.toml:
# qldata.toml
data_dir = "./data"
cache_enabled = true
validation_enabled = true
[exchanges.binance]
testnet = false
[exchanges.bybit]
testnet = false
Per-Query Overrides¶
Override global config for specific queries:
import qldata as qd
# Global config
qd.config(cache_enabled=True)
# Override for this query
df = qd.data("BTCUSDT", source="binance") \
.last(30) \
.resolution("1h") \
.get(cache=False) # Skip cache for this query
Data Directory Structure¶
The data directory is organized as:
~/.qldata/
├── cache/
│ ├── binance/
│ │ ├── spot/
│ │ │ └── BTCUSDT_1h_2024-11.parquet
│ │ └── usdm/
│ │ └── BTCUSDT_1h_2024-11.parquet
│ └── bybit/
│ └── linear/
│ └── BTCUSDT_1h_2024-11.parquet
├── logs/
│ └── qldata.log
└── config/
└── qldata.yaml
Logging¶
Configure logging for debugging:
import logging
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Or for specific module
logging.getLogger("qldata").setLevel(logging.DEBUG)
# Quiet mode (errors only)
logging.getLogger("qldata").setLevel(logging.ERROR)
Best Practices¶
Development¶
import qldata as qd
qd.config(
data_dir="./dev_data",
cache_enabled=True, # Cache for faster iteration
validation_enabled=True # Catch issues early
)
Production¶
import qldata as qd
qd.config(
data_dir="/var/lib/qldata",
cache_enabled=True,
validation_enabled=True
)
Testing¶
import qldata as qd
import tempfile
qd.config(
data_dir=tempfile.mkdtemp(),
cache_enabled=False, # Fresh data each time
validation_enabled=True
)
See Also¶
- Installation - Setup and verification
- Error Handling - Error configuration