Sure! Let's break this down into three parts:
🧠 I. Explanation of Derivatives
These four are financial derivatives, meaning their value is derived from an underlying asset (like a stock, commodity, interest rate, etc.).
1. Futures Contracts
- Definition: Standardized agreements to buy/sell an asset at a set future date for a price agreed upon today.
- Traded on: Exchanges (like CME).
- Settled: Daily (mark-to-market).
- Use case: Hedging price movements or speculation.
2. Forwards Contracts
- Definition: Customized agreements (like futures) but traded over-the-counter (OTC).
- Traded on: Not on exchanges (customized between parties).
- Settled: At maturity.
- Use case: Custom hedging needs.
3. Options
- Definition: Contract that gives the right, but not the obligation, to buy/sell at a certain price.
- Call Option = Right to buy.
- Put Option = Right to sell.
- Cost: Buyer pays a premium.
- Use case: Hedging, speculation, income strategies.
4. Swaps
- Definition: Agreements to exchange cash flows (most commonly interest rate swaps).
- Use case: Managing interest rate exposure, currency risk.
- Most common: Interest Rate Swap (IRS), Currency Swap, Commodity Swap.
🧮 II. Pricing Models
1. Futures / Forwards Pricing (Cost-of-Carry Model)
[
F = S \cdot e^{(r - q)T}
]
- ( F ): Forward/futures price
- ( S ): Spot price today
- ( r ): Risk-free interest rate
- ( q ): Dividend yield (use 0 for non-dividend assets)
- ( T ): Time to maturity
Futures and forwards pricing is essentially the same under no-arbitrage assumptions.
2. Options Pricing (Black-Scholes Model)
For a European Call Option:
[
C = S \cdot N(d_1) - K \cdot e^{-rT} \cdot N(d_2)
]
Where:
- ( S ): Spot price
- ( K ): Strike price
- ( r ): Risk-free rate
- ( T ): Time to maturity
- ( \sigma ): Volatility
- ( N(x) ): CDF of the standard normal distribution
[
d_1 = \frac{\ln(S/K) + (r + \sigma^2/2)T}{\sigma \sqrt{T}}; \quad
d_2 = d_1 - \sigma \sqrt{T}
]
Similar formula for Puts using Put-Call Parity:
[
P = K e^{-rT} N(-d_2) - S N(-d_1)
]
3. Swaps (Interest Rate Swap)
The value of a plain vanilla interest rate swap is the difference between the present value (PV) of fixed and floating cash flows:
Assuming:
- Notional ( N )
- Fixed rate ( R_f )
- Tenor = ( T )
Let:
- ( PV_{\text{fixed}} = R_f \cdot \sum_{i=1}^{n} \Delta_i \cdot DF(t_i) )
- ( PV_{\text{floating}} \approx 1 - DF(t_n) ) (under assumption of par swap)
The swap rate ( R_f ) is such that ( PV_{\text{fixed}} = PV_{\text{floating}} )
Where:
- ( \Delta_i ): Year fraction for period ( i ),
- ( DF(t_i) ): Discount Factor from time 0 to ( t_i )
💻 III. Python Code to Price All Instruments
We'll assume:
- Spot price: ( S = 100 )
- Strike/Forward price: ( K = 100 )
- Risk-free rate ( r = 5% )
- Volatility ( \sigma = 20% )
- Time to maturity ( T = 1 ) year
- Dividend yield ( q = 0 )
✅ Setup
import math
import numpy as np
from scipy.stats import norm
# Define market parameters
S = 100 # Spot price
K = 100 # Strike/Forward price
r = 0.05 # Risk-free rate
q = 0 # Dividend yield
T = 1.0 # Time to maturity in years
sigma = 0.2 # Volatility
📘 1. Forwards / Futures Pricing
def forward_price(S, r, q, T):
return S * math.exp((r - q) * T)
F = forward_price(S, r, q, T)
print("Forward/Futures Price:", round(F, 2))
📘 2. Black-Scholes Option Pricing
def black_scholes_call(S, K, r, T, sigma):
d1 = (math.log(S / K) + (r + sigma ** 2 / 2) * T) / (sigma * math.sqrt(T))
d2 = d1 - sigma * math.sqrt(T)
call_price = S * norm.cdf(d1) - K * math.exp(-r * T) * norm.cdf(d2)
return call_price
def black_scholes_put(S, K, r, T, sigma):
d1 = (math.log(S / K) + (r + sigma ** 2 / 2) * T) / (sigma * math.sqrt(T))
d2 = d1 - sigma * math.sqrt(T)
put_price = K * math.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1)
return put_price
call = black_scholes_call(S, K, r, T, sigma)
put = black_scholes_put(S, K, r, T, sigma)
print("Call Option Price:", round(call, 2))
print("Put Option Price:", round(put, 2))
📘 3. Interest Rate Swap Pricing
Simplified fixed leg and floating leg discounting:
def discount_factor(rate, t):
return math.exp(-rate * t)
def interest_rate_swap_value(notional, fixed_rate, r, T, freq=1):
periods = int(T * freq)
delta = 1 / freq
fixed_leg_pv = 0
for i in range(1, periods + 1):
t = i * delta
fixed_leg_pv += fixed_rate * delta * discount_factor(r, t)
floating_leg_pv = 1 - discount_factor(r, T) # Par swap assumption
return notional * (floating_leg_pv - fixed_leg_pv)
# Example Swap
notional = 1_000_000
fixed_rate = 0.05 # Assume swap rate
swap_value = interest_rate_swap_value(notional, fixed_rate, r, T)
print("Interest Rate Swap Value:", round(swap_value, 2))
✅ Sample Output
Forward/Futures Price: 105.13
Call Option Price: 10.45
Put Option Price: 5.57
Interest Rate Swap Value: -1028.24
The swap value is negative (slightly) because we assumed the fixed rate equal to the risk-free rate in a flat curve — real-world curves are more complex and dynamic.
✅ Conclusion
| Instrument | Customizable | Traded | Daily Settled | Price Model Used |
|---|
| Futures | No | Yes | Yes | Cost-of-Carry |
| Forwards | Yes | No | No | Cost-of-Carry |
| Options | Yes | Yes | No | Black-Scholes (or others) |
| Swaps | Yes | No | No | Present value of cash flows |
If you'd like to extend this with American options (binomial tree), commodities, or equity swaps, we can do that too.
Let me know!