Stock Cache Utils for Openclaw

A specialized utility module providing market-aware data caching and trading status detection for stock market AI agents.

georgetao730
v1.0.0
Mar 21, 2026
0
976
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install shared

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install shared using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Stock Cache Utils?

Stock Cache Utils is a robust technical module designed to provide a unified caching mechanism for financial trading skills. It intelligently manages stock market data by distinguishing between active trading windows and after-market hours, ensuring that AI agents remain performant while minimizing unnecessary API calls. This utility is a core component for developers building sophisticated Openclaw Skills in the fintech space.

The skill specifically targets the A-share market, offering automated detection of trading periods and 24-hour expiration management. By implementing this utility, developers can ensure their agents use real-time data when the market is live and pivot to high-speed cached data during off-hours, providing a seamless and cost-effective data strategy.

Stock Cache Utils Use Cases

  • Reducing API latency in stock analysis agents by retrieving cached market snapshots during off-market hours.
  • Implementing market-aware logic where agents only trigger real-time trades during valid A-share trading windows.
  • Managing local data persistence for financial research agents to maintain a 24-hour lookback window.
  • Building resilient financial Openclaw Skills that gracefully degrade to cached data when live data sources are unavailable.

How Stock Cache Utils Works

  1. The utility initializes a local cache directory with a configurable Time-To-Live (TTL), defaulting to 24 hours.
  2. It executes a trading status check to determine if the current system time falls within the A-share trading window (9:30 - 15:30 on trading days).
  3. Based on the market status, the logic branches: it prioritizes fresh data during active trading or checks for valid local cache during off-hours.
  4. Data is serialized and saved to the local disk with metadata, allowing for easy retrieval and age validation.
  5. The system automatically calculates the next trading window to help the agent schedule future tasks.

Stock Cache Utils Setup

To integrate this utility into your Openclaw Skills environment, ensure you are running Python 3.10 or higher. Since it has no external dependencies, installation is straightforward:

# Navigate to your skill directory
cd your-skill-folder

# Import the module into your Python environment
# Ensure cache_utils.py is in your PYTHONPATH

Initialize the cache in your script:

from cache_utils import StockDataCache
cache = StockDataCache(cache_dir='./.cache', cache_max_age_hours=24)

Stock Cache Utils Data Schema & Taxonomy

The utility organizes data using a directory-based storage system. The metadata taxonomy includes the following trading status fields:

Field Type Description
current_time String The ISO timestamp of the check
is_trading_day Boolean True if today is a valid market workday
is_trading_time Boolean True if within 9:30-15:30 window
next_trading_time String The timestamp of the next market opening

Stock Cache Utils Advanced Features

  • Intelligent trading status detection specifically tuned for A-share market hours.
  • Automated cache expiration management with customizable TTL (hours).
  • Fallback mechanisms that allow agents to operate offline using the most recent valid cache.
  • Lightweight footprint with zero external library dependencies for maximum compatibility across different Openclaw Skills environments.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*