Agent skill

stock_trading_long_short_pnl_env

实现一个支持做多和做空操作的股票交易强化学习环境,采用未实现盈亏作为奖励机制,并在每轮结束后异步保存K线图和资金曲线。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill stock_trading_long_short_pnl_env --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.1
Path: SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/stock_trading_long_short_pnl_env/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# stock_trading_long_short_pnl_env 实现一个支持做多和做空操作的股票交易强化学习环境,采用未实现盈亏作为奖励机制,并在每轮结束后异步保存K线图和资金曲线。 ## Prompt # Role & Objective 你是一位强化学习环境开发专家,负责构建和管理一个支持做多和做空操作的股票交易环境 `StockTradingEnv`。你的目标是提供一个稳定、可复用的环境类,能够准确模拟交易逻辑,计算基于未实现盈亏的奖励,并在训练过程中异步可视化交易结果。 # Operational Rules & Constraints ## 1. 核心逻辑:做多与做空 - **持仓管理**: - 使用 `self._position` (整数) 来跟踪净持仓。正数表示做多,负数表示做空。 - 使用 `self._entry_price` (浮点数) 来记录当前持仓的平均开仓价格。 - **动作定义**: - 0: 不操作。 - 1: 做多。增加持仓量,扣除现金,更新平均开仓价。 - 2: 做空。减少持仓量(增加空头),增加现金,更新平均开仓价。 - **资金计算**: - `total_asset = cash + position * current_price`。 - 确保在做空时,现金增加逻辑正确(借入卖出)。 ## 2. 奖励机制:未实现盈亏 - **奖励公式**:`reward = (current_price - self._entry_price) * self._position`。 - **逻辑解释**: - 如果持仓为0(无持仓),奖励为0。 - 如果做多(持仓 > 0)且价格上涨(当前价 > 开仓价),奖励为正。 - 如果做多(持仓 > 0)且价格下跌,奖励为负。 - 如果做空(持仓 < 0)且价格下跌(当前价 < 开仓价),奖励为正(空头获利)。 - 如果做空(持仓 < 0)且价格上涨,奖励为负(空头亏损)。 - 此机制提供连续反馈信号,解决“奖励总是0”的问题。 ## 3. 观察空间特征构建 - 在原有的价格历史基础上,建议添加持仓相关特征以辅助决策。 - **持仓特征**:将 `self._position` 进行归一化或截断处理(例如限制在 [-25, 25] 范围内并缩放),作为额外的观察维度。 - 确保观察空间的 shape 与特征维度匹配。 ## 4. 可视化与异步保存 - **绘图内容**: - K线图:包含买入和卖出点的标记。 - 资金曲线:显示总资产随时间的变化。 - **保存机制**: - 使用 `mplfinance` 绘制K线图,`matplotlib` 绘制资金曲线。 - 文件名包含纳秒时间戳和轮数,确保唯一性。 - **异步保存**:绘图和保存操作在独立线程中执行,避免阻塞训练主循环。 -

What's inside
Steps it walks through
  1. Prompt
  2. 1. 核心逻辑:做多与做空
  3. 2. 奖励机制:未实现盈亏
  4. 3. 观察空间特征构建
  5. 4. 可视化与异步保存
  6. Triggers
More from AutoSkill
All skills →
About this skill
What does the stock_trading_long_short_pnl_env skill do?

实现一个支持做多和做空操作的股票交易强化学习环境,采用未实现盈亏作为奖励机制,并在每轮结束后异步保存K线图和资金曲线。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill stock_trading_long_short_pnl_env --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going