diff --git a/crypto_seller/__init__.py b/crypto_seller/__init__.py index d0c82cc..144f530 100644 --- a/crypto_seller/__init__.py +++ b/crypto_seller/__init__.py @@ -195,7 +195,7 @@ def sample_from_range(rng: random.Random, rang: tuple[Any, Any]) -> Any: ROUND_TO_WHOLE = Decimal('1') -def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults: +def run_auto_sell(config: AutoSellConfig, skip_first:int=0) -> AutoSellRunResults: """Executes the sell-off. Sell-offs are performed in rounds of sizes and with intervals randomly @@ -214,7 +214,10 @@ def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults: ) logger.info('Currently own %s %s', input_amount_available, config.input_asset.raw_short_name()) - if input_amount_available > 0: + if skip_first > 0: + skip_first -= 1 + logger.info('Skipping this round') + elif 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) amount_to_sell = amount_to_sell.quantize(ROUND_TO_WHOLE, rounding=ROUND_DOWN) diff --git a/crypto_seller/__main__.py b/crypto_seller/__main__.py index 77d7262..5707180 100644 --- a/crypto_seller/__main__.py +++ b/crypto_seller/__main__.py @@ -12,6 +12,7 @@ import fin_depo from . import ( AutoSellConfig, + log_estimates, log_results, order_csv, run_auto_sell, @@ -97,6 +98,7 @@ def load_config(config_path: Path) -> AutoSellConfig: def parse_args(): parser = argparse.ArgumentParser('crypto_seller', description=CLI_DESCRIPTION) parser.add_argument('--config', type=Path, dest='config_file', required=True) + parser.add_argument('--skip-first', action='store_true', dest='skip_first') return parser.parse_args() @@ -107,11 +109,16 @@ def main(): logger.info('Initializing crypto_seller') args = parse_args() + # Load config auto_sell_config = load_config(args.config_file) + # Display estimates log_estimates(auto_sell_config) - results = run_auto_sell(auto_sell_config) + # Run auto sell + results = run_auto_sell(auto_sell_config, skip_first=args.skip_first and 1 or 0) + + # Display results logging.info('Sell-offs complete') log_results(results)