1
0

Added --skip-first command line argument
All checks were successful
Test Python / Test (push) Successful in 27s

This commit is contained in:
Jon Michael Aanes 2024-09-04 17:35:03 +02:00
parent 1d7327fe6a
commit c8ce383751
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 13 additions and 3 deletions

View File

@ -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)

View File

@ -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)