コード例 #1
0
def generate_fee_info(fee):
    """Aux function for 'dep_get_with_fees_by_exch(exchange)' and
    'get_coin_fees(coin_id)'.
    Generates the formated content to be provided.
    """
    # If Fee Amount == None, return n/a
    if not is_number(fee.amount):
        return {"amount": 'n/a', "comments": None}
    # Generate fee string
    fee_str = fee.amount
    # Calculate fee info
    if fee.type == 'Percentage':
        fee_str = "{}%".format(fee.amount)
    else:
        fee_str = "{} {}".format(float_to_str(fee.amount), fee.scope)
    if fee.min_amount and is_number(fee.min_amount):
        try:
            symbol = Params.CURRENCY_SYMBOLS[fee.scope]
        except Exception as e:
            symbol = " {}".format(fee.scope)
        if symbol == '$':
            fee_str = "{}\n(Min: {}{})".format(fee_str, symbol, fee.min_amount)
        else:
            fee_str = "{}\n(Min: {}{})".format(fee_str, fee.min_amount, symbol)
    # Generate comments
    comments = None
    if fee.type == 'Less1kUSD':
        comments = 'Fee applied on deposits of less than a 1,000 USD'\
            ' equivalent'
    return {"amount": fee_str, "comments": comments}
コード例 #2
0
 def validate_orig_amt(self, orig_amt):
     if not orig_amt.data:
         raise ValidationError("Please, fill 'Amount'")
     if not is_number(orig_amt.data):
         raise ValidationError("Not a number")
     elif float(orig_amt.data) <= 0:
         raise ValidationError("Amount must be a positive number")
コード例 #3
0
 def store_fees(self, deposit_fee, withdraw_fee):
     if deposit_fee and deposit_fee[0] is not None:
         rounded_fee = round_amount_by_price(deposit_fee[0],
                                             self.trade.sell_coin.symbol)
         # Ensure that it is stored as a float
         if is_number(rounded_fee):
             self.deposit_fee = rounded_fee
         else:
             self.deposit_fee = str_2_float(rounded_fee)
     if withdraw_fee and withdraw_fee[0] is not None:
         rounded_fee = round_amount_by_price(withdraw_fee[0],
                                             self.trade.buy_coin.symbol)
         # Ensure that it is stored as a float
         if is_number(rounded_fee):
             self.withdraw_fee = rounded_fee
         else:
             self.withdraw_fee = str_2_float(rounded_fee)