示例#1
0
def calculateSaleReturnTest(_supply, _reserveBalance, _reserveRatio,
                            _sellAmount):
    fixed = calculateSaleReturn(_supply, _reserveBalance, _reserveRatio,
                                _sellAmount)
    real = Decimal(_reserveBalance) * (
        1 - (1 - Decimal(_sellAmount) / Decimal(_supply))**
        (100 / Decimal(_reserveRatio)))
    return fixed, real
def formulaTest(_supply, _reserveBalance, _reserveRatio, _amount):
    _new_amount = calculatePurchaseReturn(_supply, _reserveBalance, _reserveRatio, _amount)
    _old_amount = calculateSaleReturn(_supply+_new_amount, _reserveBalance+_amount, _reserveRatio, _new_amount)	
    if _old_amount > _amount:
        error = []
        error.append('error occurred on:')
        error.append('_supply         = {}'.format(_supply))
        error.append('_reserveBalance = {}'.format(_reserveBalance))
        error.append('_reserveRatio   = {}'.format(_reserveRatio))
        error.append('_amount         = {}'.format(_amount))
        raise BaseException('\n'.join(error))
    return float(Decimal(_old_amount) / Decimal(_amount))
示例#3
0
def formulaTest(supply,reserve,ratio,amount):
    newAmount = calculatePurchaseReturn(supply,reserve,ratio,amount)
    oldAmount = calculateSaleReturn(supply+newAmount,reserve+amount,ratio,newAmount)
    if oldAmount > amount:
        error = []
        error.append('error occurred on:')
        error.append('supply  = {}'.format(supply))
        error.append('reserve = {}'.format(reserve))
        error.append('ratio   = {}'.format(ratio))
        error.append('amount  = {}'.format(amount))
        raise BaseException('\n'.join(error))
    return Decimal(oldAmount)/amount
示例#4
0
def formulaTest(_supply, _reserveBalance, _reserveRatio, _amount):
    fixed = calculateSaleReturn(_supply, _reserveBalance, _reserveRatio, _amount)
    real  = Decimal(_reserveBalance)*(1-(1-Decimal(_amount)/Decimal(_supply))**(100/Decimal(_reserveRatio)))
    if fixed > real:
        error = []
        error.append('error occurred on:')
        error.append('_supply         = {}'.format(_supply))
        error.append('_reserveBalance = {}'.format(_reserveBalance))
        error.append('_reserveRatio   = {}'.format(_reserveRatio))
        error.append('_amount         = {}'.format(_amount))
        error.append('fixed result    = {}'.format(fixed))
        error.append('real  result    = {}'.format(real))
        raise BaseException('\n'.join(error))
    return float(fixed / real)
示例#5
0
def formulaTest(supply, reserve, ratio, amount):
    fixed = Decimal(calculateSaleReturn(supply, reserve, ratio, amount))
    real = Decimal(reserve) * (1 - (1 - Decimal(amount) / Decimal(supply))**
                               (100 / Decimal(ratio)))
    if fixed > real:
        error = []
        error.append('error occurred on:')
        error.append('supply  = {}'.format(supply))
        error.append('reserve = {}'.format(reserve))
        error.append('ratio   = {}'.format(ratio))
        error.append('amount  = {}'.format(amount))
        error.append('fixed   = {}'.format(fixed))
        error.append('real    = {}'.format(real))
        raise BaseException('\n'.join(error))
    return fixed / real
示例#6
0
def formulaTest(_supply, _reserveBalance, _reserveRatio, _amount):
    fixed = calculateSaleReturn(_supply, _reserveBalance, _reserveRatio,
                                _amount)
    real = Decimal(_reserveBalance) * (
        1 - (1 - Decimal(_amount) / Decimal(_supply))**
        (100 / Decimal(_reserveRatio)))
    if fixed > real:
        error = []
        error.append('error occurred on:')
        error.append('_supply         = {}'.format(_supply))
        error.append('_reserveBalance = {}'.format(_reserveBalance))
        error.append('_reserveRatio   = {}'.format(_reserveRatio))
        error.append('_amount         = {}'.format(_amount))
        error.append('fixed result    = {}'.format(fixed))
        error.append('real  result    = {}'.format(real))
        raise BaseException('\n'.join(error))
    return float(fixed / real)