Trading Log System for Openclaw

An automated stock trading log and portfolio management system for A-shares and Hong Kong markets.

wtjjacobj
v1.0.0
Mar 31, 2026
0
629
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install trading-log

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 trading-log 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 Trading Log System?

The Trading Log System is a sophisticated utility designed to record every transaction in A-shares and Hong Kong markets, providing users with a streamlined way to manage their financial portfolios. By leveraging Openclaw Skills, this tool automates the tedious aspects of trading, such as calculating weighted average costs and tracking realized versus floating profits. It serves as a personal financial ledger that bridge the gap between manual record-keeping and professional trading platforms.

This skill is particularly powerful for developers and traders who want to maintain a permanent, queryable history of their market activities. With integrated real-time price fetching through reliable APIs, it ensures that your portfolio valuation is always current, allowing for informed decision-making based on the latest market data available within the Openclaw Skills ecosystem.

Trading Log System Use Cases

  • Recording daily stock purchases or sales with specific trade rationales.
  • Monitoring real-time floating profit and loss for active positions.
  • Generating historical trade logs to review past performance and strategies.
  • Calculating weighted average costs for positions built through multiple entry points.
  • Automating end-of-day portfolio snapshots for long-term tracking.

How Trading Log System Works

  1. The user provides a trade command such as Buy or Sell to the AI agent.
  2. The system identifies the stock code and automatically assigns the correct market prefix for Shanghai, Shenzhen, Beijing, or Hong Kong exchanges.
  3. The trading_log.py script fetches real-time market data to calculate the current transaction value.
  4. The system updates the JSON master file, recalculating the weighted average cost for holdings and updating the realized profit/loss for sales.
  5. A formatted summary or log entry is returned to the user, confirming the updated portfolio status.

Trading Log System Setup

To get started with this component of Openclaw Skills, ensure you have Python 3 installed. Place the core script and data files in a consistent directory.

# Navigate to your working directory
cd ~/Desktop

# Run a command (e.g., check current positions)
python3 交易日志.py 持仓

Ensure that scripts/trading_log.py and the initial JSON data file are present in the same path for proper data persistence.

Trading Log System Data Schema & Taxonomy

The skill organizes all transaction and portfolio data within a JSON structure for maximum portability and readability.

Attribute Description
Timestamp Precise time of the transaction (to the second)
Security Code 6-digit standardized stock or fund code
Transaction Details Price, quantity, and total amount
Direction Identification of Buy, Sell, or Full Liquidation
Meta Information Stock name, trade reason, and optional account tags
P&L Logic Automated calculation of floating vs. realized gains

Trading Log System Advanced Features

  • Real-time live tracking using the Tencent finance API for up-to-the-minute portfolio valuation.
  • Automated Cron job integration that triggers at 15:30 on trading days for daily profit/loss archiving.
  • Intelligent market prefixing that automatically distinguishes between SH, SZ, BJ, and HK listings.
  • Permanent transaction history that prevents data loss and supports long-term audit trails within Openclaw Skills.
  • Support for complex transactions including partial sales and multi-stage position building.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*