def dashboard_view(request): context = {} # Check to see if haas is working haasCheck = HaasManager.haasomeClient.test_credentials() if HaasManager.verify_haas_connectivity(): #Continue customBots = HaasManager.get_all_custom_bots() tradeBots = HaasManager.get_all_trade_bots() context = {'customBots': customBots, 'tradeBots': tradeBots, 'amountOfCustomBots': len(customBots), 'amountOfTradeBots': len(tradeBots), 'totalBotsCount': len(tradeBots) + len(customBots), 'totalRoi': UtilManager.get_roi_from_bot_list(tradeBots) + UtilManager.get_roi_from_bot_list(customBots), 'totalTradeCount': UtilManager.get_total_trades_from_bot_list(tradeBots) + UtilManager.get_total_trades_from_bot_list(customBots), 'totalActivatedBots': UtilManager.get_activated_count_from_bot_list(tradeBots) + UtilManager.get_activated_count_from_bot_list(customBots)} if 'successNotification' in request.session: context['successNotification'] = request.session['successNotification'] if 'failureNotification' in request.session: context['failureNotification'] = request.session['failureNotification'] request = UtilManager.clear_session_notifications(request) else: context = {'connectFailure': True} return render(request, 'authed/dashboard.html', context)
def basic_analyzer_view(request): config = ConfigManager.get_or_create_config() history = HistoryRetrievalManager.get_or_create_history_retrieval_model() basicAnalysis = BasicAnalysisManager.get_or_create_basic_analysis_run_model() context = {'accounts': HaasManager.get_all_accounts(), 'customBots': HaasManager.get_all_custom_bots(), 'tradeBots': HaasManager.get_all_trade_bots(), 'history': HistoryRetrievalManager.get_or_create_history_retrieval_model(), 'basicAnalysis': BasicAnalysisManager.get_or_create_basic_analysis_run_model() } if history.completed == True and basicAnalysis.started == False: basicAnalysis.started = True context['basicAnalysis'] = basicAnalysis markets = HaasManager.get_all_markets_for_guid(basicAnalysis.accountGuid) BasicAnalysisManager.set_total_to_retrieve(len(markets)) BasicAnalysisManager.mark_started() backtest_all_markets_with_bot(config.haasIp, config.haasPort, config.haasSecret, basicAnalysis.accountGuid, basicAnalysis.botGuid, basicAnalysis.timeFrameInMinutes, "", basicAnalysis.isCustomBot) return render(request, 'authed/basic_analyzer.html', context)