def main(): api_key = config.get(USER_CFG_SECTION, 'api_key') api_secret_key = config.get(USER_CFG_SECTION, 'api_secret_key') tld = config.get(USER_CFG_SECTION, 'tld') client = BinanceAPIManager(api_key, api_secret_key, tld, logger) logger.info("Creating database schema if it doesn't already exist") create_database() set_coins(supported_coin_list) migrate_old_state() initialize_trade_thresholds(client) initialize_current_coin(client) schedule = SafeScheduler(logger) schedule.every(SCOUT_SLEEP_TIME).seconds.do( scout, client=client, transaction_fee=SCOUT_TRANSACTION_FEE, multiplier=SCOUT_MULTIPLIER).tag("scouting") schedule.every(1).minutes.do(update_values, client=client).tag("updating value history") schedule.every(1).minutes.do( prune_scout_history, hours=SCOUT_HISTORY_PRUNE_TIME).tag("pruning scout history") schedule.every(1).hours.do(prune_value_history).tag( "pruning value history") while True: schedule.run_pending() time.sleep(1)
def main(): api_key = config.get(USER_CFG_SECTION, 'api_key') api_secret_key = config.get(USER_CFG_SECTION, 'api_secret_key') tld = config.get(USER_CFG_SECTION, 'tld') or 'com' # Default Top-level domain is 'com' client = BinanceAPIManager(api_key, api_secret_key, tld, logger) logger.info("Creating database schema if it doesn't already exist") create_database() set_coins(supported_coin_list) migrate_old_state() initialize_trade_thresholds(client) if get_current_coin() is None: current_coin_symbol = config.get(USER_CFG_SECTION, 'current_coin') if not current_coin_symbol: current_coin_symbol = random.choice(supported_coin_list) logger.info("Setting initial coin to {0}".format(current_coin_symbol)) if current_coin_symbol not in supported_coin_list: exit( "***\nERROR!\nSince there is no backup file, a proper coin name must be provided at init\n***" ) set_current_coin(current_coin_symbol) if config.get(USER_CFG_SECTION, 'current_coin') == '': current_coin = get_current_coin() logger.info("Purchasing {0} to begin trading".format(current_coin)) all_tickers = client.get_all_market_tickers() client.buy_alt(current_coin, BRIDGE, all_tickers) logger.info("Ready to start trading") schedule = SafeScheduler(logger) schedule.every(SCOUT_SLEEP_TIME).seconds.do( scout, client=client, transaction_fee=SCOUT_TRANSACTION_FEE, multiplier=SCOUT_MULTIPLIER).tag("scouting") schedule.every(1).minutes.do(update_values, client=client).tag("updating value history") schedule.every(1).minutes.do( prune_scout_history, hours=SCOUT_HISTORY_PRUNE_TIME).tag("pruning scout history") schedule.every(1).hours.do(prune_value_history).tag( "pruning value history") while True: schedule.run_pending() time.sleep(1)
def main(): api_key = config.get(USER_CFG_SECTION, 'api_key') api_secret_key = config.get(USER_CFG_SECTION, 'api_secret_key') tld = config.get(USER_CFG_SECTION, 'tld') or 'com' # Default Top-level domain is 'com' client = Client(api_key, api_secret_key, tld=tld) if not os.path.isfile('data/crypto_trading.db'): logger.info("Creating database schema") create_database() set_coins(supported_coin_list) migrate_old_state() initialize_trade_thresholds(client) if get_current_coin() is None: current_coin_symbol = config.get(USER_CFG_SECTION, 'current_coin') if not current_coin_symbol: current_coin_symbol = random.choice(supported_coin_list) logger.info("Setting initial coin to {0}".format(current_coin_symbol)) if current_coin_symbol not in supported_coin_list: exit( "***\nERROR!\nSince there is no backup file, a proper coin name must be provided at init\n***" ) set_current_coin(current_coin_symbol) if config.get(USER_CFG_SECTION, 'current_coin') == '': current_coin = get_current_coin() logger.info("Purchasing {0} to begin trading".format(current_coin)) buy_alt(client, current_coin, BRIDGE) logger.info("Ready to start trading") while True: try: time.sleep(5) scout(client) except Exception as e: logger.info('Error while scouting...\n{}\n'.format( traceback.format_exc()))