Forex Bid, Ask & Spreads Explained
Understand Bid, Ask, mid-price, and pip spread calculations in FX market data feeds, and learn how to avoid floating-point pitfalls in code.
Core Takeaway · 30-Second Brief
Bid is the price at which the market maker buys, Ask is the price at which it sells, and Ask minus Bid is the spread. Applications typically display the mid-price (Bid + Ask) / 2 or explicitly label Bid/Ask, while execution and cost models must store both sides of the book.
01
Four Core Pricing Concepts
| Field | Definition | Typical Engineering Usage |
|---|---|---|
Bid | Price a liquidity provider is willing to buy at | Valuing long liquidation or market sell execution |
Ask | Price a liquidity provider is willing to sell at | Valuing market buy execution |
Mid-Price | (Bid + Ask) / 2 | UI price display, charting, and indicator calculations |
Spread | Ask − Bid | Measuring liquidity conditions and transaction costs |
02
Converting Price Differences into Pips
Most major currency pairs are quoted to 4 decimal places where 1 pip equals 0.0001; JPY pairs (such as USD/JPY) are quoted to 2 decimal places where 1 pip equals 0.01. Many feeds append an extra fractional digit (pipette). Always normalize by the pair’s pip size rather than blindly multiplying by 10,000.
def pip_size(symbol: str) -> float: return 0.01 if symbol.upper().endswith("JPY") else 0.0001def spread_in_pips(symbol: str, bid: float, ask: float) -> float: return round((ask - bid) / pip_size(symbol), 1)print(spread_in_pips("EURUSD", 1.08512, 1.08525)) # 1.3print(spread_in_pips("USDJPY", 149.812, 149.826)) # 1.403
Common Engineering Mistakes
- Persisting only a single price column, making it impossible to reconstruct historical spreads.
- Confusing top-of-book Bid/Ask quotes with executed trade ticks.
- Comparing floating-point prices with == instead of using Decimal or epsilon tolerances.
- Failing to normalize symbol conventions across sources (e.g., EURUSD vs EUR/USD).
04
Querying Forex Quotes in AllTick
AllTick serves forex, precious metals, and commodity feeds through quote-b-api (REST) and quote-b-ws-api (WebSocket) using concatenated symbols such as EURUSD and USDJPY. The depth-tick endpoint returns both Bid and Ask levels for direct spread calculation.
Sources & Verification · 2026-10-13
Relevant endpoint, field, and exchange rules were checked against the primary specifications linked below.
Python examples passed ast.parse on Python 3.14.0. This checks syntax only; dependencies, runtime compatibility, and network responses were not tested.
Authenticated AllTick requests and production end-to-end tests were not run for this review. Record your token plan, library versions, market session, ret/trace, and observed results when reproducing these checks.
Primary specifications
Reproduce before deployment
- Keep bid and ask from the same update with decimal precision. Reject a missing side, nonpositive price, or ask below bid before computing a spread.
- Confirm the instrument tick size and whether the result is price units or pips. Compare normal sessions with rollover and stale-quote cases.