Token导航 LogoToken导航

Agent Skill · 开发

scarface-mean-reversion(疤痕均值回归)

scarface-mean-reversion 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

scarface-mean-reversion 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描有未通过项,按安装量在开发类的 21,746 个 Skill 里排第 18,732。

总安装 318周安装 13GitHub Stars 6下载 102核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:scarface-mean-reversion(疤痕均值回归)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/scarface-mean-reversion
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill scarface-mean-reversion
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill scarface-mean-reversion

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于处理金融交易中的均值回归策略回测与分析。适合在量化研究或算法交易中识别价格反转信号。可结合历史数据生成交易场景模拟报告。scarface-mean-reversion 属于开发类 Skill,可作为该场景下的辅助能力补充。安装方式基于 GitHub,需确保 Python 环境支持依赖库。

策略表现受市场环境影响,需谨慎用于实盘交易。

来源仓库内路径:skills/scarface-mean-reversion

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/copyleftdev/sk1llz --skill scarface-mean-rever…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

scarface-mean-reversion 怎么安装?

在终端执行 npx skills add https://github.com/copyleftdev/sk1llz --skill scarface-mean-reversion。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

scarface-mean-reversion 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

scarface-mean-reversion 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

scarface-mean-reversion 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

scarface-mean-reversion 用的人多吗?

公开数据是累计安装 318 次,近一周安装 13 次,下载 102 次,GitHub 6 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

scarface-mean-reversion 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
scarface-mean-reversion

疤痕均值回归 · 本页

3186只读未明确未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Scarface Trades Mean Reversion Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍‌​‌‌​‌‌​‍​‌​‌‌‌​​‍‌‌‌​‌‌‌‌‍​‌​​​​​​‍​​​​‌​‌​‍‌​‌​‌​‌‌⁠‍⁠

Overview

Scarface Trades is a trader known for mastering mean reversion—the principle that prices tend to return to their average over time. When a stock deviates significantly from its mean, probability favors a snap-back. His approach is purely mathematical: standard deviations, RSI extremes, and statistical probabilities define every trade.

Core Philosophy

"Price always returns to the mean. The only question is when and how far it overshoots."
"Two standard deviations is where the math gets interesting. Three is where money is made."
"I don't predict direction. I bet on reversion to the mean with defined risk."

Mean reversion isn't about being right—it's about probability. When price extends 2-3 standard deviations from its mean, the statistical odds of reversion increase dramatically. Scarface trades these probabilities with strict math and risk management.

Design Principles

  1. Standard Deviation is King: Price at 2σ has ~95% historical reversion probability.
  2. RSI Confirms Extremes: Oversold (<30) or overbought (>70) adds confluence.
  3. Define Risk First: Know your stop before calculating position size.
  4. Scale In, Scale Out: Enter in thirds at 2σ, 2.5σ, 3σ; exit in thirds at mean.
  5. Time Frame Alignment: Higher timeframe mean = stronger magnet.

The Math

Standard Deviation Bands

Mean (μ) = SMA(price, period)
Standard Deviation (σ) = STDEV(price, period)

Upper Band 1σ = μ + (1 × σ)
Upper Band 2σ = μ + (2 × σ)
Upper Band 3σ = μ + (3 × σ)

Lower Band 1σ = μ - (1 × σ)
Lower Band 2σ = μ - (2 × σ)
Lower Band 3σ = μ - (3 × σ)

Statistical Probabilities (Normal Distribution):

  • Price within 1σ: 68.2% of the time
  • Price within 2σ: 95.4% of the time
  • Price within 3σ: 99.7% of the time

Reversion Edge:

  • At 2σ: ~95% chance price returns to within 1σ
  • At 3σ: ~99% chance price returns to within 2σ

RSI Calculation

RS = Average Gain (n periods) / Average Loss (n periods)
RSI = 100 - (100 / (1 + RS))

Oversold: RSI < 30
Overbought: RSI > 70
Extreme Oversold: RSI < 20
Extreme Overbought: RSI > 80

Position Sizing Formula

Risk Amount = Account × Risk Percentage (typically 1-2%)
Position Size = Risk Amount / (Entry Price - Stop Price)

Example:
  Account: $100,000
  Risk: 1% = $1,000
  Entry: $50.00
  Stop: $52.00 (2σ + buffer)

  Position Size = $1,000 / $2.00 = 500 shares

