示例#1
0
def bs_euro(request):
    spot_price = request.GET.get("spot_price")
    volatility = request.GET.get("volatility")
    rate = request.GET.get("rate")
    maturity = request.GET.get("maturity")
    strike_price = request.GET.get("strike_price")
    option_type = request.GET.get("option_type")
    price = project.bs(spot_price, strike_price, maturity, volatility, rate, option_type)
    return HttpResponse(price)
    s = time.time()

    S = S0 = S1 = S2 = 100.0
    T = 3.0
    R = 0.05
    V = V1 = V2 = 0.3
    geo_K = 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=False)
    #
    import project
    #
    # # print project.arithmetic_asian_option(K, K, T, R, V, S0, n, 'call', path_num=100, control_variate=GEO_MEAN)
    #
    # e = time.time()
    # print "use", e - s
    #
    # print GPU_arithmetic_basket_option(S1, S2, V1, V2, R, T, K, geo_K, rou, 1.0, path_num=10000,
    #                              control_variate=GEO_MEAN_STRIKE, Quasi=False)

    print standardMC_european_option(K, T, R, V, S0, n, 1.0, path_num=10000)

    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=False)
    # e = time.time()
    # print "use", e - s