EZRate
Sign in

Dynamic Pricing with an Exchange Rate API: Pegging Toman Prices to Live FX

Dynamic pricing with an exchange rate API keeps Toman prices in line with the dollar: formulas, rounding, update thresholds, spike guardrails and customer messaging.

Arian Asadi
· Writer and Market Analyst
Published 8 November 2026, 20:00 · 2 min read
Dynamic Pricing with an Exchange Rate API: Pegging Toman Prices to Live FX
Key takeaways
  • Stores selling imported goods in Iran lose margin when the dollar rises and price prints stay fixed.
  • Store a base price in USD (or AED, EUR) per product and compute the Toman price from the live rate plus margin, with rounding and thresholds.
  • Guardrails — minimum change, maximum jump, low-source pause, manual approval — prevent bad data from reaching the shelf.

In a market where the dollar can move several percent in a day, a fixed Toman price list is a bet. If the dollar rises you sell below replacement cost; if it falls you are overpriced. Dynamic pricing with an exchange rate API removes the guesswork. This guide explains the model, formulas and guardrails that make it safe.

★
Short answer
Keep a base price per product in the currency you buy in (USD, AED, EUR). On a schedule, fetch the live sell rate, compute toman = base × rate × (1 + margin), round to a friendly step and update the product only if the change exceeds a threshold. Pause updates when the rate is flagged low-source or jumps more than your limit, and log every change.

Part of the Iranian Rial exchange rate API guide.

Which rate to use

Your cost is in…Rate to useWhy
US dollars, cashusd sellReplacement cost
Supplier in Dubaiaed sell or Dubai dollarYou pay via remittance; see AED hawala rate
Supplier in Turkey or Europetry or eurMatch the invoice currency
Gold contentg18Jewellery: Iran gold price API

The pricing formula

python
import math

def toman_price(base, rate, margin=0.18, fees=0.0, step=10_000):
    raw = base * rate * (1 + margin) + fees
    return int(math.ceil(raw / step) * step)   # round up to a friendly step

# $42 product, USD sell 100,000 Toman (illustrative), 18% margin
print(toman_price(42, 100_000))   # 4,960,000
  • Margin covers your costs and profit; set it per category.
  • Fees cover fixed costs such as shipping that are not dollar-linked.
  • Rounding to 1,000 / 10,000 / 50,000 Toman keeps prices readable and avoids constant tiny changes.

When to update

RuleTypical settingPurpose
ScheduleEvery 15–60 minFresh enough, cheap
Minimum change≥ 1% vs current priceAvoid churn and customer confusion
Maximum jump≤ 5% per cycle without approvalStops bad ticks reaching the shelf
Low-source pauseSkip when low_sources is trueNo repricing on thin data at night
Quiet hoursOptionalDo not change prices while carts are full at peak

Reference implementation

python
import os, requests

def live(symbol):
    r = requests.get(f"https://api.ezrate.me/v1/rates/{symbol}",
                     headers={"X-API-Key": os.environ["EZRATE_KEY"]}, timeout=10)
    r.raise_for_status()
    return r.json()["data"]

def reprice(products, store, min_change=0.01, max_jump=0.05):
    usd = live("usd")
    if usd["low_sources"]:
        return "skipped: low sources"
    for p in products:
        new = toman_price(p.base_usd, usd["sell"], p.margin)
        delta = new / p.price - 1
        if abs(delta) < min_change:
            continue
        if abs(delta) > max_jump:
            store.queue_for_approval(p, new, usd)
            continue
        store.update_price(p, new, reason=f"usd {usd['sell']} at {usd['updated_at']}")

WooCommerce users can follow the plugin-based approach in WooCommerce live Toman rates.

US Dollar265,390Toman−0.30%

Communicating with customers

  • Show “price updated at …” on product pages.
  • Honour the price in the cart for a set time (e.g. 30 minutes) to avoid checkout surprises.
  • Keep a price-history log for support and for consumer-protection questions.
  • Be transparent in your terms that prices follow the exchange rate.

Common mistakes

  • Using the official rate: your costs follow the free market — see official vs free market.
  • Updating on every tick: customers see prices flicker.
  • Mixing Rial and Toman: a 10× pricing error. See IRR vs Toman.
  • No guardrails: one bad data point reprices the entire catalogue.

Designing the margin

The margin in the formula has to cover more than profit. It should absorb the cost of currency movements between the time you price a product and the time you replace your stock, payment and shipping costs that are not tied to the dollar, and the spread you pay when you buy currency. Stores with fast stock turnover can use thinner margins; stores that hold stock for months need a buffer or more frequent repricing. Review margins per category every month against actual replacement costs.

Testing before going live

  1. Run the repricer in “dry run” mode for a week and log the prices it would have set.
  2. Compare those prices with your manual prices and your actual purchase costs.
  3. Turn on automatic updates for one category first, then expand.

Related live rates: US dollar rate, 18K gold price, Emami coin price.

What is dynamic pricing with an exchange rate API?
Automatically recalculating local-currency prices from a base price in a foreign currency using a live exchange rate.
How often should prices update?
Every 15–60 minutes, with a minimum change threshold so prices do not flicker.
How do I avoid bad prices from a data glitch?
Pause on low-source data, cap jumps per cycle and send large changes for manual approval.
Which exchange rate should a store use?
The free-market sell rate of the currency you actually pay your supplier in.
Arian Asadi
I studied economics and developed an interest in financial markets, exchange rates, and economic developments during my university years. Throughout my professional career, I have focused particularly on foreign exchange markets, gold, international money transfers, and the impact of economic developments on prices. In the articles I write, I strive to present information about exchange rates and financial markets in a clear and accessible way, based on verifiable data and market trends. My goal is to help readers gain a clearer understanding of market conditions before making decisions about buying, selling, or transferring currencies.
All posts by author →

Comments (0)

Comments are shown after review. Sign-in is needed to send.

Related

API & Developers
Flutter Currency Tracker Tutorial (plus React Native): Build an Iranian Gold and FX App
API & Developers
React Currency Converter for Live Toman Rates, with a Secure Backend Proxy
API & Developers
Securing Financial API Keys in Web and Mobile Apps: Proxies, Restrictions and Rotation