P paper2skillsPlaybook
开始业务诊断
访客模式
17-价格优化

Real-Time Competitive Repricing — 竞品价格监测与深度强化学习自动重定价

Skill-Real-Time-Competitive-Repricing

声明类型推断验证状态待复核

Momcozy M5 与 3 个竞品争夺 Buy Box,"永远低于 Elvie $5"策略导致旺季每件少赚 $10——DRL 动态重定价识别最优价格窗口,旺季 Buy Box 持有率保持 >85% 同时 ASP 提升 8-12%,年化 GMV 增量 30-60 万元

来源
paper2skills-vault/17-价格优化/Skill-Real-Time-Competitive-Repricing.md
适用边界
论文方法到业务问题的项目侧映射,不自动证明客户根因。
声明类型示例验证状态待企业数据验证

1000 万

来源
paper2skills-vault/17-价格优化/Skill-Real-Time-Competitive-Repricing.md#business-value
适用边界
方法估算或场景示例,不等于客户结果或收益承诺。

待企业数据验证 · 缺失:样本、基线、时间窗、币种、计算方法、证据来源

业务视角
适用角色定价负责人 / 运营负责人 · 选品负责人 · CEO
适用平台Amazon Buy Box 竞价策略 · 多市场价格协调 · Prime Day / Coupon 折扣优化
什么情况下用竞品突然降价,不知道该不该跟,跟了怕伤利润不跟怕丢 BSR;大促期间不知道折扣给多少,给多了利润没了
示例目标(需企业数据验证)实时监控竞品价格并自动触发调价,毛利率保持在目标区间,BSR 排名和利润同时兼顾
业务痛点
竞品降价了不知道要不要跟大促折扣给多少没有依据手动盯价格太累反应不及时新品上线定价高了还是低了

1. 解决的问题

Momcozy M5 与 3 个竞品争夺 Buy Box,"永远低于 Elvie $5"策略导致旺季每件少赚 $10——DRL 动态重定价识别最优价格窗口,旺季 Buy Box 持有率保持 >85% 同时 ASP 提升 8-12%,年化 GMV 增量 30-60 万元

2. 核心算法逻辑

核心思想

传统规则型重定价("比竞品低 $2")有两个致命缺陷:反应慢(竞品改价后才响应)和无利润意识(只追求 Buy Box,可能把利润打穿)。深度强化学习(DRL)把重定价建模为马尔可夫决策过程:Agent 不断观察市场状态,学习在不同竞争环境下最大化累积利润(而非单次销售)。

MDP 框架:

  • 状态(State):当前价格、竞品价格分布、库存水位、时间特征、历史转化率
  • 动作(Action):连续价格调整幅度(±$X)或离散价格档位
  • 奖励(Reward):Δ转化率 × 贡献毛利 — 论文创新的"收入转化率差分"奖励函数
  • 策略(Policy):Deep Q-Network 或 Actor-Critic 网络

论文核心发现(Alibaba Tmall 多月字段实验):

  • DRL 定价 vs 人工专家:显著更优(具体提升幅度保密,但验证统计显著)
  • 连续价格空间优于离散价格档位(可以精细到 $0.01 调整)
  • 冷启动预训练:用历史数据预训练,新 SKU 无需重新探索

状态空间设计

state = [
    price_ratio,          # 自身价格 / 竞品均价
    buy_box_status,       # 是否持有 Buy Box(0/1)
    inventory_level,      # 库存天数(days of supply)
    conversion_rate_7d,   # 近7天转化率(相对基准)
    hour_of_day,          # 时段(消费高峰 vs 低谷)
    day_of_week,          # 星期(周末需求弹性不同)
    competitor_count,     # 活跃竞品数量
    price_floor,          # 盈亏平衡价(SKU P&L 输入)
]

关键假设

  • 竞品价格通过 Keepa API / 爬虫实时获取(每小时刷新)
  • price_floor 由 SKU P&L 模型提供(避免亏损)
  • 适用于同质化竞争场景(多个卖家卖类似规格产品)

3. 业务应用场景

业务问题:Momcozy M5 在 Amazon 与 3 个竞品共享 Buy Box,当前策略是"永远低于 Elvie $5",导致旺季明明可以卖 $94.99 却只卖 $84.99,每件少赚 $10。

DRL 重定价的优势: - 旺季(黑五前 2 周):竞品也在备货,对价格不敏感 → DRL 学到可以提价 $8-12 而不失 Buy Box - 平日夜间(0-6 点):流量低,Buy Box 争夺不激烈 → DRL 可以轻微提价保护毛利 - 竞品缺货时:DRL 快速抬价,临时垄断利润

