Implement transaction handling
This commit is contained in:
@@ -111,26 +111,25 @@ class Money(object):
|
||||
return rates
|
||||
|
||||
# TODO: pass platform
|
||||
# async def get_acceptable_margins(self, platform, currency, amount):
|
||||
# """
|
||||
# Get the minimum and maximum amounts we would accept a trade for.
|
||||
# :param currency: currency code
|
||||
# :param amount: amount
|
||||
# :return: (min, max)
|
||||
# :rtype: tuple
|
||||
# """
|
||||
# sets = util.get_settings(platform)
|
||||
# rates = await self.get_rates_all()
|
||||
# if currency == "USD":
|
||||
# min_amount = amount - float(sets.AcceptableUSDMargin)
|
||||
# max_amount = amount + float(sets.AcceptableUSDMargin)
|
||||
# return (min_amount, max_amount)
|
||||
# amount_usd = amount / rates[currency]
|
||||
# min_usd = amount_usd - float(sets.AcceptableUSDMargin)
|
||||
# max_usd = amount_usd + float(sets.AcceptableUSDMargin)
|
||||
# min_local = min_usd * rates[currency]
|
||||
# max_local = max_usd * rates[currency]
|
||||
# return (min_local, max_local)
|
||||
async def get_acceptable_margins(self, platform, currency, amount):
|
||||
"""
|
||||
Get the minimum and maximum amounts we would accept a trade for.
|
||||
:param currency: currency code
|
||||
:param amount: amount
|
||||
:return: (min, max)
|
||||
:rtype: tuple
|
||||
"""
|
||||
rates = await self.get_rates_all()
|
||||
if currency == "USD":
|
||||
min_amount = amount - platform.accept_within_usd
|
||||
max_amount = amount + platform.accept_within_usd
|
||||
return (min_amount, max_amount)
|
||||
amount_usd = amount / rates[currency]
|
||||
min_usd = amount_usd - platform.accept_within_usd
|
||||
max_usd = amount_usd + platform.accept_within_usd
|
||||
min_local = min_usd * rates[currency]
|
||||
max_local = max_usd * rates[currency]
|
||||
return (min_local, max_local)
|
||||
|
||||
async def get_minmax(self, min_usd, max_usd, asset, currency):
|
||||
rates = await self.get_rates_all()
|
||||
|
||||
Reference in New Issue
Block a user