Quantize to avoid issues with kucoin
This commit is contained in:
parent
59cb798f7d
commit
0f4397d9e5
|
@ -129,6 +129,11 @@ from ._version import __version__
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
################################################################################
|
||||
# Constants
|
||||
|
||||
QUANTIZE_DECIMALS = Decimal('1.00')
|
||||
|
||||
################################################################################
|
||||
# Main code #
|
||||
|
||||
|
@ -192,6 +197,7 @@ def sample_from_range(rng: random.Random, rang: tuple[Any, Any]) -> Any:
|
|||
return rang[0] + (rang[1] - rang[0]) * multiplier
|
||||
|
||||
|
||||
|
||||
def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults:
|
||||
"""Executes the sell-off.
|
||||
|
||||
|
@ -209,12 +215,13 @@ def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults:
|
|||
input_amount_available = config.seller.get_depo().get_amount_of_asset(
|
||||
config.input_asset,
|
||||
)
|
||||
logger.info('Currently own %s %s', input_amount_available, config.input_asset)
|
||||
logger.info('Currently own %s %s', input_amount_available, config.input_asset.raw_short_name())
|
||||
|
||||
if input_amount_available > 0:
|
||||
amount_to_sell = sample_from_range(rng, config.input_amount_range)
|
||||
amount_to_sell = min(input_amount_available, amount_to_sell)
|
||||
logger.info('Attempting to sell %s %s', amount_to_sell, config.input_asset)
|
||||
amount_to_sell = amount_to_sell.quantize(QUANTIZE_DECIMALS)
|
||||
logger.info('Selling %s %s', amount_to_sell, config.input_asset.raw_short_name())
|
||||
|
||||
order_details = config.seller.place_market_order(
|
||||
fin_defs.AssetAmount(config.input_asset, amount_to_sell),
|
||||
|
|
Loading…
Reference in New Issue
Block a user