
Stock Trade Journal
- 703 installs
- 61 repo stars
- Updated March 16, 2026
- kirkluokun/awesome-a-stock-openclawskills
Helps with ai & agent building tasks.
About
stock-trade-journal is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- stock-trade-journal
- AI & Agent Building
- AI-coding skill
Stock Trade Journal by the numbers
- 703 all-time installs (skills.sh)
- +15 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #1,418 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/kirkluokun/awesome-a-stock-openclawskills --skill stock-trade-journalAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 703 |
|---|---|
| repo stars | ★ 61 |
| Last updated | March 16, 2026 |
| Repository | kirkluokun/awesome-a-stock-openclawskills ↗ |
What it does
Helps with ai & agent building tasks.
Files
stock-trade-journal
固定存储位置
results/trade-journal/records/<TS_CODE>.mdresults/trade-journal/db/trades.db
执行规则
1. 每次交易动作都记录(买/卖/加/减)。 2. 同时写 Markdown + SQLite(双写)。 3. Markdown 按个股持续追加,数据库用于后续统计计算。
命令模板
python3 scripts/record_trade.py \
--workspace ~/.openclaw/workspace \
--ts-code 603067.SH --side SELL --price 44.1 --quantity 2900 \
--position-before 36900 --position-after 34000 \
--reason "压力位先锁利润" --stop-loss 37.2 --take-profit "45.5分批"stock-trade-journal
交易记录技能包(最小可用版):
- 按个股写入 Markdown
- 同步写入 SQLite(trades.db)
目录
scripts/record_trade.py:记录单笔交易(自动建表/建文件)scripts/query_trades.py:查询交易记录templates/trade-entry.md:Markdown 模板
示例
python3 scripts/record_trade.py \
--workspace ~/.openclaw/workspace \
--ts-code 603067.SH --side SELL --price 44.1 --quantity 2900 \
--position-before 36900 --position-after 34000 \
--reason "压力位先锁利润"
python3 scripts/query_trades.py \
--workspace ~/.openclaw/workspace \
--ts-code 603067.SH --limit 20#!/usr/bin/env python3
import argparse, os, sqlite3
p = argparse.ArgumentParser()
p.add_argument("--workspace", required=True)
p.add_argument("--ts-code", required=True)
p.add_argument("--limit", type=int, default=20)
args = p.parse_args()
db = os.path.join(args.workspace, "results", "trade-journal", "db", "trades.db")
conn = sqlite3.connect(db)
rows = conn.execute(
"SELECT timestamp, ts_code, side, price, quantity, position_after, reason FROM trades WHERE ts_code=? ORDER BY id DESC LIMIT ?",
(args.ts_code, args.limit)
).fetchall()
conn.close()
for r in rows:
print(" | ".join(map(str, r)))
#!/usr/bin/env python3
import argparse, os, sqlite3
from datetime import datetime
def ensure_db(db_path: str):
os.makedirs(os.path.dirname(db_path), exist_ok=True)
conn = sqlite3.connect(db_path)
conn.execute(
"""
CREATE TABLE IF NOT EXISTS trades (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ts_code TEXT NOT NULL,
side TEXT NOT NULL,
price REAL NOT NULL,
quantity INTEGER NOT NULL,
position_before INTEGER,
position_after INTEGER,
reason TEXT,
stop_loss REAL,
take_profit TEXT,
note TEXT,
timestamp TEXT NOT NULL
)
"""
)
conn.commit()
return conn
def append_md(md_path: str, row: dict):
os.makedirs(os.path.dirname(md_path), exist_ok=True)
if not os.path.exists(md_path):
with open(md_path, "w", encoding="utf-8") as f:
f.write(f"# {row['ts_code']} 交易记录\n\n")
with open(md_path, "a", encoding="utf-8") as f:
f.write(
f"## {row['timestamp']} | {row['side']} | {row['ts_code']}\n"
f"- 价格:{row['price']}\n"
f"- 数量:{row['quantity']}\n"
f"- 交易后持仓:{row.get('position_after','')}\n"
f"- 仓位变化:{row.get('position_before','')} -> {row.get('position_after','')}\n"
f"- 触发原因:{row.get('reason','')}\n"
f"- 止损:{row.get('stop_loss','')}\n"
f"- 止盈:{row.get('take_profit','')}\n"
f"- 备注:{row.get('note','')}\n\n"
)
def main():
p = argparse.ArgumentParser()
p.add_argument("--workspace", required=True)
p.add_argument("--ts-code", required=True)
p.add_argument("--side", required=True)
p.add_argument("--price", type=float, required=True)
p.add_argument("--quantity", type=int, required=True)
p.add_argument("--position-before", type=int)
p.add_argument("--position-after", type=int)
p.add_argument("--reason", default="")
p.add_argument("--stop-loss", type=float)
p.add_argument("--take-profit", default="")
p.add_argument("--note", default="")
p.add_argument("--timestamp", default=datetime.now().astimezone().isoformat(timespec="seconds"))
args = p.parse_args()
base = os.path.join(args.workspace, "results", "trade-journal")
db_path = os.path.join(base, "db", "trades.db")
md_path = os.path.join(base, "records", f"{args.ts_code}.md")
row = {
"ts_code": args.ts_code,
"side": args.side.upper(),
"price": args.price,
"quantity": args.quantity,
"position_before": args.position_before,
"position_after": args.position_after,
"reason": args.reason,
"stop_loss": args.stop_loss,
"take_profit": args.take_profit,
"note": args.note,
"timestamp": args.timestamp,
}
conn = ensure_db(db_path)
conn.execute(
"""
INSERT INTO trades(ts_code, side, price, quantity, position_before, position_after, reason, stop_loss, take_profit, note, timestamp)
VALUES(?,?,?,?,?,?,?,?,?,?,?)
""",
(
row["ts_code"], row["side"], row["price"], row["quantity"], row["position_before"], row["position_after"],
row["reason"], row["stop_loss"], row["take_profit"], row["note"], row["timestamp"]
),
)
conn.commit(); conn.close()
append_md(md_path, row)
print(f"Recorded trade: {row['ts_code']} {row['side']} {row['quantity']} @ {row['price']}")
if __name__ == "__main__":
main()
{{timestamp}} | {{side}} | {{ts_code}}
- 价格:{{price}}
- 数量:{{quantity}}
- 交易后持仓:{{position_after}}
- 仓位变化:{{position_before}} -> {{position_after}}
- 触发原因:{{reason}}
- 止损:{{stop_loss}}
- 止盈:{{take_profit}}
- 备注:{{note}}
Related skills
AI & Agent Buildingagents