When Trading Mean Reversion

Always

  • Calculate standard deviation bands before entering
  • Confirm with RSI or other momentum oscillator
  • Set stops beyond the extreme (3σ + ATR buffer)
  • Scale into positions at multiple deviation levels
  • Take partial profits at the mean
  • Use limit orders, not market orders

Never

  • Fight a trend without deviation from mean
  • Enter at 1σ (not enough edge)
  • Hold through earnings or major catalysts
  • Average down without predefined levels
  • Ignore volume (climactic volume = exhaustion)
  • Risk more than 2% per trade

Prefer

  • Stocks with history of mean-reverting behavior
  • High RSI divergence with price
  • End-of-day setups (overnight reversion)
  • Liquid names with tight spreads
  • Multiple timeframe confluence
  • Scaling in/out over single entry/exit

Code Patterns

Mean Reversion Scanner

class MeanReversionScanner:
    """
    Scarface-style mean reversion setup identification.
    Pure math: standard deviations and RSI extremes.
    """

    def __init__(self, lookback_period: int = 20):
        self.period = lookback_period

    def calculate_bands(self, prices: pd.Series) -> dict:
        """
        Calculate mean and standard deviation bands.
        """
        mean = prices.rolling(self.period).mean()
        std = prices.rolling(self.period).std()

        return {
            'mean': mean,
            'std': std,
            'upper_1sd': mean + std,
            'upper_2sd': mean + (2 * std),
            'upper_3sd': mean + (3 * std),
            'lower_1sd': mean - std,
            'lower_2sd': mean - (2 * std),
            'lower_3sd': mean - (3 * std),
        }

    def calculate_z_score(self, price: float, mean: float, std: float) -> float:
        """
        How many standard deviations from the mean?
        """
        return (price - mean) / std

    def calculate_rsi(self, prices: pd.Series, period: int = 14) -> pd.Series:
        """
        Relative Strength Index calculation.
        """
        delta = prices.diff()
        gain = (delta.where(delta > 0, 0)).rolling(window=period).mean()
        loss = (-delta.where(delta < 0, 0)).rolling(window=period).mean()

        rs = gain / loss
        rsi = 100 - (100 / (1 + rs))
        return rsi

    def scan_for_setups(self,
                        symbols: List[str],
                        data: Dict[str, pd.DataFrame]) -> List[Setup]:
        """
        Scan universe for mean reversion setups.
        """
        setups = []

        for symbol in symbols:
            df = data[symbol]
            prices = df['close']

            bands = self.calculate_bands(prices)
            rsi = self.calculate_rsi(prices)

            current_price = prices.iloc[-1]
            current_mean = bands['mean'].iloc[-1]
            current_std = bands['std'].iloc[-1]
            current_rsi = rsi.iloc[-1]

            z_score = self.calculate_z_score(current_price, current_mean, current_std)

            # Long setup: price at -2σ or below with RSI < 30
            if z_score <= -2 and current_rsi < 30:
                setups.append(Setup(
                    symbol=symbol,
                    direction='LONG',
                    z_score=z_score,
                    rsi=current_rsi,
                    entry_price=current_price,
                    mean_target=current_mean,
                    stop_price=bands['lower_3sd'].iloc[-1] - self.atr_buffer(df),
                    edge_probability=self.get_reversion_probability(z_score)
                ))

            # Short setup: price at +2σ or above with RSI > 70
            elif z_score >= 2 and current_rsi > 70:
                setups.append(Setup(
                    symbol=symbol,
                    direction='SHORT',
                    z_score=z_score,
                    rsi=current_rsi,
                    entry_price=current_price,
                    mean_target=current_mean,
                    stop_price=bands['upper_3sd'].iloc[-1] + self.atr_buffer(df),
                    edge_probability=self.get_reversion_probability(z_score)
                ))

        return sorted(setups, key=lambda x: abs(x.z_score), reverse=True)

    def get_reversion_probability(self, z_score: float) -> float:
        """
        Statistical probability of reversion based on z-score.
        """
        from scipy import stats
        # Probability of returning to within 1σ
        return stats.norm.cdf(1) - stats.norm.cdf(z_score) if z_score < 0 else \
               stats.norm.cdf(z_score) - stats.norm.cdf(1)

    def atr_buffer(self, df: pd.DataFrame, period: int = 14) -> float:
        """
        ATR-based buffer for stop placement.
        """
        high = df['high']
        low = df['low']
        close = df['close']

        tr = pd.concat([
            high - low,
            abs(high - close.shift(1)),
            abs(low - close.shift(1))
        ], axis=1).max(axis=1)

        return tr.rolling(period).mean().iloc[-1]

