def main():
    try:
        message = 'Starting '
        if (app.getExchange() == 'coinbasepro'):
            message += 'Coinbase Pro bot'
        elif (app.getExchange() == 'binance'):
            message += 'Binance bot'
        message += (((' for ' + app.getMarket()) + ' using granularity ') + app.printGranularity())
        app.notifyTelegram(message)
        trading_data = app.startApp(account, state.last_action)

        def runApp():
            if app.isSimulation():
                executeJob(s, app, state, trading_data)
            else:
                executeJob(s, app, state)
            s.run()
        try:
            runApp()
        except KeyboardInterrupt:
            raise
        except (BaseException, Exception) as e:
            if app.autoRestart():
                time.sleep(30)
                Logger.critical(('Restarting application after exception: ' + repr(e)))
                app.notifyTelegram(((('Auto restarting bot for ' + app.getMarket()) + ' after exception: ') + repr(e)))
                map(s.cancel, s.queue)
                runApp()
            else:
                raise
    except KeyboardInterrupt:
        Logger.warning((str(datetime.now()) + ' bot is closed via keyboard interrupt...'))
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)
    except (BaseException, Exception) as e:
        app.notifyTelegram(((('Bot for ' + app.getMarket()) + ' got an exception: ') + repr(e)))
        Logger.critical(repr(e))
        raise
def main():
    try:
        message = 'Starting '
        if (app.getExchange() == 'coinbasepro'):
            message += 'Coinbase Pro bot'
        elif (app.getExchange() == 'binance'):
            message += 'Binance bot'
        message += (((' for ' + app.getMarket()) + ' using granularity ') + app.printGranularity())
        app.notifyTelegram(message)
        trading_data = app.startApp(account, state.last_action)

        def runApp():
            if app.isSimulation():
                executeJob(s, app, state, trading_data)
            else:
                executeJob(s, app, state)
            s.run()
        try:
            runApp()
        except KeyboardInterrupt:
            raise
        except (BaseException, Exception) as e:
            if app.autoRestart():
                time.sleep(30)
                Logger.critical(('Restarting application after exception: ' + repr(e)))
                app.notifyTelegram(((('Auto restarting bot for ' + app.getMarket()) + ' after exception: ') + repr(e)))
                map(s.cancel, s.queue)
                runApp()
            else:
                raise
    except KeyboardInterrupt:
        Logger.warning((str(datetime.now()) + ' bot is closed via keyboard interrupt...'))
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)
    except (BaseException, Exception) as e:
        app.notifyTelegram(((('Bot for ' + app.getMarket()) + ' got an exception: ') + repr(e)))
        Logger.critical(repr(e))
        raise