三轨验证: - 成本:Keepa API 订阅费约 $50-200/月;每小时爬虫运行需 1 台轻量云服务器(约 $30/月);DRL 模型训练需 GPU 实例(约 $100/月,预训练后仅需推理)。总显性成本约 $180-330/月。 - 合规:Amazon 允许动态定价,但禁止"价格操纵"(如合谋抬价)。DRL 仅基于公开竞品价格和自身库存做决策,不涉及竞品间通信,符合 Amazon 定价政策。需确保不触发"价格欺诈"红线(如灾难期间大幅提价)。 - 风险:若竞品也使用类似 DRL 策略,可能形成"算法共谋"(双方同时提价或降价),引发平台审查。建议设置最大单次调价幅度(如 ±5%)和价格

4. 输入数据要求

未提取到输入条目;请核对原始 Skill 卡片与代码。

5. 输出结果

未提取到输出条目;请核对原始 Skill 卡片与代码。

6. 业务价值与 ROI

  • ROI 预估:
  • 旺季不再错过提价机会:月增 GMV 3-8%,1000 万 GMV 规模 → ¥30-80 万/年
  • 停止无意义价格战:避免非高峰期无效降价损失毛利 ¥10-30 万/年
  • 新品定价学习加速:30 天内找到最优价格区间(vs 手动 90 天)
  • 年化综合 ROI:¥50-150 万
  • 实施难度:⭐⭐⭐☆☆(需要 Keepa API + Q-learning 实现;生产级 DQN 需要 PyTorch,2-3 周)

7. 代码模板

代码块数量:2

Python242 行 · 完整显示
"""
Real-Time Competitive Repricing — DRL 竞品重定价简化实现
基于 arXiv: 1912.02572 (Alibaba/Tmall DRL Pricing)

依赖: numpy, dataclasses (标准库)
生产环境: 替换 MockMarketEnv 为实际 Keepa/Seller Central API
"""

from dataclasses import dataclass, field
import numpy as np


@dataclass
class MarketState:
    """当前市场状态(MDP 状态向量)"""
    our_price: float
    competitor_prices: list          # 竞品价格列表
    inventory_days: float            # 库存天数
    conversion_rate_7d: float        # 近7天转化率
    hour_of_day: int                 # 当前时段
    day_of_week: int                 # 星期几(0=周一)
    price_floor: float               # SKU 最低盈亏平衡价
    price_ceiling: float             # 最高心理价位

    @property
    def competitor_min(self) -> float:
        return min(self.competitor_prices) if self.competitor_prices else self.our_price

    @property
    def price_ratio(self) -> float:
        return self.our_price / max(self.competitor_min, 0.01)

    def to_vector(self) -> np.ndarray:
        """状态向量化"""
        peak_hour = 1.0 if 18 <= self.hour_of_day <= 22 else 0.0
        weekend = 1.0 if self.day_of_week >= 5 else 0.0
        return np.array([
            self.price_ratio,
            self.our_price / self.price_floor if self.price_floor > 0 else 1.0,
            min(1.0, self.inventory_days / 60),
            self.conversion_rate_7d,
            peak_hour,
            weekend,
            min(1.0, len(self.competitor_prices) / 5),
        ])


@dataclass
class RepricingDecision:
    """重定价决策"""
    new_price: float
    price_change: float
    confidence: float
    reason: str


class SimpleQLearner:
    """
    简化版 Q-Learning 重定价策略

    生产环境替换为 DQN(2层MLP):
    
    import torch.nn as nn
    class DQN(nn.Module):
        def __init__(self):
            super().__init__()
            self.net = nn.Sequential(
                nn.Linear(7, 64), nn.ReLU(),
                nn.Linear(64, 32), nn.ReLU(),
                nn.Linear(32, 9)  # 9个价格调整动作
            )
    """

    # 可选的价格调整动作(相对于当前价格)
    PRICE_ACTIONS = [-0.05, -0.03, -0.02, -0.01, 0, +0.01, +0.02, +0.03, +0.05]

    def __init__(self, learning_rate: float = 0.01, epsilon: float = 0.15,
                 gamma: float = 0.95):
        self.lr = learning_rate
        self.epsilon = epsilon        # 探索率
        self.gamma = gamma            # 折扣因子
        self.q_table: dict = {}       # 简化版 Q-table

    def _state_key(self, state_vec: np.ndarray) -> tuple:
        """状态向量离散化(用于 Q-table 索引)"""
        return tuple(np.round(state_vec, 1))

    def select_action(self, state: MarketState) -> int:
        """ε-greedy 选择动作"""
        if np.random.random() < self.epsilon:
            return np.random.randint(len(self.PRICE_ACTIONS))  # 探索

        state_vec = state.to_vector()
        key = self._state_key(state_vec)
        q_values = self.q_table.get(key, np.zeros(len(self.PRICE_ACTIONS)))
        return int(np.argmax(q_values))

    def update(self, state: MarketState, action_idx: int,
               reward: float, next_state: MarketState) -> None:
        """Q-learning 更新"""
        s_key = self._state_key(state.to_vector())
        ns_key = self._state_key(next_state.to_vector())

        q_curr = self.q_table.get(s_key, np.zeros(len(self.PRICE_ACTIONS)))
        q_next = self.q_table.get(ns_key, np.zeros(len(self.PRICE_ACTIONS)))

        target = reward + self.gamma * np.max(q_next)
        q_curr[action_idx] += self.lr * (target - q_curr[action_idx])
        self.q_table[s_key] = q_curr


