Pricing Engine Toolkit
Dynamic pricing rules, competitor price monitoring, margin calculation, discount scheduling, and A/B price testing. Maximize revenue with data-driven pricing strategies.
Key Features
- Dynamic Pricing Rules — Time-based, demand-based, and inventory-based price adjustments
- Competitor Monitoring — Track competitor prices and auto-adjust within configured bounds
- Margin Calculator — Real-time margin analysis across cost tiers and volume discounts
- Discount Scheduler — Plan and auto-activate promotional pricing with start/end dates
- A/B Price Testing — Split traffic between price variants and measure conversion impact
- Price Guardrails — Floor and ceiling enforcement to protect margins
Quick Start
# 1. Extract and configure
unzip pricing-engine-toolkit.zip
cd pricing-engine-toolkit
cp config.example.yaml config.yaml
# 2. Load product costs and current prices
python -m pricing_engine_toolkit.core --load-catalog catalog.csv
# 3. Run pricing optimization
python -m pricing_engine_toolkit.core --optimize --config config.yaml
Architecture
src/pricing_engine_toolkit/
├── __init__.py # Package metadata and version
├── core.py # Pricing engine: rules evaluation, price calculation
├── competitors.py # Competitor price scraping and comparison
├── scheduler.py # Discount and promotion scheduling
├── ab_testing.py # Price variant assignment and result analysis
└── utils.py # Margin math, rounding rules, currency formatting
Usage Examples
Apply Dynamic Pricing Rules
from pricing_engine_toolkit.core import PricingEngine
engine = PricingEngine(config_path="config.yaml")
# Evaluate pricing for a product
price = engine.calculate(
sku="WIDGET-BLU-LG",
base_price=49.99,
cost=18.50,
current_stock=12,
demand_score=0.85 # 0-1 scale, higher = more demand
)
print(f"Recommended price: ${price['recommended']:.2f}")
print(f"Margin: {price['margin_pct']:.1%}")
print(f"Rule applied: {price['rule_name']}")
# Recommended price: $54.99
# Margin: 66.3%
# Rule applied: high_demand_low_stock
Competitor Price Comparison
from pricing_engine_toolkit.competitors import CompetitorTracker
tracker = CompetitorTracker(config_path="config.yaml")
comparison = tracker.compare(sku="WIDGET-BLU-LG")
for comp in comparison:
print(f"{comp['competitor']}: ${comp['price']:.2f} "
f"({'below' if comp['diff'] < 0 else 'above'} by ${abs(comp['diff']):.2f})")
Schedule a Promotion
from pricing_engine_toolkit.scheduler import DiscountScheduler
scheduler = DiscountScheduler(config_path="config.yaml")
scheduler.create_promotion(
name="Spring Sale 2026",
skus=["WIDGET-*"], # Wildcard SKU matching
discount_pct=20,
start_date="2026-04-01",
end_date="2026-04-14",
min_price_floor=25.00 # Never go below this
)
Margin Analysis Query
-- Product margin analysis with pricing tier breakdown
SELECT
p.sku,
p.product_name,
p.base_price,
p.cost,
p.base_price - p.cost AS gross_margin,
(p.base_price - p.cost) / p.base_price * 100 AS margin_pct,
pr.current_price,
pr.rule_applied,
CASE
WHEN (p.base_price - p.cost) / p.base_price < 0.20 THEN 'LOW'
WHEN (p.base_price - p.cost) / p.base_price < 0.40 THEN 'MEDIUM'
ELSE 'HEALTHY'
END AS margin_tier
FROM products p
JOIN pricing_rules pr ON p.sku = pr.sku
ORDER BY margin_pct ASC;
Configuration
pricing:
strategy: "margin_optimized" # margin_optimized | competitive | volume
rounding: "charm" # charm (.99) | nearest (.00) | none
currency: "USD"
rules:
high_demand_low_stock:
condition: "demand_score > 0.7 AND stock < 20"
adjustment: "+10%"
max_increase: 25.00
clearance:
condition: "stock > 500 AND days_in_stock > 90"
adjustment: "-15%"
min_price: "cost * 1.10" # Never below 10% above cost
guardrails:
min_margin_pct: 15 # Hard floor: 15% margin minimum
max_price_change_pct: 25 # Max single adjustment: 25%
price_change_cooldown_hours: 24 # Min time between price changes
competitors:
check_interval_hours: 6
sources_file: "competitors.yaml"
strategy: "match_minus_5pct" # match | match_minus_5pct | ignore
ab_testing:
enabled: false
default_split: [50, 50] # Traffic split between variants
min_sample_size: 200 # Minimum orders before declaring winner
Best Practices
- Set margin guardrails first — Prevent rules from driving prices below profitability
- Start with conservative adjustments — 5-10% max change per cycle
- Use cooldown periods — Avoid price whiplash from rapid re-evaluations
- A/B test before committing — Validate that higher prices don't tank conversion
- Monitor competitor data quality — Stale competitor prices lead to bad decisions
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Prices dropping too low | Missing min_price guardrail |
Set min_margin_pct in guardrails |
| No rules triggering | Conditions too strict | Review rule conditions and thresholds |
| A/B test inconclusive | Not enough traffic | Increase min_sample_size or run longer |
| Competitor prices stale | Scraper blocked or source changed | Check competitor source configuration |
This is 1 of 11 resources in the Retail Automation Pro toolkit. Get the complete [Pricing Engine Toolkit] with all files, templates, and documentation for $49.
Or grab the entire Retail Automation Pro bundle (11 products) for $139 — save 30%.
Top comments (0)