DEV Community

agenthustler
agenthustler

Posted on • Edited on

How to Build a Cross-Border E-commerce Arbitrage Finder with Python

Price differences between Amazon US, UK, DE, and JP can exceed 50% for the same product. Build a scraper that finds these arbitrage opportunities automatically.

The Arbitrage Opportunity

Cross-border e-commerce arbitrage exploits price differences for identical products across regional marketplaces. Currency fluctuations and regional pricing create persistent gaps.

Scraping Multi-Region Product Prices

# Implementation is proprietary (that IS the moat).
# Skip the build — use our ready-made Apify actor:
# see the CTA below for the link (fpr=yw6md3).
Enter fullscreen mode Exit fullscreen mode

Finding Arbitrage Opportunities

def find_arbitrage(df, min_margin_pct=20):
    opportunities = []
    for asin in df['asin'].unique():
        prices = df[df['asin'] == asin]
        if len(prices) < 2:
            continue
        cheapest = prices.loc[prices['usd_price'].idxmin()]
        expensive = prices.loc[prices['usd_price'].idxmax()]
        margin_pct = (expensive['usd_price'] - cheapest['usd_price']) / cheapest['usd_price'] * 100
        if margin_pct >= min_margin_pct:
            opportunities.append({
                'asin': asin,
                'buy_region': cheapest['region'],
                'buy_price': cheapest['usd_price'],
                'sell_region': expensive['region'],
                'sell_price': expensive['usd_price'],
                'margin_pct': round(margin_pct, 1)
            })
    return pd.DataFrame(opportunities).sort_values('margin_pct', ascending=False)

opps = find_arbitrage(df)
print("\nArbitrage Opportunities (>20% margin):")
print(opps.to_string(index=False))
Enter fullscreen mode Exit fullscreen mode

Real-Time Exchange Rates

# Implementation is proprietary (that IS the moat).
# Skip the build — use our ready-made Apify actor:
# see the CTA below for the link (fpr=yw6md3).
Enter fullscreen mode Exit fullscreen mode

Net Margin After Fees

Use ThorData for geo-specific pricing. Monitor with ScrapeOps:

def calculate_net_margin(opp, shipping=15, duty_pct=5, platform_pct=15):
    total_cost = opp['buy_price'] + shipping + opp['buy_price'] * duty_pct / 100
    platform_fee = opp['sell_price'] * platform_pct / 100
    net_profit = opp['sell_price'] - total_cost - platform_fee
    return round((net_profit / total_cost) * 100, 1)

for _, opp in opps.iterrows():
    net = calculate_net_margin(opp)
    print(f"ASIN {opp['asin']}: Net margin {net}%")
Enter fullscreen mode Exit fullscreen mode

Key Considerations

  • Always factor in shipping, duties, and platform fees
  • Currency rates fluctuate — recheck at purchase time
  • Some products have regional restrictions
  • ScraperAPI handles Amazon's bot detection across all regions
  • Start with lightweight, high-margin products to minimize shipping costs

Top comments (0)