Exemple #1
0
def alpha_as_beta(beta, r=R, sigma2=SIGMA2, check_tol=1e-8):
    '''alpha as beta so that hedge fund manager is indifferent'''

    assert beta * T <= BETA_UPPER_BOUND
    assert BETA0 == 0, "Formula only applies to the case where BETA0 is 0!"

    _f_func = common._f_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)
    _g_func = common._g_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)

    deltat = DELTA * T

    numerator = term2(BETA0, r=r, sigma2=sigma2) - \
                term2(beta, r=r, sigma2=sigma2) + \
                term3(BETA0, r=r, sigma2=sigma2) - \
                term3(beta, r=r, sigma2=sigma2)
    denominator = T * (_f_func(1 + deltat) - deltat * _g_func(1 + deltat))
    alpha = ALPHA0 + numerator / denominator

    assert alpha * T <= ALPHA_UPPER_BOUND
    assert abs(option_px(alpha, beta, r=r, sigma2=sigma2)- \
               option_px(ALPHA0, BETA0, r=r, sigma2=sigma2)) < check_tol

    return alpha
Exemple #2
0
def eterm1(alpha, mu=MU, sigma2=SIGMA2):
    '''Term 1 for expectation'''

    deltat = DELTA * T
    alphat = alpha * T

    _f_func = common._f_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _g_func = common._g_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)

    term1a = (1-alphat)*_f_func(1+deltat)
    term1b = deltat*(1-alphat)*_g_func(1+deltat)
    return term1a - term1b
Exemple #3
0
def eterm3(beta, mu=MU, sigma2=SIGMA2):
    '''Term 3 for expectation'''

    betat = beta * T
    deltat = DELTA * T

    _f_func = common._f_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _g_func = common._g_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)

    ksi = 1-betat+deltat
    term3a = np.exp(mu*T) - _f_func(ksi)
    term3b = (betat-deltat)*(1-_g_func(ksi))
    return term3a + term3b
Exemple #4
0
def term2(beta, r=R, sigma2=SIGMA2):
    '''Term 2'''

    betat = beta * T
    deltat = DELTA * T

    _f_func = common._f_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)
    _g_func = common._g_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)

    term2a = _f_func(1 - betat + deltat) - _g_func(1 - betat + deltat)
    term2b = _f_func(1 + deltat) - _g_func(1 + deltat)
    return term2a - term2b
Exemple #5
0
def term1(alpha, r=R, sigma2=SIGMA2):
    '''Term 1'''

    deltat = DELTA * T
    alphat = alpha * T

    _f_func = common._f_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)
    _g_func = common._g_func_generator(mean=(r - 0.5 * sigma2) * T,
                                       sigma2=sigma2 * T)

    term1a = alphat * (_f_func(1 + deltat) - deltat * _g_func(1 + deltat))
    term1b = deltat * _g_func(1 + deltat)
    return term1a + term1b
Exemple #6
0
def sterm1(alpha, mu=MU, sigma2=SIGMA2):
    '''Term 1 for second-order moment'''

    deltat = DELTA * T
    alphat = alpha * T

    _f_func = common._f_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _g_func = common._g_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)

    term1a = (1-alphat)*(1-alphat)*_h_func(1+deltat)
    term1b = 2*deltat*(1-alphat)*(1-alphat)*_f_func(1+deltat)
    term1c = deltat*deltat*(1-alphat)*(1-alphat)*_g_func(1+deltat)

    return term1a - term1b + term1c
Exemple #7
0
def sterm3(beta, mu=MU, sigma2=SIGMA2):
    '''Term 3 for second-order moment'''

    betat = beta * T
    deltat = DELTA * T

    _f_func = common._f_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _g_func = common._g_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _h_func = common._h_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)

    ksi = 1-betat+deltat
    term3a = np.exp(2*mu*T+SIGMA2*T) - _h_func(ksi)
    term3b = 2*(betat-deltat)*(np.exp(mu*T)-_f_func(ksi))
    term3c = (betat-deltat) * (betat-deltat) * (1-_g_func(ksi))
    return term3a + term3b + term3c
Exemple #8
0
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 22 09:50:02 2017

@author: Yixian
"""

import numpy as np
import common

from common import (DELTA, T, X_0)

MU = 0.1 #10%
SIGMA2 = 0.4*0.4 # 40%

_f_func = common._f_func_generator(mean=(MU-0.5*SIGMA2)*T, sigma2=SIGMA2*T)
_g_func = common._g_func_generator(mean=(MU-0.5*SIGMA2)*T, sigma2=SIGMA2*T)
_h_func = common._h_func_generator(mean=(MU-0.5*SIGMA2)*T, sigma2=SIGMA2*T)

def eterm1(alpha, mu=MU, sigma2=SIGMA2):
    '''Term 1 for expectation'''

    deltat = DELTA * T
    alphat = alpha * T

    _f_func = common._f_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)
    _g_func = common._g_func_generator(mean=(mu-0.5*sigma2)*T, sigma2=sigma2*T)

    term1a = (1-alphat)*_f_func(1+deltat)
    term1b = deltat*(1-alphat)*_g_func(1+deltat)
    return term1a - term1b