danghungithp's picture
Upload 1398 files
bec48e1 verified
import numpy as np
from scipy.stats import norm
def calculate_covered_warrant_profit(stock_price, strike_price, warrant_price, conversion_ratio):
"""
Calculates the profit and break-even price for a covered warrant.
Args:
stock_price (float): Current price of the underlying stock (S).
strike_price (float): The strike price of the warrant (X).
warrant_price (float): The price of one warrant (Price).
conversion_ratio (float): The conversion ratio (N).
Returns:
dict: A dictionary containing the 'profit' and 'break_even_price'.
"""
# Lãi/Lỗ mỗi cổ phiếu cơ sở = (Giá trị nội tại) - (Chi phí mua chứng quyền)
# Giá trị nội tại = Giá cổ phiếu cơ sở - Giá thực hiện
# Chi phí mua chứng quyền = Giá chứng quyền * Tỷ lệ chuyển đổi
profit = (stock_price - strike_price) - (warrant_price * conversion_ratio)
# Giá hòa vốn là giá của cổ phiếu cơ sở mà tại đó nhà đầu tư không lãi cũng không lỗ.
# Tại điểm hòa vốn, Lãi/Lỗ = 0
# => (Giá hòa vốn - Giá thực hiện) - (Giá chứng quyền * Tỷ lệ chuyển đổi) = 0
# => Giá hòa vốn = Giá thực hiện + (Giá chứng quyền * Tỷ lệ chuyển đổi)
break_even_price = strike_price + (warrant_price * conversion_ratio)
return {
'profit': profit,
'break_even_price': break_even_price
}
def black_scholes_price(S, X, T, r, v, conversion_ratio):
"""
Calculates the theoretical price of a covered warrant using the Black-Scholes model.
Args:
S (float): Current price of the underlying stock.
X (float): Strike price of the warrant.
T (float): Time to expiration in years.
r (float): Risk-free interest rate.
v (float): Volatility of the underlying stock's returns.
conversion_ratio (float): The conversion ratio of the warrant.
Returns:
float: The theoretical price of one covered warrant.
"""
if T <= 0 or v <= 0:
# If time has expired or volatility is zero, the value is its intrinsic value
intrinsic_value = max(0, S - X)
return intrinsic_value / conversion_ratio
d1 = (np.log(S / X) + (r + 0.5 * v**2) * T) / (v * np.sqrt(T))
d2 = d1 - v * np.sqrt(T)
# Calculate the price of a standard call option
call_price = (S * norm.cdf(d1) - X * np.exp(-r * T) * norm.cdf(d2))
# Adjust for the conversion ratio
warrant_price = call_price / conversion_ratio
return warrant_price