Ejemplo n.º 1
0
def price(request):
    if not request.user.is_superuser:
        profile = UserProfile.objects.get(user=request.user)
        calls = profile.calls
        if profile.get_remaining() > 0:
            profile.calls += 1
            profile.save()
        else:
            return redirect('purchase.html')
    else:
        calls = 0
    model = str(request.GET.get('model','laplace'))
    days = int(request.GET.get('days', ''))
    strike = float(request.GET.get('strike', ''))
    ticker = request.GET.get('ticker', '').upper()
    putcall = request.GET.get('type', '')
    f = futurePrice.futurePrice(request.GET.get('ticker', ''))
    x = 0
    for i in range(ITERATIONS):
        x = x + futurePrice.price(f, days, strike, putcall[0], model)
    value = x / ITERATIONS
    response_data = {'ticker': str(ticker),
                     'days': str(days),
                     'strike': str(strike),
                     'type': putcall,
                     'price': round(value, 3),
                     'calls': calls}
    return JsonResponse(response_data)
Ejemplo n.º 2
0
def gen():
    print(sum([price(f, 100, 780) for i in range(ITERATIONS)]) / ITERATIONS)
Ejemplo n.º 3
0
def loop():
    x = 0
    for i in range(ITERATIONS):
        x = x + price(f, 100, 780)
    print(x / ITERATIONS)
Ejemplo n.º 4
0
def parPrice(i):
    return price(*i)