1
0

Estimates will now be logged during startup
All checks were successful
Test Python / Test (push) Successful in 28s

This commit is contained in:
Jon Michael Aanes 2024-09-04 15:36:00 +02:00
parent 97369e0b74
commit 1d7327fe6a
4 changed files with 57 additions and 2 deletions

View File

@ -212,7 +212,7 @@ 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)
@ -251,6 +251,52 @@ def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults:
)
def log_estimates(config: AutoSellConfig):
current_balance = config.seller.get_depo().get_amount_of_asset(
config.input_asset,
)
average_sleep = (config.interval_range[0] + config.interval_range[1]) / 2
average_amount = (config.input_amount_range[0] + config.input_amount_range[1]) / 2
expected_num_sell_offs = current_balance / average_amount
expected_duration = average_sleep * float(expected_num_sell_offs)
fastest_duration = config.interval_range[0] * float(current_balance / config.input_amount_range[1])
slowest_duration = config.interval_range[1] * float(current_balance / config.input_amount_range[0])
logger.info('Welcome to crypto seller!')
config.sleep(1)
logger.info('')
config.sleep(1)
logger.info('I, the great crypto seller, your humble servant, will')
logger.info('now analyse your configuration and divine some estimates!')
config.sleep(1)
logger.info('')
config.sleep(1)
logger.info('- Current balance: %s %s', current_balance, config.input_asset.raw_short_name())
config.sleep(1)
logger.info('- Average sleep: %s seconds', average_sleep)
config.sleep(1)
logger.info('- Average amount: %s %s', average_amount, config.input_asset.raw_short_name())
config.sleep(1)
logger.info('- Expected counts: %s', expected_num_sell_offs)
config.sleep(1)
logger.info('- Expected time: %s', expected_duration)
config.sleep(1)
logger.info('- Fastest time: %s', fastest_duration)
config.sleep(1)
logger.info('- Slowest time: %s', slowest_duration)
config.sleep(1)
logger.info('')
config.sleep(1)
logger.info('Do you still want to proceed?')
config.sleep(1)
logger.info('If not, press CTRL+C within the next 10 seconds...')
config.sleep(10)
logger.info('')
def log_results(results: AutoSellRunResults):
logger.info('Stats:')
logger.info('- Num orders: %s', len(results.order_details))

View File

@ -108,6 +108,9 @@ def main():
args = parse_args()
auto_sell_config = load_config(args.config_file)
log_estimates(auto_sell_config)
results = run_auto_sell(auto_sell_config)
logging.info('Sell-offs complete')
log_results(results)

3
pytest.ini Normal file
View File

@ -0,0 +1,3 @@
[pytest]
log_cli = True
log_level=INFO

View File

@ -8,6 +8,7 @@ import fin_depo
import crypto_seller
import crypto_seller.order_csv
import pytest
class SellerMock(fin_depo.data.DepoFetcher):
def __init__(self, asset: fin_defs.Asset, initial_amount: Decimal):
@ -70,6 +71,8 @@ def test_auto_run():
sleep=sleep_mock,
)
crypto_seller.log_estimates(config)
results = crypto_seller.run_auto_sell(config)
# Check results
@ -80,4 +83,4 @@ def test_auto_run():
# Check mocks agree
assert seller_mock.amount_left == 0
assert sleep_mock.time_slept == 1000
assert sleep_mock.time_slept == 1000 + 23