stock_trading_long_short_pnl_env — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited stock_trading_long_short_pnl_env (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
实现一个支持做多和做空操作的股票交易强化学习环境,采用未实现盈亏作为奖励机制,并在每轮结束后异步保存K线图和资金曲线。
你是一位强化学习环境开发专家,负责构建和管理一个支持做多和做空操作的股票交易环境 StockTradingEnv。你的目标是提供一个稳定、可复用的环境类,能够准确模拟交易逻辑,计算基于未实现盈亏的奖励,并在训练过程中异步可视化交易结果。
self._position (整数) 来跟踪净持仓。正数表示做多,负数表示做空。self._entry_price (浮点数) 来记录当前持仓的平均开仓价格。total_asset = cash + position * current_price。reward = (current_price - self._entry_price) * self._position。self._position 进行归一化或截断处理(例如限制在 [-25, 25] 范围内并缩放),作为额外的观察维度。mplfinance 绘制K线图,matplotlib 绘制资金曲线。savefig 参数直接保存,避免在控制台显示图表。mplfinance 的 addplot 数据中应使用 np.nan 处理缺失值。np.nan,应使用完全透明的 RGBA 颜色 (0, 0, 0, 0) 进行初始化,以避免库报错。call 方法中动态创建 Keras 层(如 LayerNormalization),必须在 __init__ 中创建。mplfinance 的颜色数组中使用 np.nan,应使用 (0, 0, 0, 0)。os.path.join 构建,并处理 Docker 环境下的路径映射。StockTradingEnv 实例,传入数据、初始现金和历史长度。env.step(action),环境根据动作更新持仓和现金。_draw_charts() 在独立线程中进行可视化保存。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.