声明类型推断验证状态待复核
中型卖家每周花6小时手动调整200个关键词出价规则不一致还有遗漏——条件触发规则引擎7×24小时自动执行高ACOS降价/无转化暂停/低曝光提价,ACOS降低15-20%运营时间节省80%年化20-50万元
Skill-PPC-Rule-Automation-Engine
中型卖家每周花6小时手动调整200个关键词出价规则不一致还有遗漏——条件触发规则引擎7×24小时自动执行高ACOS降价/无转化暂停/低曝光提价,ACOS降低15-20%运营时间节省80%年化20-50万元
¥20-50 万
待企业数据验证 · 缺失:样本、基线、时间窗、币种、计算方法、证据来源
中型卖家每周花6小时手动调整200个关键词出价规则不一致还有遗漏——条件触发规则引擎7×24小时自动执行高ACOS降价/无转化暂停/低曝光提价,ACOS降低15-20%运营时间节省80%年化20-50万元
手动调价 vs 规则自动化:
手动调价(现状):
每周一查报告 → 找 ACOS 偏高的词 → 降价10% → 等下周看结果
问题:滞后1周,竞争变化没有及时响应;规则不一致
规则自动化:
每日/每小时自动检查所有关键词
→ 满足条件立即执行
Rule 1: IF ACOS > 30% AND Clicks >= 20 THEN Decrease Bid 10%
Rule 2: IF ACOS < 15% AND Impressions >= 1000 THEN Increase Bid 5%
Rule 3: IF Clicks >= 30 AND Orders = 0 THEN Pause Keyword
Rule 4: IF TimeOfDay = 00:00-06:00 THEN Decrease Bid 30% (dayparting)规则引擎核心概念:
规则 = 条件集合 + 动作 + 执行约束
条件类型:
指标条件:ACOS/CTR/CVR/Impressions/Clicks/Orders/Spend
时间条件:星期几/时间段/促销期
竞争条件:关键词排名变化/竞品出价变化
动作类型:
出价调整:增加X%/减少X%/设为固定值
预算调整:增加/减少每日预算
状态变更:启用/暂停/归档
通知:发送邮件/Slack 告警
执行约束:
频率限制:同一关键词同一天最多调整2次
变化上限:单次变化不超过20%(防止剧烈波动)
优先级:多条规则同时触发时的优先顺序安全护栏:
规则引擎必须防止"规则风暴"(循环触发导致出价剧烈震荡):
业务问题:运营有 200 个关键词,每周花 6 小时手动检查和调整。其中: - 30 个关键词 ACOS > 35%(过度花费) - 20 个关键词 7 天无转化但还在花钱 - 10 个低 ACOS 优质词没有加预算(错失机会)
规则引擎把这些决策自动化,每天运行而非每周,响应更及时。
数据要求: - Amazon 广告报告(关键词维度,每日数据) - 目标 ACOS 设置(按 SKU 或活动)
代码块数量:3
"""
PPC Rule Automation Engine
条件触发的广告出价自动化规则引擎
"""
import numpy as np
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from collections import defaultdict
@dataclass
class KeywordMetrics:
keyword: str
match_type: str # exact/phrase/broad
current_bid: float
impressions: int
clicks: int
orders: int
spend: float
acos: float # 实际 ACOS
target_acos: float = 0.25 # 目标 ACOS
last_modified: datetime = None
@dataclass
class AutomationRule:
rule_id: str
name: str
conditions: list[dict] # [{metric, operator, value}]
action: dict # {type, value}
cooldown_hours: int = 24
max_daily_changes: int = 2
enabled: bool = True
def evaluate(self, metrics: KeywordMetrics) -> bool:
"""检查规则条件是否满足"""
for cond in self.conditions:
metric_val = getattr(metrics, cond['metric'], None)
if metric_val is None:
return False
op = cond['operator']
threshold = cond['value']
if op == '>' and not (metric_val > threshold): return False
if op == '<' and not (metric_val < threshold): return False
if op == '>=' and not (metric_val >= threshold): return False
if op == '<=' and not (metric_val <= threshold): return False
if op == '==' and not (metric_val == threshold): return False
return True
class PPCRuleEngine:
"""PPC 规则自动化引擎"""
def __init__(self):
self.rules: list[AutomationRule] = []
self.execution_log: list[dict] = []
self.keyword_change_count: dict = defaultdict(int)
self.keyword_last_modified: dict = {}
def add_rule(self, rule: AutomationRule):
self.rules.append(rule)
def _can_modify(self, keyword: str, rule: AutomationRule) -> bool:
"""检查冷却期和次数限制"""
# 检查冷却期
last_mod = self.keyword_last_modified.get(keyword)
if last_mod:
hours_elapsed = (datetime.now() - last_mod).total_seconds() / 3600
if hours_elapsed < rule.cooldown_hours:
return False
# 检查每日次数
if self.keyword_change_count[keyword] >= rule.max_daily_changes:
return False
return True
def execute_action(self, metrics: KeywordMetrics, action: dict) -> dict:
"""执行动作并返回结果"""
old_bid = metrics.current_bid
new_bid = old_bid
if action['type'] == 'increase_bid_pct':
change = min(0.20, action['value'] / 100) # 最多增加20%
new_bid = old_bid * (1 + change)
elif action['type'] == 'decrease_bid_pct':
change = min(0.20, action['value'] / 100)
new_bid = old_bid * (1 - change)
elif action['type'] == 'set_bid':
new_bid = action['value']
elif action['type'] == 'pause':
return {'action': 'pause', 'old_bid': old_bid, 'new_bid': 0}
new_bid = max(0.10, min(5.0, round(new_bid, 2))) # 出价范围约束
return {'action': action['type'], 'old_bid': round(old_bid, 2),
'new_bid': new_bid, 'change_pct': round((new_bid - old_bid) / old_bid * 100, 1)}
def run(self, keywords: list[KeywordMetrics]) -> list[dict]:
"""运行规则引擎,返回执行日志"""
logs = []
for kw in keywords:
triggered_rules = []
for rule in self.rules:
if not rule.enabled: continue
if not rule.evaluate(kw): continue
if not self._can_modify(kw.keyword, rule): continue
triggered_rules.append(rule)
if not triggered_rules: continue
# 按优先级执行(规则列表顺序即优先级)
top_rule = triggered_rules[0]
result = self.execute_action(kw, top_rule.action)
result['keyword'] = kw.keyword
result['rule_name'] = top_rule.name
result['acos'] = kw.acos
result['clicks'] = kw.clicks
result['orders'] = kw.orders
# 更新状态
self.keyword_change_count[kw.keyword] += 1
self.keyword_last_modified[kw.keyword] = datetime.now()
logs.append(result)
return logs
def build_standard_rules(target_acos: float = 0.25) -> list[AutomationRule]:
"""构建标准 PPC 规则集"""
return [
AutomationRule('R001', '高ACOS降价',
conditions=[{'metric': 'acos', 'operator': '>', 'value': target_acos * 1.4},
{'metric': 'clicks', 'operator': '>=', 'value': 15}],
action={'type': 'decrease_bid_pct', 'value': 12}),
AutomationRule('R002', '低ACOS提价',
conditions=[{'metric': 'acos', 'operator': '<', 'value': target_acos * 0.6},
{'metric': 'impressions', 'operator': '>=', 'value': 500}],
action={'type': 'increase_bid_pct', 'value': 8}),
AutomationRule('R003', '无转化暂停',
conditions=[{'metric': 'clicks', 'operator': '>=', 'value': 25},
{'metric': 'orders', 'operator': '==', 'value': 0}],
action={'type': 'pause', 'value': 0},
cooldown_hours=72),
AutomationRule('R004', '低曝光提价',
conditions=[{'metric': 'impressions', 'operator': '<', 'value': 100},
{'metric': 'acos', 'operator': '<', 'value': target_acos}],
action={'type': 'increase_bid_pct', 'value': 15}),
]
def run_ppc_automation_demo():
print('=' * 65)
print('PPC Rule Automation Engine — 广告规则自动化引擎')
print('=' * 65)
np.random.seed(42)
keywords = [
KeywordMetrics('breast pump', 'exact', 2.0, 5000, 150, 8, 300, 0.38), # ACOS过高
KeywordMetrics('quiet breast pump','exact', 1.2, 3000, 90, 6, 108, 0.21), # ACOS正常
KeywordMetrics('hospital pump', 'phrase',1.5, 200, 30, 0, 45, 1.50), # 无转化
KeywordMetrics('portable pump', 'broad', 0.8, 80, 10, 1, 8, 0.18), # 曝光低
KeywordMetrics('wearable pump', 'exact', 1.8, 1500, 60, 5, 108, 0.26), # 正常
]
engine = PPCRuleEngine()
for rule in build_standard_rules(target_acos=0.25):
engine.add_rule(rule)
logs = engine.run(keywords)
print(f'\n📊 规则引擎执行报告(共 {len(keywords)} 个关键词):')
print(f' 触发规则: {len(logs)} 次')
print()
print(f' {"关键词":<22} {"规则":>16} {"旧出价":>7} {"新出价":>7} {"变化":>7} {"ACOS":>7}')
print(' ' + '-' * 72)
for log in logs:
action_icon = {'pause': '⏸', 'increase_bid_pct': '↑', 'decrease_bid_pct': '↓'}.get(log['action'], '~')
new_bid_str = '暂停' if log['action'] == 'pause' else f"${log['new_bid']:.2f}"
change_str = '暂停' if log['action'] == 'pause' else f"{log.get('change_pct', 0):+.1f}%"
print(f' {log["keyword"]:<22} {log["rule_name"]:>16} ${log["old_bid"]:>6.2f} '
f'{new_bid_str:>7} {action_icon} {change_str:>6} {log["acos"]:>7.0%}')
not_triggered = [kw.keyword for kw in keywords if kw.keyword not in [l['keyword'] for l in logs]]
print(f'\n ✅ 未触发规则(正常运行): {not_triggered}')
print(f'\n 💡 规则引擎每日自动运行,无需人工干预')
print('\n[✓] PPC Rule Automation Engine 测试通过')
if __name__ == '__main__':
run_ppc_automation_demo()论文链接用于核验方法来源,不自动证明本页商业结果。