Metadata-Version: 2.4
Name: ppcopen
Version: 0.1.0
Summary: PPCOpen - Open-Source Amazon PPC Strategy Engine, Backtester & AI Agent MCP Hub
Home-page: https://ppcopen.com
Author: PPCOpen
Author-email: PPCOpen <ppcopen.com@gmail.com>
License-Expression: AGPL-3.0-or-later
Project-URL: Homepage, https://ppcopen.com
Project-URL: Repository, https://github.com/ppcopen/ppcopen
Keywords: amazon-ppc,amazon-ads,ppc,acos,mcp,ai-agents,open-source
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# PPCOpen

**The Open-Source Amazon PPC Strategy Engine, Backtest Leaderboard & AI Agent MCP Hub.**

[![Website](https://img.shields.io/badge/web-ppcopen.com-blue)](https://ppcopen.com)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPLv3-orange.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-green.svg)](https://pypi.org/project/ppcopen/)
[![MCP Ready](https://img.shields.io/badge/MCP-Agent%20Ready-purple.svg)](#ai-agent--mcp-integration)

Closed-source Amazon PPC tools get acquired, hike prices, lock you into black-box algorithms, and eventually shut down. Your ad automation and bidding logic should never die with a corporate buyout.

**PPCOpen** gives sellers, agencies, and AI agents a transparent, deterministic strategy engine with **hard safety guardrails**, a **20-strategy open-source catalog**, a **backtest leaderboard**, and a **zero-dependency MCP server**.

---

## Why PPCOpen?

- **Open Strategy Marketplace:** Pick from 20 built-in battle-tested Amazon PPC strategies or author your own Python `BaseStrategy` in 20 lines of code.
- **Deterministic Hard Guardrails:** No third-party or AI-authored strategy can ever exceed your `min_bid`, `max_bid`, `max_bid_change_pct`, or pause/negate protected brand terms.
- **AI Agent Native (MCP):** Connect Claude, Cursor, OpenClaw, or your own agent via `ppcopen mcp` so AI can inspect campaigns, backtest strategies, and scaffold new algorithms safely.
- **Self-Host or Managed Cloud:** Run locally with `pip install ppcopen`, or deploy with zero Amazon Ads API setup friction on [ppcopen.com](https://ppcopen.com).

---

## Quickstart

```bash
pip install ppcopen
```

List all 20 built-in strategies:

```bash
ppcopen list
```

Run a backtest leaderboard across all strategies:

```bash
ppcopen leaderboard --target-acos 0.30
```

Backtest a specific strategy on your exported campaign/search-term CSV:

```bash
ppcopen backtest target_acos_optimizer --csv examples/sample_entities.csv --target-acos 0.28
```

Validate a custom community or AI-authored strategy:

```bash
ppcopen validate examples/custom_strategy_template.py
```

---

## AI Agent / MCP Integration

Start the built-in Model Context Protocol server over stdio:

```bash
ppcopen mcp
```

Exposed MCP tools:
- `list_strategies` — filter catalog by category or risk level (`LOW`, `MEDIUM`, `HIGH`)
- `run_backtest` — simulate projected ACoS, spend saved, and action counts
- `leaderboard` — rank all strategies against benchmark portfolio data
- `evaluate_guardrails` — dry-run any proposed bid change against safety bounds
- `generate_strategy_scaffold` — emit a ready-to-edit `BaseStrategy` Python template

---

## Writing Your Own Strategy

```python
from ppcopen import BaseStrategy, BidAdjustment, EntitySnapshot, EntityStatus, EntityType, Guardrails, RiskLevel, StrategyMetadata, StrategyResult


class WeekendAcosDefender(BaseStrategy):
    metadata = StrategyMetadata(
        id="weekend_acos_defender",
        name="Weekend ACoS Defender",
        version="0.1.0",
        author="Your Name",
        category="bidding",
        risk_level=RiskLevel.LOW,
        description="Cools overspending exact targets before margins erode.",
    )

    def evaluate(self, entities: list[EntitySnapshot], guardrails: Guardrails) -> StrategyResult:
        res = StrategyResult(strategy_id=self.metadata.id)
        for e in entities:
            if e.status == EntityStatus.ENABLED and e.entity_type == EntityType.KEYWORD:
                if e.clicks >= 6 and e.acos > guardrails.target_acos:
                    res.bid_adjustments.append(
                        BidAdjustment(e.entity_id, e.current_bid, round(e.current_bid * 0.85, 2), "ACoS above target", "WKD_1")
                    )
        return res
```

Even if a strategy accidentally proposes `$999.00`, `BaseStrategy.run()` enforces `apply_guardrails()` automatically before any action leaves the engine.

---

## Built-In Strategy Catalog (20 Strategies)

| Category | Strategies |
| :--- | :--- |
| **Bidding** | `target_acos_optimizer`, `zero_impression_booster`, `profit_harvester_conservative`, `high_acos_bleeder_cut`, `margin_break_even_balancer` |
| **Negation** | `bleeding_term_blocker`, `cannibalization_guard` |
| **Harvesting** | `exact_keyword_harvester`, `asin_target_harvester`, `zombie_keyword_reviver`, `new_asin_discovery` |
| **Protection** | `click_threshold_guardian`, `spend_cap_guardian`, `brand_defense_shield`, `low_ctr_trimmer`, `inventory_aware_throttle` |
| **Scaling** | `launch_aggressive_ranker`, `top_of_search_sniper`, `seasonality_ramp`, `portfolio_budget_rebalancer` |

---

## License

- Core Engine (`src/ppcopen/`): **GNU AGPL v3.0 or later** (`AGPL-3.0-or-later`). Anyone can self-host freely; hosted commercial SaaS derivatives must remain open source or obtain a commercial license.
- Example & Community Strategy SDK Templates (`examples/`): **MIT**.

Built by **PPCOpen** ([ppcopen.com](https://ppcopen.com)) — `ppcopen.com@gmail.com`