class RepricingAgent:
    """
    实时竞品重定价 Agent

    核心逻辑:
    1. 观察当前市场状态
    2. DRL/Q-learning 选择价格调整
    3. 应用约束(price_floor ≤ new_price ≤ price_ceiling)
    4. 执行并观察结果 → 更新模型
    """

    def __init__(self, sku_id: str, learner: SimpleQLearner = None):
        self.sku_id = sku_id
        self.learner = learner or SimpleQLearner()
        self.decision_history = []

    def decide(self, state: MarketState) -> RepricingDecision:
        """生成重定价决策"""
        action_idx = self.learner.select_action(state)
        action_pct = SimpleQLearner.PRICE_ACTIONS[action_idx]

        raw_new_price = state.our_price * (1 + action_pct)
        # 约束:不得低于 price_floor,不得高于 price_ceiling
        new_price = max(state.price_floor, min(state.price_ceiling, raw_new_price))
        new_price = round(new_price / 0.01) * 0.01  # 精确到 $0.01

        # 生成决策原因
        if new_price > state.our_price:
            reason = "竞品短缺或高峰时段,提价保护毛利"
        elif new_price < state.our_price:
            reason = "竞品降价或转化率下降,降价维持竞争力"
        else:
            reason = "市场均衡,维持当前价格"

        decision = RepricingDecision(
            new_price=new_price,
            price_change=round(new_price - state.our_price, 2),
            confidence=1 - self.learner.epsilon,
            reason=reason,
        )
        self.decision_history.append((state, action_idx, decision))
        return decision

    def simulate_episode(self, initial_state: MarketState,
                         n_steps: int = 30) -> list:
        """模拟30天的重定价过程"""
        results = []
        state = initial_state

        for step in range(n_steps):
            decision = self.decide(state)

            # 模拟市场反应
            np.random.seed(step)
            price_effect = -0.8 * (decision.price_change / state.our_price)
            base_cvr = state.conversion_rate_7d
            new_cvr = max(0.01, base_cvr * (1 + price_effect + np.random.normal(0, 0.02)))

            # 奖励:新转化率改善 × 贡献毛利
            cm_per_unit = decision.new_price - (state.price_floor * 0.7)
            reward = (new_cvr - base_cvr) * cm_per_unit * 100  # 单位销量

            # 更新 Q-table
            next_state = MarketState(
                our_price=decision.new_price,
                competitor_prices=state.competitor_prices,
                inventory_days=max(0, state.inventory_days - 1),
                conversion_rate_7d=new_cvr,
                hour_of_day=(state.hour_of_day + 8) % 24,
                day_of_week=(state.day_of_week + (1 if step % 3 == 0 else 0)) % 7,
                price_floor=state.price_floor,
                price_ceiling=state.price_ceiling,
            )
            self.learner.update(state, self.decision_history[-1][1], reward, next_state)

            results.append({
                "step": step + 1,
                "price": decision.new_price,
                "cvr": round(new_cvr, 4),
                "reward": round(reward, 2),
            })
            state = next_state

        return results


def run_repricing_demo():
    """演示:吸奶器 DRL 自动重定价"""
    print("=" * 60)
    print("Real-Time Competitive Repricing — DRL 重定价演示")
    print("=" * 60)

    initial_state = MarketState(
        our_price=89.99,
        competitor_prices=[92.00, 87.50, 94.99],
        inventory_days=45.0,
        conversion_rate_7d=0.082,
        hour_of_day=20,
        day_of_week=4,  # 周五
        price_floor=65.0,  # 来自 SKU-Level-PL-Dashboard
        price_ceiling=109.99,
    )

    print(f"\n📊 初始状态: 我方 ${initial_state.our_price} | "
          f"竞品最低 ${initial_state.competitor_min} | "
          f"当前 CVR {initial_state.conversion_rate_7d:.1%}")

    agent = RepricingAgent("M5-BPump")
    results = agent.simulate_episode(initial_state, n_steps=10)

    print(f"\n{'天数':>5} {'价格':>8} {'CVR':>8} {'奖励':>8}")
    print("-" * 35)
    for r in results:
        print(f"{r['step']:>5} ${r['price']:>7.2f} {r['cvr']:>7.2%} {r['reward']:>8.2f}")

    prices = [r["price"] for r in results]
    cvrs = [r["cvr"] for r in results]

    # 验证
    assert all(initial_state.price_floor <= p <= initial_state.price_ceiling
               for p in prices), "所有价格应在允许范围内"
    assert len(results) == 10

    avg_reward = sum(r["reward"] for r in results) / len(results)
    print(f"\n平均奖励: {avg_reward:.2f}")
    print("\n[✓] Real-Time Competitive Repricing 测试通过")
    return results


if __name__ == "__main__":
    run_repricing_demo()

8. 论文来源

论文链接用于核验方法来源,不自动证明本页商业结果。