Chapter 4 Exercises
These exercises cover binary contracts, multi-outcome contracts, scalar contracts, order types, the trade lifecycle, position management, and settlement. Work through each section in order, as later exercises build on earlier concepts.
Part A: Binary Contract Fundamentals (Exercises 1-6)
Exercise 1: Basic Binary Payoff Calculation
A binary contract asks: "Will Bitcoin exceed $100,000 by December 31, 2026?" You buy a Yes contract at $0.62.
(a) What is your profit if Bitcoin exceeds $100,000 by the deadline?
(b) What is your loss if it does not?
(c) What is the implied probability of Bitcoin exceeding $100,000 based on the market price?
(d) If you instead buy the No contract at $0.40, what is your profit if Bitcoin does NOT exceed $100,000? What is your loss if it does?
(e) The prices sum to $1.02 ($0.62 + $0.40). What does the extra $0.02 represent?
Exercise 2: Shorting a Binary Contract
You believe the probability that the European Central Bank cuts rates at its next meeting is only 20%, but the Yes contract is priced at $0.35.
(a) If you sell (short) the Yes contract at $0.35, what is your P&L if the ECB does cut rates? What if it does not?
(b) What is your maximum loss? What is your maximum profit?
(c) What is the margin requirement for this short position (assuming full collateralization)?
(d) Compare this to buying the No contract at $0.65. Show that the P&L profiles are identical (ignoring any difference in prices from the overround).
Exercise 3: Arbitrage Detection
You observe the following prices on a binary contract ("Will it rain in Seattle on April 1?"):
| Platform A | Platform B |
|---|---|
| Yes: $0.55 | Yes: $0.48 | |
| No: $0.50 | No: $0.48 |
(a) Calculate the price sum on each platform. Is there an arbitrage opportunity?
(b) Describe the exact trades you would make to capture the arbitrage.
(c) Calculate the guaranteed profit per pair of contracts.
(d) What practical obstacles might prevent you from capturing this arbitrage?
Exercise 4: Binary P&L Table
Complete the following P&L table for a binary contract where you buy 200 Yes contracts at $0.45 per contract:
| Scenario | Total Cost | Total Payout | Net P&L | Return on Investment |
|---|---|---|---|---|
| Event occurs (Yes) | ? | ? | ? | ? |
| Event does not occur (No) | ? | ? | ? | ? |
Exercise 5: Multiple Binary Positions
You make the following trades over time on the same binary contract ("Will Company X be acquired in 2026?"):
- Buy 100 Yes contracts at $0.30
- Buy 50 Yes contracts at $0.40
- Sell 75 Yes contracts at $0.55
(a) What is your average cost basis after trades 1 and 2?
(b) What is your realized P&L from trade 3?
(c) How many contracts do you still hold?
(d) What is your average cost basis on the remaining contracts?
(e) If the contract resolves Yes, what is your total P&L (realized + settlement)?
(f) If the contract resolves No, what is your total P&L?
Exercise 6: Write a Python Function
Write a Python function binary_pnl_scenarios(purchase_price, quantity, side) that:
- Takes a purchase price (0 to 1), quantity (positive integer), and side ("yes" or "no").
- Returns a dictionary with keys "event_yes" and "event_no", each mapping to the net P&L for that scenario.
- Include input validation and docstring.
Test your function with: price=0.65, quantity=50, side="yes".
Part B: Multi-Outcome Contracts (Exercises 7-12)
Exercise 7: Multi-Outcome Price Analysis
An election market has the following prices:
| Candidate | Price |
|---|---|
| Harris | $0.35 |
| DeSantis | $0.25 |
| Newsom | $0.18 |
| Haley | $0.12 |
| Other | $0.15 |
(a) Calculate the total price sum and the overround.
(b) Calculate the normalized implied probability for each candidate.
(c) If you buy 100 contracts of Harris at $0.35, what is your P&L if Harris wins? If DeSantis wins? If any other candidate wins?
(d) What is your maximum profit and maximum loss?
Exercise 8: Overround and Fair Prices
A bookmaker sets prices for a three-outcome market with a 5% overround:
True probabilities: P(A) = 0.50, P(B) = 0.30, P(C) = 0.20
(a) If the overround is distributed proportionally, what are the market prices for A, B, and C?
(b) What is a trader's expected loss per dollar bet (assuming the true probabilities are known)?
(c) How does this compare to a market with 2% overround?
Exercise 9: Multi-Outcome Portfolio Construction
You want to construct a portfolio that profits if either Harris or Newsom wins the election from Exercise 7 (a "Democrat sweep" bet).
(a) What contracts do you buy, and at what prices?
(b) Calculate your total cost for 100 contracts of each.
(c) Calculate your P&L for each of the five possible winners.
(d) What is the implied probability that a Democrat wins (Harris or Newsom)?
Exercise 10: Arbitrage in Multi-Outcome Markets
You observe these prices across two platforms for the same five-candidate election:
| Candidate | Platform X | Platform Y |
|---|---|---|
| Harris | $0.33 | $0.37 | |
| DeSantis | $0.27 | $0.24 | |
| Newsom | $0.16 | $0.19 | |
| Haley | $0.14 | $0.11 | |
| Other | $0.13 | $0.14 |
(a) For each candidate, identify the lower price.
(b) If you buy each candidate at the lowest available price, what is the total cost?
(c) Since exactly one candidate wins (paying $1), is there an arbitrage? What is the profit?
(d) What real-world frictions might prevent this arbitrage?
Exercise 11: Arrow-Debreu Security Replication
Using the election market from Exercise 7, construct a portfolio that pays: - $5 if Harris wins - $2 if DeSantis wins - $0 otherwise
(a) How many contracts of each candidate do you need?
(b) What is the total cost of this portfolio?
(c) What is the expected payoff using the normalized probabilities?
(d) What is the expected profit or loss?
Exercise 12: Write a Python Class
Write a Python class MultiOutcomeMarket that:
- Takes a dictionary of {outcome: price} in the constructor.
- Has a method overround() returning the overround.
- Has a method normalized_probs() returning normalized probabilities.
- Has a method portfolio_pnl(holdings, winner) where holdings is {outcome: (quantity, cost)} and winner is the winning outcome.
- Include type hints and docstrings.
Test with the election data from Exercise 7.
Part C: Scalar Contracts (Exercises 13-18)
Exercise 13: Bracket Contract Payoffs
A GDP growth market has the following brackets:
| Bracket | Price |
|---|---|
| Below 0% | $0.04 |
| 0% to 1% | $0.09 |
| 1% to 2% | $0.22 |
| 2% to 3% | $0.38 |
| 3% to 4% | $0.18 |
| Above 4% | $0.07 |
(a) Calculate the price sum and overround.
(b) If GDP growth comes in at 2.5%, which bracket wins? What is the P&L if you bought that bracket at the listed price?
(c) Calculate the implied expected value of GDP growth (using bracket midpoints and normalized probabilities). Use 5% as the midpoint for "Above 4%" and -1% as the midpoint for "Below 0%".
(d) If you buy 100 contracts of "2% to 3%" at $0.38, what is your maximum profit and maximum loss?
Exercise 14: Linear Scalar Contract
A linear scalar contract on inflation has floor = 1%, ceiling = 6%, and current price = $0.52.
(a) What is the implied expected inflation rate?
(b) Calculate the payoff for actual inflation values of: 0%, 2%, 3.5%, 5%, 7%.
(c) If you buy at $0.52, calculate the P&L for each inflation value in (b).
(d) What is the break-even inflation value?
(e) What is the maximum profit and maximum loss?
Exercise 15: Bracket Design
You are designing a bracket market for "How many seats will Party A win?" The expected value is around 230 seats, with a range of roughly 200-260.
(a) Design 6 brackets that cover the full range and have reasonable granularity around the expected value.
(b) Explain why wider brackets at the tails and narrower brackets near the center is a good design.
(c) If the market prices your brackets uniformly at $0.167 each, what does this imply about the market's belief distribution?
Exercise 16: Recovering the Implied Distribution
Using the bracket prices from Exercise 13:
(a) Calculate the implied probability density for each finite bracket (probability / bracket width).
(b) Which bracket has the highest density? What does this mean?
(c) Sketch (describe) the shape of the implied distribution. Is it symmetric? Skewed?
(d) Compare this to a normal distribution with mean 2.3% and standard deviation 1.0%. How do they differ?
Exercise 17: Scalar Contract Strategies
You believe GDP growth will be between 1.5% and 2.5% with high probability, but the market seems to assign too much weight to the "3% to 4%" bracket.
(a) Describe a strategy using bracket contracts that profits from this view.
(b) Calculate the P&L for each possible bracket outcome if you buy 100 contracts of "1% to 2%" at $0.22, buy 100 contracts of "2% to 3%" at $0.38, and sell 100 contracts of "3% to 4%" at $0.18.
(c) What is your maximum profit? Maximum loss? In which bracket outcomes?
Exercise 18: Write a Python Function
Write a Python function bracket_expected_value(brackets) that:
- Takes a list of tuples (label, lower, upper, price) representing brackets.
- Returns the normalized expected value using bracket midpoints.
- For unbounded brackets (lower = -inf or upper = inf), require the caller to specify a midpoint via an optional parameter.
Test with the GDP brackets from Exercise 13.
Part D: Order Types and Execution (Exercises 19-24)
Exercise 19: Order Book Reading
Given this order book for a Yes contract:
ASKS (Sells):
$0.58 x 200
$0.56 x 100
$0.55 x 150
$0.54 x 50
BIDS (Buys):
$0.52 x 80
$0.51 x 120
$0.50 x 300
$0.48 x 500
(a) What is the best bid? Best ask? The spread?
(b) What is the midpoint price?
(c) If you place a market buy for 100 contracts, at what price(s) do you fill? What is the average fill price?
(d) If you place a market buy for 250 contracts, at what price(s) do you fill? What is the average fill price? What is the slippage vs. the best ask?
(e) If you place a limit buy for 200 contracts at $0.55, how many fill immediately? How many rest in the book?
Exercise 20: Order Type Selection
For each scenario, recommend the best order type (market, limit, stop, FOK, IOC, GTC) and explain why:
(a) You want to buy Yes contracts quickly because you believe a news announcement is imminent.
(b) You want to buy Yes contracts but only at $0.45 or below, and you are willing to wait.
(c) You hold a large Yes position and want to automatically sell if the price drops below $0.30.
(d) You want to buy exactly 500 contracts for a statistical analysis, and need exactly 500 (not partial fills).
(e) You want to buy as many contracts as are available at $0.42 right now, but do not want an unfilled order sitting in the book.
Exercise 21: Slippage Calculation
Using the order book from Exercise 19:
(a) Calculate the total cost and average price for market buys of 50, 100, 200, and 500 contracts.
(b) For each quantity, calculate the slippage relative to the best ask ($0.54).
(c) Plot (or describe) how slippage increases with order size.
(d) At what order size does the buyer exhaust all available ask liquidity?
Exercise 22: Spread Analysis
You are comparing two markets for the same event:
| Market | Best Bid | Best Ask | Daily Volume |
|---|---|---|---|
| Platform A | $0.48 | $0.52 | 5,000 | |
| Platform B | $0.50 | $0.51 | 50,000 |
(a) Calculate the spread and half-spread for each platform.
(b) If you want to do a round-trip trade (buy and then sell), what is the minimum cost on each platform (in terms of the spread)?
(c) Which platform would you prefer for a market order? For a limit order? Explain.
(d) What might explain the relationship between volume and spread?
Exercise 23: Time-in-Force Scenarios
You place a limit buy for 200 contracts at $0.45 on a book where only 80 contracts are available at or below $0.45.
Describe what happens under each time-in-force rule:
(a) Good-Til-Cancelled (GTC) (b) Fill-or-Kill (FOK) (c) Immediate-or-Cancel (IOC) (d) Day Order (assume it is 10 AM)
Exercise 24: Write a Python Order Book Simulator
Write a Python class SimpleOrderBook that:
- Maintains sorted lists of bids and asks.
- Has methods add_bid(price, qty) and add_ask(price, qty).
- Has a method market_buy(qty) that returns a list of (fill_price, fill_qty) tuples and the average fill price.
- Has a method market_sell(qty) that works similarly against bids.
- Has a property spread returning the bid-ask spread (or None if empty).
Test by recreating the order book from Exercise 19 and executing the trades from Exercise 21.
Part E: Position Management and Settlement (Exercises 25-30)
Exercise 25: Cost Basis Tracking
A trader makes the following trades on a Yes contract:
| Trade # | Action | Quantity | Price |
|---|---|---|---|
| 1 | Buy | 200 | $0.35 |
| 2 | Buy | 100 | $0.42 |
| 3 | Sell | 150 | $0.50 |
| 4 | Buy | 50 | $0.48 |
(a) After trades 1 and 2, what is the average cost basis? (Use the standard average cost method.)
(b) After trade 3, what is the realized P&L? What is the remaining quantity and average cost?
(c) After trade 4, what is the new average cost basis? How many contracts are held?
(d) If the current market price is $0.55, what is the unrealized P&L?
Exercise 26: Portfolio Valuation
A trader's portfolio contains:
| Contract | Outcome | Qty | Avg Cost | Current Price |
|---|---|---|---|---|
| Fed rate hike | Yes | 150 | $0.42 | $0.55 | |
| Election winner | Harris | 200 | $0.38 | $0.35 | |
| GDP growth | 2-3% bracket | 100 | $0.33 | $0.40 |
Cash balance: $350.00
(a) Calculate the unrealized P&L for each position.
(b) Calculate the total market value of all positions.
(c) Calculate the total equity (cash + position market value).
(d) Calculate the maximum possible portfolio value (if all positions resolve in the trader's favor).
(e) Calculate the minimum possible portfolio value (if all positions resolve against the trader).
Exercise 27: Margin Requirements
A prediction market platform requires full collateralization. For each position below, calculate the margin (capital) required:
(a) Buy 100 Yes contracts at $0.60.
(b) Sell (short) 100 Yes contracts at $0.60.
(c) Buy 50 contracts each of three different outcomes in a multi-outcome market at $0.25, $0.35, and $0.15 respectively.
(d) Explain why the sum of margins for a buyer and seller of the same contract always equals $1.00 per contract.
Exercise 28: Settlement Calculations
A multi-outcome election market resolves with Harris as the winner. Three traders have the following positions:
| Trader | Position | Qty | Avg Cost |
|---|---|---|---|
| Alice | Harris | 500 | $0.38 |
| Bob | DeSantis | 300 | $0.25 |
| Carol | Harris | 200 | $0.60 |
| Carol | Other | 100 | $0.10 |
(a) Calculate the settlement payout and net P&L for each trader.
(b) What is the total amount paid out by the platform?
(c) What is the total amount collected by the platform (from purchase prices)?
(d) Verify that total payouts are consistent with the total money in the system (accounting for the overround if any).
Exercise 29: Disputed Resolution
A contract asks: "Will the U.S. unemployment rate be below 4.0% in the March 2026 BLS report?" The initial BLS report says 3.9%, but one week later, a technical correction revises it to 4.0%.
(a) If the resolution criteria say "first release," how should this resolve?
(b) If the criteria say "final official figure," how should it resolve?
(c) If the criteria are ambiguous (just "BLS unemployment rate"), what arguments would each side make?
(d) What resolution mechanism (admin decision, community vote, escalation) would you recommend, and why?
(e) Write improved resolution criteria that would prevent this ambiguity.
Exercise 30: Comprehensive Lifecycle Simulation
Write a Python script that simulates the following complete lifecycle:
- Create a binary contract: "Will SpaceX launch Starship to orbit by June 2026?"
- Create a portfolio with $1,000 initial balance.
- Trader buys 200 Yes contracts at $0.35.
- Price moves to $0.50 — calculate unrealized P&L.
- Trader buys 100 more Yes contracts at $0.50.
- Price moves to $0.65 — calculate unrealized P&L.
- Trader sells 100 contracts at $0.65 — calculate realized P&L.
- Contract resolves Yes — settle the remaining position.
- Print a final portfolio summary showing total realized P&L, final cash balance, and total return.
Your script should use classes for BinaryContract, Portfolio, and Trade, and should print a clear log of every step.
Hints and Tips
- For arbitrage exercises, remember that transaction costs and platform differences can eliminate theoretical profits.
- When calculating average cost basis, always use the weighted average formula.
- For margin calculations, think about the maximum possible loss for each position.
- The overround represents the "house edge" — it is the cost of participating in the market.
- When comparing platforms, consider both explicit fees and implicit costs (spread, slippage).
Solutions are available in code/exercise-solutions.py.