55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
import datetime
|
|
import logging
|
|
import logging.handlers
|
|
import time
|
|
from decimal import Decimal
|
|
|
|
import fin_defs
|
|
|
|
from . import PATH_LOG_FILE, AutoSellConfig, config, run_auto_sell
|
|
from . import logger as module_logger
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
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')
|
|
|
|
|
|
def main():
|
|
setup_logging()
|
|
logger.info('Initializing crypto_seller')
|
|
|
|
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,
|
|
seller=seller_backend,
|
|
sleep=time.sleep,
|
|
)
|
|
run_auto_sell(auto_sell_config)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|