Example #1
0
def get_arithmetic_asian_option(request):
    S0 = float(request.GET.get("spot_price"))
    V = float(request.GET.get("volatility"))
    R = float(request.GET.get("rate"))
    T = float(request.GET.get("maturity"))
    K = float(request.GET.get("strike_price"))
    geo_K = K
    option_type = request.GET.get("option_type")
    N = float(request.GET.get("observation_num"))
    path_num = int(request.GET.get("path_num"))
    control_variate = request.GET.get("control_variate")
    price, std, confcv = project.arithmetic_asian_option(K, geo_K, T, R, V, S0, N, option_type, path_num,
                                                         control_variate)
    return HttpResponse(str(price) + ':' + str(confcv))
    s = time.time()

    S = S0 = S1 = S2 = 100.0
    T = 3.0
    R = 0.05
    V = V1 = V2 = 0.3
    K = 100.0
    n = 50.0
    rou = 0.5
    m = 10000

    print GPU_arithmetic_asian_option(K, K, T, R, V, S0, n, 1.0, path_num=100, control_variate=STANDARD, Quasi=True)

    import project

    print project.arithmetic_asian_option(K, K, T, R, V, S0, n, 'call', path_num=100, control_variate=STANDARD)

    e = time.time()
    print "use", e - s

    s = time.time()
    print standardMC_european_option(K, T, R, V, S0, n, 'call', path_num=100000)
    e = time.time()
    print "use", e - s

    print project.bs(S0, K, T, V, R, 'call')
    s = time.time()
    print GPU_european_option(K, T, R, V, S0, n, 1.0, path_num=100000, Quasi=True)
    e = time.time()
    print "use", e - s