Position Manager with Scaling

class MeanReversionPositionManager:
    """
    Manage scaled entries and exits for mean reversion trades.
    """

    def __init__(self,
                 account_size: float,
                 risk_per_trade: float = 0.01):  # 1%
        self.account = account_size
        self.risk_pct = risk_per_trade

    def calculate_scaled_entries(self, setup: Setup) -> List[Entry]:
        """
        Scale into position at 2σ, 2.5σ, 3σ levels.
        Scarface method: thirds at each level.
        """
        direction = 1 if setup.direction == 'LONG' else -1
        mean = setup.mean_target
        std = (setup.entry_price - mean) / setup.z_score * direction

        total_risk = self.account * self.risk_pct
        risk_per_level = total_risk / 3

        entries = []

        levels = [
            ('2.0σ', 2.0, 0.33),
            ('2.5σ', 2.5, 0.33),
            ('3.0σ', 3.0, 0.34),
        ]

        for label, sigma, allocation in levels:
            entry_price = mean + (direction * -1 * sigma * std)
            stop_distance = abs(setup.stop_price - entry_price)

            shares = int((risk_per_level * allocation * 3) / stop_distance)

            entries.append(Entry(
                level=label,
                price=entry_price,
                shares=shares,
                allocation_pct=allocation
            ))

        return entries

    def calculate_scaled_exits(self,
                                setup: Setup,
                                avg_entry: float,
                                total_shares: int) -> List[Exit]:
        """
        Scale out at mean, -1σ (for longs), and breakeven.
        """
        direction = 1 if setup.direction == 'LONG' else -1
        mean = setup.mean_target
        std = abs(setup.entry_price - mean) / abs(setup.z_score)

        exits = [
            Exit(
                level='Mean (μ)',
                price=mean,
                shares=int(total_shares * 0.50),
                reason='Primary target: reversion to mean'
            ),
            Exit(
                level='1σ toward entry',
                price=mean + (direction * -0.5 * std),
                shares=int(total_shares * 0.25),
                reason='Partial: halfway to mean'
            ),
            Exit(
                level='Runner',
                price=mean + (direction * std),  # 1σ past mean
                shares=int(total_shares * 0.25),
                reason='Runner: extended reversion'
            ),
        ]

        return exits

    def calculate_risk_reward(self, setup: Setup, entries: List[Entry]) -> dict:
        """
        Calculate overall risk/reward for scaled position.
        """
        total_shares = sum(e.shares for e in entries)
        avg_entry = sum(e.price * e.shares for e in entries) / total_shares

        risk = abs(avg_entry - setup.stop_price) * total_shares
        reward = abs(setup.mean_target - avg_entry) * total_shares

        return {
            'avg_entry': avg_entry,
            'total_shares': total_shares,
            'total_risk_dollars': risk,
            'target_reward_dollars': reward,
            'risk_reward_ratio': reward / risk,
            'required_win_rate': 1 / (1 + reward/risk)
        }

Backtesting Mean Reversion

