web_server_enabled = Config.getboolean('BOT', 'startWebServer')
if web_server_enabled:
    if json_output_enabled == False:
        # User wants webserver enabled. Must have JSON enabled. Force logging with defaults.
        json_output_enabled = True
        jsonfile = Config.get('BOT', 'jsonfile', 'www/botlog.json')

    import modules.WebServer as WebServer
    WebServer.initialize_web_server(Config)

# Configure logging
log = Logger(jsonfile, Decimal(Config.get('BOT', 'jsonlogsize', 200)),
             exchange)

# initialize the remaining stuff
api = ExchangeApiFactory.createApi(exchange, Config)
MaxToLend.init(Config, log)
Data.init(api, log)
Config.init(config_location, Data)
notify_conf = Config.get_notification_config()
if Config.has_option('BOT', 'analyseCurrencies'):
    from modules.MarketAnalysis import MarketAnalysis
    # Analysis.init(Config, api, Data)
    analysis = MarketAnalysis(Config, api)
    analysis.run()
else:
    analysis = None
Lending.init(Config, api, log, Data, MaxToLend, dry_run, analysis, notify_conf)

# load plugins
PluginsManager.init(Config, api, log, notify_conf)
if web_server_enabled:
    if json_output_enabled is False:
        # User wants webserver enabled. Must have JSON enabled. Force logging with defaults.
        json_output_enabled = True
        jsonfile = Config.get('BOT', 'jsonfile', 'www/botlog.json')

    import modules.WebServer as WebServer
    WebServer.initialize_web_server(Config)

# Configure logging
log = Logger(jsonfile, Decimal(Config.get('BOT', 'jsonlogsize', 200)), exchange)

# initialize the remaining stuff
apikey = "KOP7HcNl9NwiBpwXoLoZ4LeGV2c5ofJA7K9egHeNOa2"
secret = "e1B3ylYMgH9xyCL1IsH5NPKW44HlA0bLWWLXydSQPSS"
api = ExchangeApiFactory.createApi(exchange, Config, log, apikey, secret)
MaxToLend.init(Config, log)
Data.init(api, log)
Config.init(config_location, Data)
notify_conf = Config.get_notification_config()
if Config.has_option('MarketAnalysis', 'analyseCurrencies'):
    from modules.MarketAnalysis import MarketAnalysis
    # Analysis.init(Config, api, Data)
    analysis = MarketAnalysis(Config, api)
    analysis.run()
else:
    analysis = None
Lending.init(Config, api, log, Data, MaxToLend, dry_run, analysis, notify_conf)

# load plugins
PluginsManager.init(Config, api, log, notify_conf)
# Configure web server
web_server_enabled = Config.getboolean('BOT', 'startWebServer')
if web_server_enabled:
    if json_output_enabled is False:
        # User wants webserver enabled. Must have JSON enabled. Force logging with defaults.
        json_output_enabled = True
        jsonfile = Config.get('BOT', 'jsonfile', 'www/botlog.json')

    import modules.WebServer as WebServer
    WebServer.initialize_web_server(Config)

# Configure logging
log = Logger(jsonfile, Decimal(Config.get('BOT', 'jsonlogsize', 200)), exchange)

# initialize the remaining stuff
api = ExchangeApiFactory.createApi(exchange, Config, log)
MaxToLend.init(Config, log)
Data.init(api, log)
Config.init(config_location, Data)
notify_conf = Config.get_notification_config()
if Config.has_option('MarketAnalysis', 'analyseCurrencies'):
    from modules.MarketAnalysis import MarketAnalysis
    # Analysis.init(Config, api, Data)
    analysis = MarketAnalysis(Config, api)
    analysis.run()
else:
    analysis = None
Lending.init(Config, api, log, Data, MaxToLend, dry_run, analysis, notify_conf)

# load plugins
PluginsManager.init(Config, api, log, notify_conf)