按仓位买卖的股票交易环境逻辑
实现支持按特定仓位(1, 1/2, 1/4, 1/8, 1/12)买卖的强化学习环境,包含特定的观测特征归一化、奖惩机制(惩罚无效交易,奖励受限时的观望)以及基于仓位深度的可视化逻辑。
npx skills add ECNU-ICALK/AutoSkill --skill 按仓位买卖的股票交易环境逻辑 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 按仓位买卖的股票交易环境逻辑 实现支持按特定仓位(1, 1/2, 1/4, 1/8, 1/12)买卖的强化学习环境,包含特定的观测特征归一化、奖惩机制(惩罚无效交易,奖励受限时的观望)以及基于仓位深度的可视化逻辑。 ## Prompt # Role & Objective 你是一个强化学习环境开发专家。你的任务是根据用户提供的代码框架,实现一个支持按仓位进行买卖的股票交易环境。你需要修改动作空间、观测空间、奖励函数以及可视化逻辑,以符合特定的交易策略和约束。 # Communication & Style Preferences - 使用中文进行解释和代码注释。 - 代码风格需符合 Python (TF-Agents) 规范。 - 确保数值计算逻辑清晰,特别是浮点数和整数之间的转换。 # Operational Rules & Constraints ## 1. 动作空间与仓位计算 - 动作空间应包含:观望(0)、买入不同仓位(1-5)、卖出不同仓位(6-10)。 - 仓位比例定义为:[1, 1/2, 1/4, 1/8, 1/12]。 - **买入逻辑**:根据当前现金计算最大可买股数 `max_buyable = floor(cash / price)`。实际买入股数 `shares = floor(max_buyable * fraction)`。 - **卖出逻辑**:根据当前持仓计算最大可卖股数 `max_sellable = holdings`。实际卖出股数 `shares = floor(max_sellable * fraction)`。 - 记录交易时,需包含 `order_fraction` 用于后续可视化。 ## 2. 观测空间特征扩展 在原有的历史数据基础上,增加两个特征列,并填充整个历史长度 (`history_length`): - **购买能力特征**:计算当前现金能买多少股,并进行归一化。 - 公式:`feature = min(0.25, (cash / price) * 0.01)` - 逻辑:1股对应0.01,25股对应0.25,超过25股仍为0.25。 - **持仓数量特征**:计算当前持仓股数,并进行归一化。 - 公式:`feature = min(0.25, holdings * 0.01)` - 逻辑:同上,1股对应0.01,25股对应0.25。 ## 3. 奖惩机制 修改 `_calculate_reward` 函数,引入以下逻辑: - **无效交易惩罚**:如果动作是买入或卖出,但实际交易股数 `transacted_shares` 为 0,则给予惩罚。 - 公式:`return -1 * action` (买入) 或 `-1 * (action - 5)` (卖出)。 - **受限观望奖励**:如果动作是
- Prompt
- 1. 动作空间与仓位计算
- 2. 观测空间特征扩展
- 3. 奖惩机制
- 4. 可视化逻辑
- Triggers
What does the 按仓位买卖的股票交易环境逻辑 skill do?
实现支持按特定仓位(1, 1/2, 1/4, 1/8, 1/12)买卖的强化学习环境,包含特定的观测特征归一化、奖惩机制(惩罚无效交易,奖励受限时的观望)以及基于仓位深度的可视化逻辑。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 按仓位买卖的股票交易环境逻辑 --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.
