def get_resetpassword_page(appname, burl, step, data, data2, terminal): """ xxx """ return_data = '' page_content = '' if step == str(2): page_content = validate_email_input(burl, data) elif step == str(3): page_content = change_password_form(burl, data) elif step == str(4): page_content = set_new_password(burl, data, data2) else: page_content = get_resetpassword_email_input(burl) return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbar(burl, 0, terminal) +\ page_content +\ get_page_footer(burl, False),'') return_data = set_page(return_data) return return_data
def get_tradingview_ecocal(width, height, show_copyright): """ Get tradingview economic calendar """ return_data = '' theme = get_sa_theme() tradingview_copyright = '' if str(width) == '0': width = '"100%"' if str(height) == '0': height = '"100%"' if str(show_copyright) == '1': tradingview_copyright = ''+\ '<div class="tradingview-widget-copyright">'+\ '<a href="https://www.tradingview.com/markets/currencies/economic-calendar/" rel="noopener" target="_blank">'+\ '<span class="blue-text">Economic Calendar</span></a> by TradingView'+\ '</div>' return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ tradingview_copyright+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-events.js" async>'+\ ' {'+\ ' "colorTheme": "'+ theme +'",'+\ ' "isTransparent": true,'+\ ' "width": '+ width +','+\ ' "height": '+ height +','+\ ' "locale": "en",'+\ ' "importanceFilter": "-1,0,1"'+\ '}'+\ ' </script>'+\ '</div>' return return_data
def get_widget_page(appname, burl, nonavbar, funcname, refresh_in_second, noflexheight, terminal): """ xxx """ return_data = '' navbarcontent = '' metarefresh = '' if nonavbar is None: navbarcontent = navbar(burl, 0, terminal) if refresh_in_second is not None: metarefresh = '<meta http-equiv="refresh" content="' + str( refresh_in_second) + '">' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ metarefresh +\ get_metatags(burl) +\ redirect_if_not_logged_in(burl, '') +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbarcontent +\ get_widget_content(burl, nonavbar, funcname, noflexheight),'') return_data = set_page(return_data) return return_data
def get_tradingview_chartoverview(suid): """ Get tradingview symbol info widget """ return_data = '' symbol = '' label_not_available = 'Indicators are not available for this instrument' theme = get_sa_theme() if theme == "dark": trendline_color = 'rgba(255, 255, 255, 1)' else: trendline_color = 'rgba(0, 0, 0, 1)' connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT tradingview FROM symbol_list WHERE uid ='" + str(suid) + "'" cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] if symbol != '': return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div id="tradingview_b336e"></div>'+\ ' <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>'+\ ' <script type="text/javascript">'+\ ' new TradingView.MediumWidget('+\ ' {'+\ ' "symbols": ['+\ ' ['+\ ' "'+ str(symbol) +'|12M"'+\ ' ]'+\ ' ],'+\ ' "chartOnly": false,'+\ ' "width": "100%",'+\ ' "height": "100%",'+\ ' "locale": "en",'+\ ' "colorTheme": "'+ str(theme) +'",'+\ ' "gridLineColor": "#2a2e39",'+\ ' "trendLineColor": "'+ str(trendline_color) +'",'+\ ' "fontColor": "#787b86",'+\ ' "underLineColor": "rgba(55, 166, 239, 0.15)",'+\ ' "isTransparent": true,'+\ ' "autosize": true,'+\ ' "container_id": "tradingview_b336e"'+\ '}'+\ ' );'+\ ' </script>'+\ '</div>' else: return_data = label_not_available cursor.close() connection.close() return return_data
def gen_portf_page(uid, appname, burl, pop, terminal): """ xxx """ return_data = '' if uid is None: uid = 0 if uid == '': uid = 0 connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT instruments.fullname FROM `symbol_list` "+\ "JOIN instruments ON symbol_list.symbol = instruments.symbol "+\ "WHERE symbol_list.uid = " + str(uid) cursor.execute(sql) res = cursor.fetchall() instfullname = '' for row in res: instfullname = row[0] cursor.close() connection.close() if instfullname != '': return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname +' - ' + instfullname) +\ get_metatags(burl) +\ redirect_if_not_logged_in(burl, '') +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_google_chart_script() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), gen_portf_popup(pop) +\ navbar(burl, 0, terminal) +\ '<div class="box-top"><div class="row">' +\ get_details_header(uid, burl) +\ get_portf_alloc(uid, burl) +\ get_portf_perf_desc(uid) +\ get_portf_risk_trail_returns(uid) +\ get_trades_box(uid, burl, None) +\ '</div></div>' +\ get_page_footer(burl, False),'') return_data = set_page(return_data) else: get_error_page(appname, burl, terminal) return return_data
def get_tradingview_indicators(suid, width, height): """ Get Tradingview Indicators """ return_data = '' url = get_broker_affiliate_link('Tradingview', 'baseurl') symbol = '' label_not_available = 'Indicators are not available for this instrument' theme = get_sa_theme() connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT tradingview_ta FROM symbol_list WHERE uid ='"+ str(suid) +"'" cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] if symbol != '': tradingview_copyright = ''+\ '<div class="tradingview-widget-container__widget"></div>' return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ tradingview_copyright+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-technical-analysis.js" '+\ 'async>'+\ ' {'+\ ' "showIntervalTabs": true,'+\ ' "width": "'+ width +'",'+\ ' "colorTheme": "'+ theme +'",'+\ ' "isTransparent": true,'+\ ' "locale": "en",'+\ ' "symbol": "'+ symbol +'",'+\ ' "interval": "1h",'+\ ' "height": "'+ height +'",'+\ ' "largeChartUrl": "'+ url +'"'+\ '}'+\ ' </script>'+\ '</div>' else: return_data = label_not_available cursor.close() connection.close() return return_data
def get_tradingview_fxheatmap(width, height, show_copyright): """ Get Tradingview FX heatmap """ return_data = '' tradingview_copyright = '' url = get_broker_affiliate_link('Tradingview', 'baseurl') theme = get_sa_theme() if str(width) == '0': width = '"100%"' if str(height) == '0': height = '"100%"' if str(show_copyright) == '1': tradingview_copyright = ''+\ '<div class="tradingview-widget-copyright">'+\ '<a href="https://www.tradingview.com/markets/currencies/forex-heat-map/" rel="noopener" target="_blank">'+\ '<span class="blue-text">Forex Heat Map</span></a> by TradingView<'+\ '/div>' return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ tradingview_copyright+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-forex-heat-map.js" async>'+\ ' {'+\ ' "width": '+ str(width) +','+\ ' "height": '+ str(height) +','+\ ' "currencies": ['+\ ' "EUR",'+\ ' "USD",'+\ ' "JPY",'+\ ' "GBP",'+\ ' "CHF",'+\ ' "AUD",'+\ ' "CAD",'+\ ' "NZD",'+\ ' "CNY",'+\ ' "SGD",'+\ ' "RUB"'+\ ' ],'+\ ' "isTransparent": true,'+\ ' "colorTheme": "'+ theme +'",'+\ ' "locale": "en",'+\ ' "largeChartUrl": "'+ str(url) +'"'+\ '}'+\ ' </script>'+\ '</div>' return return_data
def get_tradingview_screener(width, height, market): """ Args: Integer: Width of the widget component. If 0, then autosize Integer: Height of the widget component. If 0, then autosize Integer: Market to load in the screener. if 0 then default user profile 0 = default user profile 1 = forex 2 = U.S market 3 = U.K market 4 = Germany 5 = crypto Returns: None """ ret = '' if str(width) == '0': width = '100%' if str(height) == '0': height = '100%' if str(market) == '0': market_selection = get_screener_market(get_user_default_profile()) else: market_selection = get_screener_market(str(market)) theme = get_sa_theme() url = get_broker_affiliate_link('Tradingview', 'baseurl') tradingview = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-screener.js" async>'+\ ' {'+\ ' "width": "'+ str(width) +'",'+\ ' "height": "'+ str(height) +'",'+\ ' "defaultColumn": "overview",'+\ ' "defaultScreen": "general",'+\ ' "market": "'+ str(market_selection) +'",'+\ ' "showToolbar": true,'+\ ' "colorTheme": "'+ str(theme) +'",'+\ ' "locale": "en",'+\ ' "isTransparent": true,'+\ ' "largeChartUrl": "'+ str(url) +'"'+\ '}'+\ ' </script>'+\ '</div>' ret = tradingview return ret
def gen_selectmarket_page(appname, burl, mode, terminal): """ xxx """ return_data = '' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_selectmarket_box(burl, mode),'') return_data = set_page(return_data) return return_data
def custom_save_portf_page(appname, burl, terminal): """ xxx """ return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_selectportf_box(burl, '6') +\ get_box_portf_save(burl),'') return_data = set_page(return_data) return return_data
def get_signin_page(appname, burl, err, redirect, terminal): """ xxx """ return_data = '' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_signin_content(burl, 'light', err, redirect) +\ get_page_footer(burl, False) +\ get_purechat(1),'') return_data = set_page(return_data) return return_data
def gen_main_page(selection, appname, burl, is_dashboard, tour, nonavbar, terminal): """ xxx """ metarefresh = '' refresh_in_second = 900 navbarcontent = '' if nonavbar is None: navbarcontent = navbar(burl, 0, terminal) page_content = '' if is_dashboard == str(1): if user_is_login() == 1: page_content = get_dashboard(burl, is_dashboard) else: page_content = '' else: page_content = get_page_content(burl, terminal, selection) if user_is_login() == 1: metarefresh = '<meta http-equiv="refresh" content="'+ str(refresh_in_second) +'">' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_googleadsense() +\ get_title(appname) +\ metarefresh+get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_google_chart_script() +\ get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbarcontent +\ gen_tour_popup(tour, burl) +\ get_signin_box(burl) +\ get_box_user_profile_header() +\ page_content + get_page_footer(burl, False) +\ get_purechat(0),'') return_data = set_page(return_data) return return_data
def gen_selectportf_page(appname, burl, step, terminal): """ xxx """ return_data = '' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() + get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_selectportf_box(burl, step) +\ get_box_list_instr_n_portf(burl, 'portf_select', 'instr', step, 10000, ''),'') return_data = set_page(return_data) if step == '1': return_data = ini_portf_select(return_data) return return_data
def get_intel_page(appname, burl, terminal): """ Get and build the entire intelligence report page """ return_data = '' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ redirect_if_not_logged_in(burl, burl +'intelligence') +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_intel_content(burl, terminal),'') return_data = set_page(return_data) return return_data
def get_xxx_page(appname, burl, terminal): """ Return the content of the entire page """ return_data = '' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ redirect_if_not_logged_in(burl, '') +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_xxx_content(burl) +\ get_page_footer(burl, False),'') return_data = set_page(return_data) return return_data
def get_tradingview_financials(suid): """ Get tradingview symbol info widget """ return_data = '' url = get_broker_affiliate_link('Tradingview', 'baseurl') symbol = '' label_not_available = 'Indicators are not available for this instrument' theme = get_sa_theme() connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT tradingview FROM symbol_list WHERE uid ='" + str(suid) + "'" cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] if symbol != '': return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-financials.js" async>'+\ ' {'+\ ' "symbol": "'+ str(symbol) +'",'+\ ' "colorTheme": "'+ str(theme) +'",'+\ ' "isTransparent": true,'+\ ' "largeChartUrl": "'+ str(url) +'",'+\ ' "displayMode": "adaptive",'+\ ' "width": "100%",'+\ ' "height": "100%",'+\ ' "locale": "en"'+\ '}'+\ ' </script>'+\ '</div>' else: return_data = label_not_available cursor.close() connection.close() return return_data
def get_search_page(appname, burl, nonavbar, terminal): """ xxx """ return_data = '' navbarcontent = '' if nonavbar is None: navbarcontent = navbar(burl, 1, terminal) return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbarcontent +\ get_search_page_content(burl, nonavbar, terminal) +\ get_page_footer(burl, False),'') return_data = set_page(return_data) return return_data
def gen_view_list_instr_n_portf(appname, burl, what, sel, terminal): """ xxx """ #what = 'instr', what = 'portf' #sel = market or asset class return_data = '' if what == 'instr': numrow = 10000 else: numrow = 200 page_title = 'Top Performing Trades of the Week' page_desc = 'Access to thousands of financial instruments, '+\ 'stocks, forex, commodities & cryptos. '+\ 'Create your trading signals portfolio powered by Artificial intelligence.' return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_googleadsense() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 2, page_title, page_desc) +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() + get_stylesheet(burl)) return_data = return_data + get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_top_instr_n_portf_list() +\ get_box_list_instr_n_portf(burl, 'view', what, 1, numrow, sel) +\ get_page_footer(burl, False) +\ get_purechat(0), '') return_data = set_page(return_data) return return_data
def get_doc_page(appname, burl, uid, terminal): """ Return the content of the entire page """ return_data = '' document = doc_data(uid) title = document.get_title() content = document.get_content() category = document.get_category() page_url = burl + 'doc/?uid=' + str(uid) return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 2, title, page_url) +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_doc_content(burl, title, content, category, terminal) +\ get_page_footer(burl, False),'overflow: hidden;') return_data = set_page(return_data) return return_data
def gen_createuser_page(uid, appname, burl, name, username, password, from_ip, broker, username_broker, terminal): """ xxx """ return_data = '' if uid == '0': return_data = get_head(get_loading_head() +\ get_googleanalytics() +\ get_title(appname) +\ get_metatags(burl) +\ set_ogp(burl, 1, '', '') +\ get_bootstrap(get_sa_theme(), burl) +\ get_font_awesome() +\ get_stylesheet(burl)) return_data = return_data +\ get_body(get_loading_body(), navbar(burl, 0, terminal) +\ get_user_creation_form(burl, broker) +\ get_page_footer(burl, False),'') return_data = set_page(return_data) else: connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT username FROM users WHERE uid = '"+\ str(uid) +"' OR username LIKE '"+\ str(username) +"' " cursor.execute(sql) res = cursor.fetchall() check_exists = '' for row in res: check_exists = row[0] if check_exists == '': name = name.lower() nickname = set_nickname() date_today = datetime.datetime.now() date_today = date_today.strftime('%Y%m%d') referred_by_code = get_refer_by_code() avatar_id = get_random_num(19) email_subscription = 'ALL' password = get_hash_string(password) broker = str(broker) username_broker = str(username_broker) sql = "INSERT INTO users(uid, name, nickname, username, "+\ "password, created_on, referred_by_code, avatar_id, "+\ "from_ip,lang,email_subscription,broker,username_broker) "+\ "VALUES ('"+\ str(uid) +"','"+\ str(name) +"','"+\ str(nickname) +"','"+\ str(username) +"','"+\ str(password) +"',"+\ str(date_today) +", '"+\ str(referred_by_code) +"', "+\ str(avatar_id) +", '"+\ str(from_ip) + "', '"+\ str(get_lang()) +"', '"+\ str(email_subscription) +"','"+\ str(broker)+"', '"+\ str(username_broker) +"' )" cursor.execute(sql) connection.commit() return_data = set_sa_cookie(uid, set_page( get_head('<meta http-equiv="refresh" content="0;URL=' +\ burl + 'n/?step=c" />') +\ get_body('', '',''))) send_email_notification(broker, name, username) else: return_data = 'user already exists :P !' cursor.close() connection.close() return return_data
def get_tradingview_watchlist(width, height, show_copyright): """ xxx """ if str(width) == '0': width = '100%' if str(height) == '0': height = '100%' tradingview_copyright = '' theme = get_sa_theme() url = get_broker_affiliate_link('Tradingview', 'baseurl') ret = '' l_list_strategy_portfolio = 'My Strategy Portfolio' l_list_top_5_best_performers = 'Top 5 Pos Movers' l_list_top_5_worst_performers = 'Top 5 Neg Movers' l_list_watchlist = 'In the Radar' url = get_broker_affiliate_link('Tradingview', 'baseurl') if str(show_copyright) == '1': tradingview_copyright = ''+\ '<div class="tradingview-widget-copyright">'+\ '<a href="https://www.tradingview.com" rel="noopener" target="_blank">'+\ '<span class="blue-text">Market Data</span></a> by TradingView'+\ '</div>' tradingview = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ tradingview_copyright+\ ' <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-market-overview.js" async>'+\ ' {'+\ ' "colorTheme": "'+ theme +'",'+\ ' "dateRange": "1d",'+\ ' "showChart": true,'+\ ' "locale": "en",'+\ ' "width": "'+ width +'",'+\ ' "height": "'+ height +'",'+\ ' "largeChartUrl": "'+ url +'",'+\ ' "isTransparent": true,'+\ ' "plotLineColorGrowing": "rgba(25, 118, 210, 1)",'+\ ' "plotLineColorFalling": "rgba(25, 118, 210, 1)",'+\ ' "gridLineColor": "rgba(42, 46, 57, 1)",'+\ ' "scaleFontColor": "rgba(120, 123, 134, 1)",'+\ ' "belowLineFillColorGrowing": "rgba(33, 150, 243, 0.12)",'+\ ' "belowLineFillColorFalling": "rgba(33, 150, 243, 0.12)",'+\ ' "symbolActiveColor": "rgba(33, 150, 243, 0.12)",'+\ ' "tabs": ['+\ get_tradingview_list_content(l_list_strategy_portfolio, 'port', False) +\ get_tradingview_list_content(l_list_watchlist, 'watchlist', False) +\ get_tradingview_list_content(l_list_top_5_best_performers, 'best', False) +\ get_tradingview_list_content(l_list_top_5_worst_performers, 'worst', True) +\ ' ],'+\ ' "locale": "en",'+\ ' "largeChartUrl": "'+ str(url) +'"'+\ '}'+\ ' </script>'+\ '</div>' ret = tradingview return ret
def get_tradingview_chart(suid, width, height, show_copyright): """ Get tradingview interactive chart """ return_data = '' symbol = '' referral_id = get_broker_affiliate_link('Tradingview', 'affiliate') label_not_available = 'Live chart is not available for this instrument' theme = get_sa_theme() allow_symbol_change = 'true' tradingview_copyright = '' connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT tradingview_chart FROM symbol_list WHERE uid ='" + str( suid) + "'" cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] if str(width) == '0': width = '"100%"' if str(height) == '0': height = '"100%"' if symbol != '': if str(show_copyright) == '1': tradingview_copyright = ''+\ '<div class="tradingview-widget-copyright">'+\ '<a href="https://www.tradingview.com/symbols/'+ symbol +'/" rel="noopener" target="_blank">'+\ '<span class="blue-text">'+ symbol +' Chart</span></a> by TradingView</div>' return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div id="tradingview_713ab"></div>'+\ tradingview_copyright+\ '<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>'+\ '<script type="text/javascript">'+\ 'new TradingView.widget('+\ '{'+\ '"autosize": true,'+\ '"width": '+ str(width) +','+\ '"height": '+ str(height) +','+\ '"symbol": "'+ symbol +'",'+\ '"interval": "D",'+\ '"timezone": "Etc/UTC",'+\ '"theme": "'+ theme +'",'+\ '"style": "1",'+\ '"locale": "en",'+\ '"toolbar_bg": "#f1f3f6",'+\ '"enable_publishing": false,'+\ '"save_image": false,'+\ '"allow_symbol_change": '+ allow_symbol_change +','+\ '"referral_id": "'+ referral_id +'",'+\ '"container_id": "tradingview_713ab",'+\ '"hide_side_toolbar": false,'+\ '}'+\ ' );'+\ ' </script>'+\ '</div>' else: return_data = label_not_available cursor.close() connection.close() return return_data
def go(): """ xxx """ appname = 'SmartAlpha | Trading Intelligence' c = '' burl = request.url_root; if not DEV_MODE: burl = burl.replace('http://','https://') uid = request.args.get('uid') ref = request.args.get('ref') lang = request.args.get('lang') nonavbar = request.values.get('nonavbar') terminal = request.args.get('terminal') x = request.args.get('x'); err = request.args.get('err') ############################################################################ if request.endpoint == 's': tvws = request.args.get('tvwidgetsymbol') c = gen_sign_page(uid, tvws, appname, burl, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'p': ins = request.values.get('ins') step = request.values.get('step') mode = request.values.get('mode') pop = request.values.get('pop') delete = request.values.get('delete') dashboard = request.values.get('dashboard') if ins != '' or ins != None: if x == '' or x == None : x = get_user_default_profile() if ins == '1': c = gen_selectportf_page(appname, burl, step, terminal) if ins == '2': c = save_portf_select(burl, step, uid) if ins == '3': c = custom_save_portf_page(appname, burl, terminal) if ins == '4': c = portf_save_conviction(burl,mode,x) if ins == '5': c = portf_save(burl) if ins is None: c = gen_portf_page(uid,appname,burl,pop, terminal) if delete is not None: c = del_portf(delete,burl,x,dashboard) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'ls': what = request.values.get('w') c = gen_view_list_instr_n_portf(appname, burl, what, x, terminal) elif request.endpoint == 'n': name = request.values.get('name') username = request.values.get('email') password = request.values.get('password') from_ip = request.values.get('from_ip') nickname = request.values.get('nickname') step = request.args.get('step') broker = request.args.get('broker') if broker is None: broker = request.values.get('broker') broker_username = request.values.get('username_broker') mode = request.values.get('mode') if step == 'c': c = gen_selectmarket_page(appname, burl, mode, terminal) elif step == 'd': c= save_selectmarket(burl, x) else: c = gen_createuser_page(uid, appname, burl, name, username, password, from_ip,broker, broker_username, terminal) elif request.endpoint == 'join': broker = request.args.get('broker') #if broker is None: #broker = 'not-specified' c = gen_createuser_page('0',appname,burl,'','','','',broker,'', terminal) elif request.endpoint == 'h': c = get_help_page(appname, burl, terminal) elif request.endpoint == 'doc': c = get_doc_page(appname, burl, uid, terminal) elif request.endpoint == 'financials': c = get_financials_page(appname, uid, burl, terminal) elif request.endpoint == 'profile': c = get_profile_page(appname, uid, burl, terminal) elif request.endpoint == 'w': funcname = request.values.get('funcname') refreshw = request.values.get('refreshw') noflexheight = request.values.get('noflexheight') c = get_widget_page(appname, burl, nonavbar, funcname, refreshw, noflexheight, terminal) elif request.endpoint == 'intelligence': c = get_intel_page(appname, burl, terminal) elif request.endpoint == 'terminal': c = get_sa_terminal_page(appname,burl, terminal) elif request.endpoint == 'terminalhelp': c = get_sa_terminal_help_page(appname,burl, terminal) elif request.endpoint == 'theme': switch_to = '' if get_sa_theme() == 'dark': switch_to = 'light' else: switch_to = 'dark' c = theme_redirect(burl, terminal) c = set_sa_theme(switch_to, c ) elif request.endpoint == 'login': user = request.values.get('user') password = request.values.get('password') redirect_to = request.values.get('redirect') c = user_login(user,password, burl, redirect_to) elif request.endpoint == 'logout': c = user_logout(burl) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'signin': redirect_to = request.values.get('redirect') c = get_signin_page(appname, burl, err, redirect_to, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'pricing': c = get_plan_selection_page(appname, burl, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'settings': step = request.args.get('step') name = request.values.get('name') nickname = request.values.get('nickname') username = request.values.get('username') default_profile = request.values.get('default_profile') email_subscription = request.values.get('email_subscription') message = save_settings(name,nickname,username,default_profile,email_subscription) c = get_settings_page(appname, burl, step, message, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'reset': step = request.args.get('step') data = request.values.get('data') data2 = request.values.get('data2') c = get_resetpassword_page(appname, burl, step, data, data2, terminal) elif request.endpoint == 'search': nonavbar = request.args.get('nonavbar') c = get_search_page(appname,burl,nonavbar, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'genportf': acm = request.args.get('acm') step = request.args.get('step') notstart = request.args.get('notstart') if step == '1': c = gen_portf_user_example(burl,acm,notstart) if step == '2': c = gen_portf_validate_content(burl,notstart) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'error': c = get_error_page(appname, burl, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) elif request.endpoint == 'url': url_q = request.values.get('q') c = set_page( get_head('<meta http-equiv="refresh" content="0;URL=' + str(url_q) + '" />') + get_body('','','') ) else: if x == '' or x == None : x = get_user_default_profile() dashboard = request.args.get('dashboard') tour = request.args.get('tour') c = gen_main_page(x,appname,burl,dashboard,tour,nonavbar, terminal) c = set_sa_lang(lang,c) c = set_sa_ref_code(ref,c) ############################################################################ sid = request.args.get('sid') if sid is None: sid = '' q = request.args.get(sid) if len(sid)>5: c = get_search_result(q, burl, nonavbar) if not DEV_MODE: if burl.find('https://app.') == -1: if burl.find('https://www.') > -1: burl = burl.replace('https://www.','https://app.') else: burl = burl.replace('https://','https://app.') c = set_page( get_head(get_loading_head() + '<script>window.location = "'+ burl +'";</script>' ) + get_body( get_loading_body() , '' , '') ) return c
def get_tradingview_mini_chart(suid, width, height, autosize, date_range, area_chart, show_copyright): """ Get tradingview mini chart """ return_data = '' url = get_broker_affiliate_link('Tradingview', 'baseurl') symbol = '' label_not_available = 'Symbol is not available' theme = get_sa_theme() tradingview_copyright = '' connection = pymysql.connect(host=DB_SRV, user=DB_USR, password=DB_PWD, db=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cursor = connection.cursor(pymysql.cursors.SSCursor) sql = "SELECT tradingview_chart FROM symbol_list WHERE uid ='" + str( suid) + "'" cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] trend_line_color = '#37a6ef' under_line_color = '#e3f2fd' if get_signal(suid) == 'b': if area_chart == 1: trend_line_color = theme_return_this('rgba(106, 168, 79, 1)', 'rgba(255,255,255,0.4)') else: trend_line_color = theme_return_this('rgba(217, 234, 211, 1)', 'rgba(102,255,51,1)') under_line_color = theme_return_this( 'rgba(217, 234, 211, 1)', 'rgba(102,255,51,' + str(area_chart) + ')') else: if area_chart == 1: trend_line_color = theme_return_this('rgba(255, 0, 0, 1)', 'rgba(255,255,255,0.4)') else: trend_line_color = theme_return_this('rgba(244, 204, 204, 1)', 'rgba(217,83,79, 1)') under_line_color = theme_return_this( 'rgba(244, 204, 204, 1)', 'rgba(217,83,79,' + str(area_chart) + ')') if symbol != '': if str(show_copyright) == '1': tradingview_copyright = ''+\ '<div class="tradingview-widget-copyright">'+\ '<a href="https://www.tradingview.com/symbols/'+ symbol +'/" rel="noopener" target="_blank">'+\ '<span class="blue-text">'+ symbol +' Rates</span></a> by TradingView'+\ '</div>' return_data = '' +\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ tradingview_copyright+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js"'+\ ' async>'+\ ' {'+\ ' "symbol": "'+ symbol +'",'+\ ' "width": "'+ width +'",'+\ ' "height": "'+ height +'",'+\ ' "locale": "en",'+\ ' "dateRange": "'+date_range+'",'+\ ' "colorTheme": "'+ theme +'",'+\ ' "trendLineColor": "'+ trend_line_color +'",'+\ ' "underLineColor": "'+ under_line_color +'",'+\ ' "isTransparent": true,'+\ ' "autosize": '+ autosize +','+\ ' "largeChartUrl": "'+ url +'"'+\ '}'+\ ' </script>'+\ '</div>' else: return_data = label_not_available cursor.close() connection.close() return return_data