class MeanReversionBacktest:
    """
    Backtest mean reversion strategy with realistic assumptions.
    """

    def __init__(self,
                 entry_z_threshold: float = 2.0,
                 exit_z_threshold: float = 0.0,  # Mean
                 stop_z_threshold: float = 3.5,
                 lookback: int = 20):
        self.entry_z = entry_z_threshold
        self.exit_z = exit_z_threshold
        self.stop_z = stop_z_threshold
        self.lookback = lookback

    def run_backtest(self,
                     prices: pd.Series,
                     start_date: str,
                     end_date: str) -> BacktestResult:
        """
        Run backtest on historical data.
        """
        prices = prices.loc[start_date:end_date]

        mean = prices.rolling(self.lookback).mean()
        std = prices.rolling(self.lookback).std()
        z_score = (prices - mean) / std

        trades = []
        position = None

        for i in range(self.lookback, len(prices)):
            current_z = z_score.iloc[i]
            current_price = prices.iloc[i]

            if position is None:
                # Check for entry
                if current_z <= -self.entry_z:
                    position = Trade(
                        direction='LONG',
                        entry_price=current_price,
                        entry_date=prices.index[i],
                        entry_z=current_z,
                        stop_price=mean.iloc[i] - (self.stop_z * std.iloc[i])
                    )
                elif current_z >= self.entry_z:
                    position = Trade(
                        direction='SHORT',
                        entry_price=current_price,
                        entry_date=prices.index[i],
                        entry_z=current_z,
                        stop_price=mean.iloc[i] + (self.stop_z * std.iloc[i])
                    )
            else:
                # Check for exit
                exit_signal = False
                exit_reason = None

                if position.direction == 'LONG':
                    if current_z >= self.exit_z:
                        exit_signal = True
                        exit_reason = 'TARGET'
                    elif current_price <= position.stop_price:
                        exit_signal = True
                        exit_reason = 'STOP'
                else:  # SHORT
                    if current_z <= self.exit_z:
                        exit_signal = True
                        exit_reason = 'TARGET'
                    elif current_price >= position.stop_price:
                        exit_signal = True
                        exit_reason = 'STOP'

                if exit_signal:
                    position.exit_price = current_price
                    position.exit_date = prices.index[i]
                    position.exit_reason = exit_reason
                    position.pnl_pct = self.calculate_pnl(position)
                    trades.append(position)
                    position = None

        return self.analyze_trades(trades)

    def calculate_pnl(self, trade: Trade) -> float:
        """Calculate percentage P&L for a trade."""
        if trade.direction == 'LONG':
            return (trade.exit_price - trade.entry_price) / trade.entry_price
        else:
            return (trade.entry_price - trade.exit_price) / trade.entry_price

    def analyze_trades(self, trades: List[Trade]) -> BacktestResult:
        """Compute strategy statistics."""
        if not trades:
            return BacktestResult(total_trades=0)

        pnls = [t.pnl_pct for t in trades]
        winners = [t for t in trades if t.pnl_pct > 0]
        losers = [t for t in trades if t.pnl_pct <= 0]

        return BacktestResult(
            total_trades=len(trades),
            win_rate=len(winners) / len(trades),
            avg_win=np.mean([t.pnl_pct for t in winners]) if winners else 0,
            avg_loss=np.mean([t.pnl_pct for t in losers]) if losers else 0,
            profit_factor=abs(sum(t.pnl_pct for t in winners) /
                            sum(t.pnl_pct for t in losers)) if losers else float('inf'),
            total_return=np.prod([1 + p for p in pnls]) - 1,
            max_drawdown=self.calculate_max_drawdown(pnls),
            sharpe_ratio=np.mean(pnls) / np.std(pnls) * np.sqrt(252) if np.std(pnls) > 0 else 0,
            avg_holding_period=np.mean([(t.exit_date - t.entry_date).days for t in trades])
        )

Mental Model

Scarface approaches mean reversion by asking:

  1. How extended is it? Z-score tells you standard deviations from mean
  2. Is momentum confirming? RSI extremes add confluence
  3. What's my risk? Stop at 3σ + ATR buffer
  4. What's the probability? >2σ has 95%+ reversion probability
  5. How do I scale? Enter in thirds, exit in thirds

The Setup Checklist

□ Price at 2σ or beyond from 20-period mean
□ RSI < 30 (long) or RSI > 70 (short)
□ No earnings within 5 days
□ Sufficient liquidity (>1M avg volume)
□ Stop calculated (3σ + 1 ATR buffer)
□ Position sized to 1% account risk
□ Scaling levels defined (2σ, 2.5σ, 3σ)
□ Exit targets defined (mean, runner)

Signature Scarface Moves

  • Standard deviation bands (2σ, 3σ entries)
  • RSI confirmation at extremes
  • Scaling in at multiple sigma levels
  • Taking profits at the mean
  • ATR-based stop buffers
  • Mathematical position sizing
  • Z-score quantification of setups
  • Probability-based edge calculation

平台分布

Codex

36.33%
按下载量换算37

Claude

30.46%
按下载量换算31

Cursor

16.32%
按下载量换算17

Gemini CLI

9.1%
按下载量换算9

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills