From 684e08de0432b9bb2876b8f8ceb1fec1b47ddcad Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 2 Dec 2024 18:18:20 +0100 Subject: [PATCH] Fixed logging --- crypto_seller/__init__.py | 9 ++++----- crypto_seller/order_csv.py | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/crypto_seller/__init__.py b/crypto_seller/__init__.py index 66c4cf0..95d10c6 100644 --- a/crypto_seller/__init__.py +++ b/crypto_seller/__init__.py @@ -232,7 +232,7 @@ def run_auto_sell( if initial_rounds_to_skip > 0: initial_rounds_to_skip -= 1 - logger.info('skipping this round') + 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) @@ -241,14 +241,13 @@ def run_auto_sell( rounding=ROUND_DOWN, ) logger.info( - 'Attempting to sell %s %s', + 'Selling %s %s', amount_to_sell, - config.input_asset, + config.input_asset.raw_short_name(), ) order_details = config.seller.place_market_order( - config.input_asset, - amount_to_sell, + fin_defs.AssetAmount(config.input_asset, amount_to_sell), config.output_asset, ) diff --git a/crypto_seller/order_csv.py b/crypto_seller/order_csv.py index c73690a..7155b43 100644 --- a/crypto_seller/order_csv.py +++ b/crypto_seller/order_csv.py @@ -26,18 +26,24 @@ class CsvFileLogger: 'raw_order_details', ] + # Select data to write + d = { + 'executed_time': trade_order.executed_time, + 'input_asset': trade_order.input.asset, + 'input_amount': trade_order.input.amount, + 'output_asset': trade_order.output.asset, + 'output_amount': trade_order.output.amount, + 'fee_asset': trade_order.fee.asset, + 'fee_amount': trade_order.fee.amount, + 'order_id': trade_order.order_id, + 'raw_order_details': trade_order.raw_order_details, + } + # Ensure that directory exists self.path.parent.mkdir(parents=True, exist_ok=True) # Write row in CSV file with open(self.path, 'a') as f: writer = csv.DictWriter(f, fieldnames=fieldnames) - d = trade_order.__dict__ - d['input_asset'] = d['input'].asset - d['input_amount'] = d['input'].amount - d['output_asset'] = d['output'].asset - d['output_amount'] = d['output'].amount - d['fee_asset'] = d['fee'].asset - d['fee_amount'] = d['fee'].amount - del d['fee'], d['input'], d['output'] writer.writerow(d) + del d