def get_broker_url(broker, what, uid): """ xxx """ return_data = '' if what == 'link': return_data = '<a '+\ go_to_url(get_broker_affiliate_link(broker, 'affiliate'), 'link', uid) +\ '" target="_blank">'+ broker +'</a>' if what == 'form': return_data = go_to_url(get_broker_affiliate_link(broker, 'affiliate'), 'form', uid) return return_data
def get_signin_box(burl): """ xxx """ box_content = '' if user_is_login() == 0: l_app_header_title = 'Create unlimited optimized trading strategies' l_app_header_desc = 'Chart patterns, price movements, '+\ 'and news analysed using quantitative methods '+\ 'with the power of artificial intelligence to generate trading signals. '+\ 'Generate more profitable trades by using SmartAlpha as your trading assistant.' l_app_call_to_action_link = 'Join now.' etoro_logo_form = go_to_url( get_broker_affiliate_link('eToro', 'affiliate'), 'form', 'eToro') etoro_logo_link = go_to_url( get_broker_affiliate_link('eToro', 'affiliate'), 'link', 'eToro') box_content = etoro_logo_form +\ '<div class="box-sign"><div class="row">' +\ ' <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">'+\ ' <div class="sign-part">'+\ ' <div class="row sign-row">'+\ ' <div class="col-lg-6 col-md-6 col-sm-23 col-xs-12 sa-signin-box">'+\ ' <div> </div>'+\ ' <h1 style="text-align: left; font-size:x-large; font-weight:bolder;">'+\ l_app_header_title +'</h1> '+\ ' <div>'+\ l_app_header_desc +' <a href="'+\ burl +'join/?" class="text-info">'+\ l_app_call_to_action_link +'</a></div>'+\ ' <div class="row d-none d-sm-block style="margin: 20px;">'+\ ' <a '+\ etoro_logo_link +'" target="_blank"><img src="'+\ burl +'static/etoro-logo.png" height="50px" style="margin:20px;" /></a>'+\ ' <a href="#" target=""><img src="'+\ burl +'static/tradingview-logo.png" height="50px" style="margin:20px;" /></a>'+\ ' <a href="#" target=""><img src="'+\ burl +'static/aws-logo.png" height="50px" style="margin:20px;" /></a>'+\ ' </div>'+\ ' </div>'+\ ' <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12" '+\ 'style="padding: 50px;">'+\ get_login_form(burl, 'dark', '') +\ ' </div>'+\ ' </div>'+\ ' </div>'+\ ' </div>'+\ '</div></div>' return box_content
def get_about_menu(terminal): """ xxx """ return_data = '' link = get_broker_affiliate_link('googleSiteSmartAlpha', 'affiliate') l_title = 'What is SmartAlpha?' return_data = '<li> </li><li class="nav-item d-none d-sm-block">'+\ '<a style="font-size: medium;" class="btn btn-sm btn-outline-info" href="'+\ open_window_as(link, terminal) +'">'+ l_title +'</a></li>' return return_data
def place_trade_link(symbol, content): ret = '' broker = 'eToro' height = '600' width = '360' etoro_symbol = get_etoro_symbol_from_symbol(symbol) trade_href = get_broker_affiliate_link(broker, 'baseurl') + str(etoro_symbol) ret = '<a href="javascript:{}" '+\ 'onclick="'+ open_window(trade_href, width, height, 0, 0) +'">'+\ content +\ '</a>' return ret
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_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 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_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_tradingview_fxcross(width, height): """ Get Tradingview FXcross """ return_data = '' #theme = get_sa_theme() url = get_broker_affiliate_link('Tradingview', 'baseurl') if str(width) == '0': width = '"100%"' if str(height) == '0': height = '"100%"' 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-forex-cross-rates.js" async>'+\ ' {'+\ ' "width": '+ str(width) +','+\ ' "height": '+ str(height) +','+\ ' "currencies": ['+\ ' "EUR",'+\ ' "USD",'+\ ' "JPY",'+\ ' "GBP",'+\ ' "CHF",'+\ ' "AUD",'+\ ' "CAD",'+\ ' "NZD",'+\ ' "CNY",'+\ ' "SGD",'+\ ' "RUB"'+\ ' ],'+\ ' "locale": "en",'+\ ' "largeChartUrl": "'+ str(url) +'"'+\ '}'+\ ' </script>'+\ '</div>' return return_data
def get_tradingview_ticker(uid): """ Get tradingview ticker """ return_data = '' ltvs = '' ide = 0 referral_id = 'smartalpha' url = get_broker_affiliate_link('Tradingview', 'baseurl') theme = 'dark' 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 id FROM users WHERE uid='" + str(uid) + "'" cursor.execute(sql) res = cursor.fetchall() for row in res: ide = row[0] sql = "SELECT DISTINCT "+\ "symbol_list.tradingview, symbol_list.symbol "+\ "FROM instruments "+\ "JOIN portfolios ON instruments.symbol = portfolios.portf_symbol "+\ "JOIN symbol_list ON portfolios.symbol = symbol_list.symbol "+\ "WHERE instruments.owner='"+ str(ide) +"' " cursor.execute(sql) res = cursor.fetchall() i = 1 sep = '' for row in res: if i == 1: sep = '' else: sep = ',' ltvs = ltvs + sep + '{"description": "' + str( row[1]) + '", "proName": "' + str(row[0]) + '"}' i += 1 return_data = ' '+\ '<div class="tradingview-widget-container">'+\ ' <div class="tradingview-widget-container__widget"></div>'+\ ' <div class="tradingview-widget-copyright">'+\ ' <script type="text/javascript" '+\ 'src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async>'+\ ' {'+\ ' "symbols": ['+\ ltvs +\ ' ],'+\ ' "colorTheme": "'+ theme +'",'+\ ' "isTransparent": true,'+\ ' "largeChartUrl": "'+ url +'",'+\ ' "displayMode": "adaptive",'+\ ' "locale": "en",'+\ ' "referral_id": "'+ referral_id +'"'+\ '}'+\ ' </script>'+\ '</div>'+\ '</div>' cursor.close() connection.close() return return_data
def get_user_creation_form(burl, broker): """ xxx """ box_content = '' l_enter_name = "Enter Name" l_enter_email = "Enter Email" l_affiliate_submit_form = '' l_create_your_account = 'Create your account' if broker is not None: l_create_broker_account = "If you do not have a trading account at "+\ str(broker) + ", create one now to trade with Smartalpha: " l_create_broker_account_btn_label = 'Create' + ' ' +\ str(broker) + ' ' +'account' uniqid = broker + '_affiliate_link' l_affiliate_href = go_to_url( get_broker_affiliate_link(broker, 'affiliate'), 'link', uniqid) l_affiliate_submit_form = go_to_url( get_broker_affiliate_link(broker, 'affiliate'), 'form', uniqid) l_create_broker_account_btn = '<a '+\ l_affiliate_href + ' target="_blank" class="btn btn-success '+\ 'form-signin-btn" role="button">'+\ l_create_broker_account_btn_label +' <i class="fas fa-external-link-alt"></i></a>' user_creation_header = '' if broker is None: user_creation_header = '<div style="text-align: center;">'+\ '<h2>' +\ l_create_your_account +\ '</h2>' +\ '</div>' else: user_creation_header = '<div style="text-align: center;">'+\ l_create_broker_account + ' '+\ l_create_broker_account_btn +'</div>' box_content = l_affiliate_submit_form +\ '<div class="box-top">' +\ ' <div class="row">'+\ ' <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">'+\ ' <div class="box-part rounded">'+\ ' <form method="POST" action="'+\ burl +'n/?uid='+ get_random_str(99) +\ '" style="width: 100%; max-width: 600px; padding: 2%; margin: auto;">'+\ ' <div>'+\ ' <div>'+\ user_creation_header+\ ' <hr>'+\ ' </div>'+\ ' </div>'+\ get_broker_signin_spec_form(broker) +\ ' <div>'+\ ' <div>'+\ ' <div class="input-group input-group-lg">'+\ ' <div class="input-group-prepend">'+\ ' <span class="input-group-text" '+\ 'id="inputGroup-sizing-lg"><i class="fa fa-user-alt" style="font-size: large;"></i></span>'+\ ' </div>'+\ ' <input type="text" id="name" name="name" '+\ 'class="form-control" aria-label="Large" '+\ 'aria-describedby="inputGroup-sizing-sm" placeholder="'+\ l_enter_name +'" required autofocus>'+\ ' </div>'+\ ' </div>'+\ ' </div>'+\ ' <div>'+\ ' <div>'+\ ' <div class="input-group input-group-lg">'+\ ' <div class="input-group-prepend">'+\ ' <span class="input-group-text" '+\ 'id="inputGroup-sizing-lg"><i class="fa fa-at" style="font-size: large;"></i></span>'+\ ' </div>'+\ ' <input type="email" id="email" '+\ 'name="email" class="form-control" aria-label="Large" '+\ 'aria-describedby="inputGroup-sizing-sm" placeholder="'+\ l_enter_email +'" required autofocus>'+\ ' </div>'+\ ' </div>'+\ ' </div>'+\ ' <div>'+\ ' <div>'+\ ' <div class="input-group input-group-lg">'+\ ' <div class="input-group-prepend">'+\ ' <span class="input-group-text" '+\ 'id="inputGroup-sizing-lg"><i class="fa fa-key" style="font-size: large;"></i></span>'+\ ' </div>'+\ ' <input type="password" '+\ 'id="password" name="password" class="form-control" aria-label="Large" '+\ 'aria-describedby="inputGroup-sizing-sm" placeholder="Password" required>'+\ ' </div>'+\ ' </div>'+\ ' </div>'+\ ' <div>'+\ ' <div>'+\ ' <div> </div>'+\ get_user_ip_input() +\ ' <button type="submit" '+\ 'class="btn btn-info btn-lg btn-block form-signin-btn">' +\ 'Next' + ' <i class="fas fa-arrow-right"></i></button>'+\ ' </div>'+\ ' </div>'+\ '<div class="expl" style="text-align: center;">'+\ '*We respect your privacy and will never share your email address '+\ 'with any person or organization.</div>'+\ ' </form>'+\ ' </div>'+\ ' </div>'+\ ' </div>'+\ '</div>' return box_content
def get_signal_details(uid, burl, mode, terminal): """ xxx """ # ============================================================================= # uid = symbol uid # mode = 'newsfeed','desc' # ============================================================================= descr_box = '' broker = 'eToro' height = '600' width = '360' button_href = open_window_as(burl + 's/?uid=' + str(uid), terminal) etoro_symbol = get_etoro_symbol_from_uid(uid) trade_href = get_broker_affiliate_link(broker, 'baseurl') + str(etoro_symbol) 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.symbol, "+\ "instruments.trade_1_entry, instruments.trade_1_tp, instruments.trade_1_sl, "+\ "instruments.trade_3_entry, instruments.trade_3_tp, instruments.trade_3_sl, "+\ "instruments.decimal_places FROM instruments "+\ "JOIN symbol_list ON symbol_list.symbol = instruments.symbol "+\ "WHERE symbol_list.uid=" + str(uid) cursor.execute(sql) res = cursor.fetchall() for row in res: symbol = row[0] trade_1_entry = row[1] trade_1_tp = row[2] trade_1_sl = row[3] trade_3_entry = row[4] trade_3_tp = row[5] trade_3_sl = row[6] decimal_places = row[7] sql = "SELECT badge FROM feed JOIN symbol_list ON symbol_list.symbol = feed.symbol "+\ "WHERE symbol_list.uid=" + str(uid) + " AND feed.type=1 " cursor.execute(sql) res = cursor.fetchall() badge = '' for row in res: badge = row[0] if badge.find('-999') == -1: if (badge.find('-0') == -1 and badge.find('-1') == -1 and badge.find('-2') == -1 and badge.find('-3') == -1 and badge.find('-4') == -1 and badge.find('-5') == -1 and badge.find('-6') == -1 and badge.find('-7') == -1 and badge.find('-8') == -1 and badge.find('-9') == -1): signal = '<a href="javascript:{}" '+\ 'onclick="'+ open_window(trade_href, width, height, 0, 0) +'"'+\ ' class="btn btn-outline-success"><h4>Buy</h4></a>' entry = trade_1_entry target_price = trade_1_tp stop_loss = trade_1_sl else: signal = '<a href="javascript:{}" '+\ 'onclick="'+ open_window(trade_href, width, height, 0, 0) +'"'+\ 'class="btn btn-outline-danger"><h4>Sell</h4></a>' entry = trade_3_entry target_price = trade_3_tp stop_loss = trade_3_sl else: signal = '<a href="javascript:{}" '+\ 'onclick="'+ open_window(trade_href, width, height, 0, 0) +'"'+\ 'class="btn btn-outline-secondary"><h4>Wait</h4></a>' entry = trade_1_entry target_price = 0 stop_loss = 0 hd_entry = 'Entry @' hd_tp = 'Target price' hd_sl = 'Stop loss' c_symbol = '' c_signal_column_width = 'style="width: 10%"' if mode == 'newsfeed': c_symbol = '<td rowspan="2"><a href="'+\ button_href +\ '" class="btn btn-outline-info"><h4>'+\ str(symbol) +'</h4></a></td>' c_signal_column_width = '' c_signal = signal c_entry = str(round(entry, decimal_places)) c_tp = str(round(target_price, decimal_places)) c_sl = str(round(stop_loss, decimal_places)) descr_box = '' +\ ' <table class="table table-sm sa-table-sm">'+\ ' <tbody>'+\ ' <tr>'+\ ' <td '+ c_signal_column_width +' rowspan="2">'+ c_signal +'</td>'+\ c_symbol+\ ' <td style="width: 10%">'+ hd_entry +'</td>'+\ ' <td style="width: 10%">'+ hd_tp +'</td>'+\ ' <td style="width: 60%">'+ hd_sl +'</td>'+\ ' </tr>'+\ ' <tr>'+\ ' <td><h6>'+ c_entry +'</h6></td>'+\ ' <td><h6>'+ c_tp +'</h6></td>'+\ ' <td><h6>'+ c_sl +'</h6></td>'+\ ' </tr>'+\ ' </tbody>'+\ ' </table>' cursor.close() connection.close() return descr_box
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 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_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