slickbet.cache¶
File-based cache for Livescore API responses.
Enables fast backtesting and hyperparameter optimization by storing API responses locally and reusing them instead of hitting the API.
Examples
>>> # First run: fetch and cache (e.g. 12 weeks backtest)
>>> client = LivescoreClient(cache_dir="data/api_cache")
>>> # ... run backtest ...
>>> # Later runs: use cache only (no API calls)
>>> client = LivescoreClient(cache_dir="data/api_cache", cache_only=True)
Classes¶
File-based cache for API response bodies (JSON). |
Functions¶
|
Produce a short, filesystem-safe cache key from endpoint and params. |
Module Contents¶
- class slickbet.cache.ApiCache(cache_dir: str | pathlib.Path)[source]¶
File-based cache for API response bodies (JSON).
Each request is stored as a single JSON file keyed by endpoint + params.
- get(endpoint: str, params: dict[str, Any] | None) dict | None[source]¶
Load cached response if present.
- Parameters:
endpoint (str) – API endpoint path.
params (dict or None) – Request query parameters.
- Returns:
dict or None – Cached JSON body or None if miss.
- root¶