1
0
crypto-seller/crypto_seller/__main__.py

53 lines
1.4 KiB
Python
Raw Normal View History

2024-07-17 20:21:58 +00:00
import datetime
import logging
import logging.handlers
2024-07-17 20:21:58 +00:00
from decimal import Decimal
2024-07-22 11:31:53 +00:00
import time
2024-07-17 20:21:58 +00:00
import fin_defs
2024-07-17 20:21:58 +00:00
2024-07-22 11:21:41 +00:00
from . import config
from . import PATH_LOG_FILE, AutoSellConfig, run_auto_sell
from . import logger as module_logger
2024-07-17 20:21:58 +00:00
logger = logging.getLogger(__name__)
2024-07-22 11:21:41 +00:00
def setup_logging():
PATH_LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
file_handler = logging.handlers.WatchedFileHandler(filename=PATH_LOG_FILE)
file_handler.setFormatter(
logging.Formatter(
'%(levelname)s:%(asctime)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S',
),
)
logging.basicConfig(handlers=[logging.StreamHandler(), file_handler])
logger.setLevel('INFO')
module_logger.setLevel('INFO')
2024-07-22 11:21:41 +00:00
def main():
setup_logging()
2024-07-17 20:21:58 +00:00
logger.info('Initializing crypto_seller')
2024-07-22 11:21:41 +00:00
seller_backend = fin_depo.defi_kucoin.KucoinDepoFetcher(
kucoin_secret=config.KUCOIN_SECRET,
kucoin_key=config.KUCOIN_KEY,
kucoin_pass=config.KUCOIN_PASS,
)
auto_sell_config = AutoSellConfig(
input_amount_range=(Decimal('0.5'), Decimal('1')),
interval_range=(datetime.timedelta(seconds=2), datetime.timedelta(seconds=6)),
input_asset=fin_defs.MPC,
output_asset=fin_defs.USDT,
exit_when_empty=True,
2024-07-22 11:31:53 +00:00
seller = seller_backend,
sleep = time.sleep
2024-07-17 20:21:58 +00:00
)
2024-07-22 11:31:53 +00:00
run_auto_sell(auto_sell_config)
2024-07-17 20:21:58 +00:00
2024-07-17 20:21:58 +00:00
if __name__ == '__main__':
main()