diff --git a/.ipynb_checkpoints/README-checkpoint.md b/.ipynb_checkpoints/README-checkpoint.md new file mode 100644 index 0000000..f64a4fd --- /dev/null +++ b/.ipynb_checkpoints/README-checkpoint.md @@ -0,0 +1,168 @@ + + + +--- + +# [Medium Files](https://github.com/dc-aichara/DS-ML-Public/tree/master/Medium_Files) + +## 1. [hyp_tune.ipynb](https://github.com/dc-aichara/DS-ML-Public/blob/master/Medium_Files/hyp_tune.ipynb) + +- A notebook to guide hyperparameters optimization using Bayesian model based optimization. + +Example hyperparameters optimization results table for LightGBM Regressor on Boston Housing data. + + + +Read complete article on [Medium](https://medium.com/analytics-vidhya/hyperparameters-optimization-for-lightgbm-catboost-and-xgboost-regressors-using-bayesian-6e7c495947a9). + +## 2. [Bar_Plot_Animation.py ](https://github.com/dc-aichara/DS-ML-Public/blob/master/Medium_Files/Bar_Plot_Animation.py) +- Creates animation of bar plots using matplotlib python package
+[Read complete tutorial on Medium](https://medium.com/@dc.aichara/making-animated-bar-plots-of-top-16-cryptocurrencies-market-capitalization-price-and-volume-7889788af264)
+[Watch animation on YouTube](https://www.youtube.com/watch?v=jqSuaRpCnro)
+[![YouTube Video](http://img.youtube.com/vi/jqSuaRpCnro/0.jpg)](http://www.youtube.com/watch?v=jqSuaRpCnro) + +## 3. [telegram.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/Medium_Files/telegram.py) +- Telegram chat data extraction and data processing
+[Medium Tutorial](https://medium.com/@dc.aichara/telegram-channel-data-extraction-users-information-chats-and-specific-messages-and-data-21bb54710fd3)
+ +> An example of telegram chats which contain keyword 'bitcoin' or 'btc' + + + + +## 4. [Bitcoin_messages_telegram.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/Medium_Files/Bitcoin_messages_telegram.py) +- Get text messages from telegram groups and channels which contain word 'bitcoin' or 'btc'.
+ +Example: + +```python +>>> tele_btc_messages.head() + +``` + + +## 5. [telegram_user_status.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/Medium_Files/telegram_user_status.py) +- Use to get users who were online in last 24 hours. + +Example: +``` +$ cd DS-ML-Public +$ python telegram_user_status.py 12345 fe3922d77g6wgwgwyu35g46c9 bitgrit +Number of active users in last 24 hours is 1530. + User status +0 Dayal Chand online +1 Sameer recently +2 Dikesh Shah 2019-07-02 01:13:19 +3 Crypto 2019-07-02 00:47:50 +4 Billy 2019-07-02 01:32:49 + +``` +*** + +## [WebScrapers](https://github.com/dc-aichara/DS-ML-Public/tree/master/WebScrapers) + +## 1. [lok_sabha_results.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/WebScrapers/lok_sabha_results.py) +- Get [Lok Sabha elections 2019 results](https://results.eci.gov.in/pc/en/partywise/index.htm) using web scraping technique with requests and BeautifulSoup python packages. + +## 2. [crypto_news_scraper.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/WebScrapers/crypto_news_scraper.py) +- Python script to extract cryptocurries related news from [CoinDesk](https://www.coindesk.com), [Cointelegraph](https://cointelegraph.com) and [cryptonewsz](https://www.cryptonewsz.com). + +### Usages +$ git clone https://github.com/dc-aichara/DS-ML-Public.git
+$ cd DS-ML-Public/WebScrapers
+$ python3 + +```python +>>> from crypto_news_scraper import NewsScrap +>>> news = NewsScrap() +>>> df_coindesk = news.CoinDesk_News() +>>> df_coindesk.head() + category heading ... time source +0 news Dapp.com Closes $1 Million Investment Round Le... ... 2019-09-06 22:00:00 CoinDesk +1 news Telegram Finally Releases Code for Its $1.7 Bi... ... 2019-09-06 21:46:00 CoinDesk +2 news Massive $1 Billion Bitcoin Whale Transaction M... ... 2019-09-06 19:00:00 CoinDesk +3 news Ethereum Picks Early October for Testnet Activ... ... 2019-09-06 18:00:00 CoinDesk +4 news Dapp Data Site DappRadar Raises $2.33 Million ... ... 2019-09-06 17:00:00 CoinDesk + +[5 rows x 6 columns] +>>> df_cointelegraph = news.Cointelegraph_News() +>>> df_cointelegraph.head() + category heading ... time source +0 News Crypto and Blockchain Adoption Grows: 5 Import... ... 2019-09-09 11:15:03 CoinTelegraph +1 News World’s ‘First’ Blockchain Smartphone to Becom... ... 2019-09-09 08:15:03 CoinTelegraph +2 News Ethereum's Istanbul Hard Fork Implementation D... ... 2019-09-09 08:15:03 CoinTelegraph +3 News Blockchain Startup DappRadar Raises $2.33M Fro... ... 2019-09-09 08:15:03 CoinTelegraph +4 News Huobi’s Research Arm to Partner with the Unive... ... 2019-09-09 07:15:03 CoinTelegraph + +[5 rows x 6 columns] +>>> df_all = news.get_all_news() +Getting news from CoinDesk!! +Getting news from Cointelegraph!! +Getting news from cryptonewsz!! This will take 1-2 mintues. 😉 +>>> df_all.head() + category heading ... time source +0 news Dapp.com Closes $1 Million Investment Round Le... ... 2019-09-06 22:00:00 CoinDesk +1 news Telegram Finally Releases Code for Its $1.7 Bi... ... 2019-09-06 21:46:00 CoinDesk +2 news Massive $1 Billion Bitcoin Whale Transaction M... ... 2019-09-06 19:00:00 CoinDesk +3 news Ethereum Picks Early October for Testnet Activ... ... 2019-09-06 18:00:00 CoinDesk +4 news Dapp Data Site DappRadar Raises $2.33 Million ... ... 2019-09-06 17:00:00 CoinDesk + +[5 rows x 6 columns] + +``` +## 3. [inshorts_news_scraper.py](https://github.com/dc-aichara/DS-ML-Public/blob/master/WebScrapers/inshorts_news_scraper.py) + +### Usages +$ git clone https://github.com/dc-aichara/DS-ML-Public.git
+$ cd DS-ML-Public/WebScrapers
+$ python3 + +```python +>>> from inshorts_news_scraper import InshortsNews +>>> news = InshortsNews('business') +>>> df_b = news.get_news() +>>> df_b.head() + headings news short_by time category +0 BSNL plans to fire 30% contract staff unpaid s... BSNL is reportedly planning to lay off about 3... Anushka Dixit 2019-09-09 23:35:00 business +1 SAT overturns SEBI's 2 year-ban on PwC in ₹7,8... The Securities Appellate Tribunal (SAT) on Mon... Anushka Dixit 2019-09-09 21:29:00 business +2 Nissan CEO Hiroto Saikawa to step down on Sept... Nissan CEO Hiroto Saikawa will step down on Se... Dharna 2019-09-09 21:08:00 business +3 British Airways pilots begin 2-day strike over... British Airways pilots began a two-day strike ... Anushka Dixit 2019-09-09 20:18:00 business +4 SEBI making e-voting app for retail investors ... Markets regulator SEBI is working on an e-voti... Dharna 2019-09-09 18:04:00 business +>>> df_all = news.get_all_news() +>>> df_all.head() + headings news short_by time category +0 Conflict between India, Pak less heated now th... Speaking about tensions between India and Paki... Arshiya Chopra 2019-09-10 08:50:00 national +1 Bengaluru woman loses ₹95,000 after calling fa... A Bengaluru woman lost ₹95,000 after calling a... Pragya Swastik 2019-09-10 08:25:00 national +2 IAS officer who resigned is traitor, should go... BJP MP Anantkumar Hegde has called IAS officer... Apaar Sharma 2019-09-09 23:28:00 national +3 Stop drama, stand up, CISF allegedly tells wom... Virali Modi, a disability rights activist, has... Anmol Sharma 2019-09-09 23:10:00 national +4 Tech firms may be allowed to sell users' publi... India is reportedly mulling guidelines which w... Dharna 2019-09-09 23:00:00 national + +``` +## 4. [Japanese News Scraper](https://github.com/dc-aichara/DS-ML-Public/blob/master/WebScrapers/japanese_news_scraper.py) + +### Usage: +```python +>>> from japanese_news_scraper import JapaneseNewsScrap +>>> jp_news = JapaneseNewsScrap(24*60*60) +>>> df_coinpost = jp_news.get_CoinPost_news() +>>> df_coinpost.head() + time heading ... link source +0 2019-10-08 15:30:48 米リップル社、大学ブロックチェーン研究イニシアチブで年次大会を初開催 ... https://coinpost.jp/?p=111090 CoinPost +1 2019-10-08 15:29:29 米NBAのキングス、ファン向けの独自仮想通貨発行を発表 ... https://coinpost.jp/?p=111088 CoinPost +2 2019-10-08 14:59:53 金融庁がブロックチェーン実験結果を公表、金融機関の顧客KYC情報を共有 ... https://coinpost.jp/?p=111189 CoinPost +3 2019-10-08 14:26:52 Chainlinkの新フレームワーク発表で、仮想通貨LINKが高騰 協賛にIntelなど ... https://coinpost.jp/?p=111080 CoinPost +4 2019-10-08 14:04:36 イーサリアム企業連合、ブロックチェーン仕様の新バージョン発表 「Devcon 5」で検証実施 ... https://coinpost.jp/?p=111170 CoinPost + +[5 rows x 5 columns] + +``` + + +## [My Medium Articles](https://medium.com/@dcaichara) +- [Hyperparameters Optimization for LightGBM, CatBoost and XGBoost Regressors using Bayesian Optimization.](https://medium.com/game-of-data/hyperparameters-optimization-for-lightgbm-catboost-and-xgboost-regressors-using-bayesian-6e7c495947a9) +- [Google Spreadsheets Automation with Python](https://medium.com/@dcaichara/play-with-google-spreadsheets-with-python-301dd4ee36eb) +- [Telegram Group/Channel Data Extraction (User’s information, chats, and specific messages), and Data Processing](https://medium.com/@dcaichara/telegram-channel-data-extraction-users-information-chats-and-specific-messages-and-data-21bb54710fd3) +- [12 Things to know about Jupyter Notebook Markdown](https://medium.com/@dcaichara/12-things-to-know-about-jupyter-notebook-markdown-3f6cef811707) +- [Making Animated Bar Plots of Top 16 CryptoCurrencies (Market Capitalization, Price and Volume)](https://medium.com/@dcaichara/telegram-channel-data-extraction-users-information-chats-and-specific-messages-and-data-21bb54710fd3) +- [A Complete Date-Time Guide for Data Scientist in Python](https://medium.com/analytics-vidhya/a-complete-date-time-guide-for-data-scientist-in-python-cd0b1cfb5e74) +- [Coin Hopping Attack : How did c0ban (First ICO from Japan) deal with it using LWMA ?](https://medium.com/@dcaichara/coin-hopping-attack-how-did-c0ban-first-ico-from-japan-deal-with-it-using-lwma-9facda2f02b6) diff --git a/Medium_Files/dashboard_demo/.gitignore b/Medium_Files/dashboard_demo/.gitignore new file mode 100644 index 0000000..0205d62 --- /dev/null +++ b/Medium_Files/dashboard_demo/.gitignore @@ -0,0 +1,2 @@ +*.pyc +.DS_Store diff --git a/Medium_Files/dashboard_demo/Procfile b/Medium_Files/dashboard_demo/Procfile new file mode 100644 index 0000000..41135e6 --- /dev/null +++ b/Medium_Files/dashboard_demo/Procfile @@ -0,0 +1 @@ +web: gunicorn index:server \ No newline at end of file diff --git a/Medium_Files/dashboard_demo/app.py b/Medium_Files/dashboard_demo/app.py new file mode 100644 index 0000000..fc2ed25 --- /dev/null +++ b/Medium_Files/dashboard_demo/app.py @@ -0,0 +1,6 @@ +import dash +external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] +app = dash.Dash(__name__, external_stylesheets=external_stylesheets) +server = app.server +app.config.suppress_callback_exceptions = True + diff --git a/Medium_Files/dashboard_demo/data.py b/Medium_Files/dashboard_demo/data.py new file mode 100644 index 0000000..ebe56a4 --- /dev/null +++ b/Medium_Files/dashboard_demo/data.py @@ -0,0 +1,36 @@ +from PriceIndices import Indices, MarketHistory +import pandas as pd +import numpy as np +history = MarketHistory() + + +def get_coin_data(crypto='bitcoin', start_date='20130428', end_date='20200501', save_data=None): + df = history.get_price(crypto, start_date, end_date) + df_bi = Indices.get_bvol_index(df) + df_bi.drop('price', axis=1, inplace=True) + df_rsi = Indices.get_rsi(df) + df_rsi.drop(['price', 'RS_Smooth', 'RSI_1'], axis=1, inplace=True) + df_sma = Indices.get_simple_moving_average(df) + df_sma.drop(['price'], axis=1, inplace=True) + df_bb = Indices.get_bollinger_bands(df) + df_bb.drop(['price'], axis=1, inplace=True) + df_ema = Indices.get_exponential_moving_average(df, [20, 50]) + df_ema.drop(['price'], axis=1, inplace=True) + df_macd = Indices.get_moving_average_convergence_divergence(df) + df_macd.drop(['price',], axis=1, inplace=True) + + df = pd.merge(df, df_macd, on='date', how='left') + df = pd.merge(df, df_rsi, on='date', how='left') + df = pd.merge(df, df_bi, on='date', how='left') + df = pd.merge(df, df_bb, on='date', how='left') + df = pd.merge(df, df_ema, on='date', how='left') + df = pd.merge(df, df_sma, on='date', how='left') + del df_rsi, df_macd, df_sma, df_bb, df_bi + df.rename(columns={'RSI_2': 'RSI'}, inplace=True) + df.fillna(0) + for col in df.columns[1:]: + df[col] = np.round(df[col], 2) + while save_data: + df.to_csv('data.csv', index=False) + break + return df diff --git a/Medium_Files/dashboard_demo/index.py b/Medium_Files/dashboard_demo/index.py new file mode 100644 index 0000000..e7916c7 --- /dev/null +++ b/Medium_Files/dashboard_demo/index.py @@ -0,0 +1,431 @@ +from app import app +from app import server +import flask +import json +import dash_html_components as html +import dash_core_components as dcc +from dash.dependencies import Input, Output +from datetime import datetime +import dash_table +import pandas as pd +from data import get_coin_data +from users import users_info + +coin_list = ['bitcoin', 'ethereum', 'ripple', 'bitcoin-cash'] + +colors = { + 'background': '#4A235A', + 'background2': 'black', + 'text': 'yellow' +} +tabs_styles = { + 'height': '51px' +} +tab_style = { + 'borderBottom': '1px solid #d6d6d6', + 'padding': '2px', + 'fontWeight': 'bold' +} + +tab_selected_style = { + 'borderTop': '1px solid #d6d6d6', + 'borderBottom': '1px solid #d6d6d6', + 'backgroundColor': 'black', + 'color': 'yellow', + 'padding': '10px' +} + +y_axis = { + 'title': 'Price', + 'showspikes': True, + 'spikedash': 'dot', + 'spikemode': 'across', + 'spikesnap': 'cursor', + } + +x_axis = { + 'title': 'Time', + 'showspikes': True, + 'spikedash': 'dot', + 'spikemode': 'across', + 'spikesnap': 'cursor', + } + +user_pwd, user_names = users_info() + +_app_route = '/' + +# Create a login route +@app.server.route('/login', methods=['POST']) +def route_login(): + data = flask.request.form + username = data.get('username') + password = data.get('password') + + if username not in user_pwd.keys() or user_pwd[username] != password: + return flask.redirect('/login') + else: + + # Return a redirect with + rep = flask.redirect(_app_route) + + # Here we just store the given username in a cookie. + # Actual session cookies should be signed or use a JWT token. + rep.set_cookie('custom-auth-session', username) + return rep + + +# Simple dash component login form. +login_form = html.Div([ + html.Form([ + dcc.Input(placeholder='username', name='username', type='text'), + dcc.Input(placeholder='password', name='password', type='password'), + html.Button('Login', type='submit') + ], action='/login', method='post') +]) + +# create a logout route +@app.server.route('/logout', methods=['POST']) +def route_logout(): + # Redirect back to the index and remove the session cookie. + rep = flask.redirect('/login') + rep.set_cookie('custom-auth-session', '', expires=0) + return rep + + +app.layout = html.Div([html.H1("Cryptocurrency Indicators Dashboard", + style={ + 'textAlign': 'center', + "background": "yellow"}), + html.Div(id='custom-auth-frame'), # Input for buttons + html.Div(id='custom-auth-frame-1', # Output after Login or Logout + style={ + 'textAlign': 'right', + "background": "black", + } + ), + html.Div(['Date selector for graphs', + dcc.DatePickerRange( + id='date-input', + stay_open_on_select=False, + min_date_allowed=datetime(2013, 4, 28), + max_date_allowed=datetime.now(), + initial_visible_month=datetime.now(), + start_date=datetime(2019, 1, 1), + end_date=datetime.now(), + number_of_months_shown=2, + month_format='MMMM,YYYY', + display_format='YYYY-MM-DD', + style={ + 'color': '#11ff3b', + 'font-size': '18px', + 'margin': 0, + 'padding': '8px', + 'background': 'yellow', + } + ), + 'Select coin here', + dcc.Dropdown(id='dropdown', + options=[{'label': i, 'value': i} for i in coin_list], + value='bitcoin', + optionHeight=10, + style={ + 'height': '50px', + 'font-weight': 100, + 'font-size': '16px', + 'line-height': '10px', + 'textAlign': 'center', + 'color': 'gray', + 'margin': 0, + 'padding': '8px', + 'background': 'yellow', + 'position': 'middle', + 'display': 'inline-block', + 'width': '150px', + 'vertical-align': 'middle', + } + ), + html.Div(id='date-output'), + html.Div(id='intermediate-value', style={'display': 'none'}), + ], className="row ", + style={'marginTop': 0, 'marginBottom': 0, 'font-size': 30, 'color': 'white', + 'display': 'inline-block'}), + dcc.Tabs(id="all-tabs-inline", value='tab-1', children=[ + dcc.Tab(label='Simple Moving Average', value='tab-1', style=tab_style, selected_style=tab_selected_style), + dcc.Tab(label='Volatility Index', value='tab-2', style=tab_style, selected_style=tab_selected_style), + dcc.Tab(label='Relative Strength Index', value='tab-3', style=tab_style, selected_style=tab_selected_style), + dcc.Tab(label='Moving Average Divergence Convergence', value='tab-4', style=tab_style, selected_style=tab_selected_style), + dcc.Tab(label='Exponential Moving Average', value='tab-5', style=tab_style, selected_style=tab_selected_style), + dcc.Tab(label='Bollinger Bands', value='tab-6', style=tab_style, + selected_style=tab_selected_style), + ], style=tabs_styles, + colors={ + "border": "yellow", + "primary": "red", + "background": "orange" + }), + html.Div(id='graph-output'), + html.Div(children=[html.H1(children="Data Table", # html for table + style={ + 'textAlign': 'center', + "background": "yellow"}) + ] + ), + html.Div(children=[html.Table(id='table'), html.Div(id='table-output')]), + html.Div(children=[dcc.Markdown( # markdown + " © 2019 [DCAICHARA](https://github.com/dc-aichara) All Rights Reserved.")], style={ + 'textAlign': 'center', + "background": "yellow"}), + ], + style={"background": "#000080"} + + ) + + +def get_data_table(df): + df['date'] = pd.to_datetime(df['date']) + data_table = dash_table.DataTable( + id='datatable-data', + data=df.to_dict('records'), + columns=[{'id': c, 'name': c} for c in df.columns], + style_table={'overflowY': 'scroll'}, + fixed_rows={'headers': True, 'data': 10}, + style_cell={'width': '100px'}, + style_header={ + 'backgroundColor': 'rgb(230, 230, 230)', + 'fontWeight': 'bold' + } + ) + return data_table + + +@app.callback(Output('intermediate-value', 'children'), + [Input('dropdown', 'value')]) +def get_data(option): + df = get_coin_data(crypto=option, save_data=None) + return df.to_json(date_format='iso', orient='split') + + +@app.callback([Output('graph-output', 'children'), + Output('table-output', 'children'), + Output('custom-auth-frame-1', 'children')], + [Input('intermediate-value', 'children'), + Input('all-tabs-inline', 'value'), + Input('date-input', 'start_date'), + Input('date-input', 'end_date')]) +def render_content(data, tab, start_date, end_date): + session_cookie = flask.request.cookies.get('custom-auth-session') + + if not session_cookie: + # If there's no cookie we need to login. + return [html.Div(html.H2("Charts will be displayed here after user's authentication."), + style={'textAlign': 'center', + 'color': 'red'}), '', login_form] + else: + df = pd.read_json(data, orient='split') + data_table = get_data_table(df) + df = df[(df.date >= start_date) & (df.date <= end_date)] + logout_output = html.Div(children=[html.Div(html.H3('Hello {} !'.format(user_names[session_cookie])), + style={'display': 'inline-block'}), + html.Div(dcc.LogoutButton(logout_url='/logout'), + style={'display': 'inline-block'})], + style={ + 'color': 'green', + 'height': '50px' + } + ) + graph_output = '' + + if tab == 'tab-1': + graph_output = html.Div([ + html.H3(dcc.Graph( + id='SMA', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['SMA'], 'type': 'line', 'name': 'SMA', 'secondary_y':True}, + ], + 'layout': { + 'title': 'Simple Moving Average', + 'height': 700, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + } + } + } + )) + ]) + elif tab == 'tab-2': + graph_output = html.Div([ + html.H3( + dcc.Graph( + id='BVOL', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['BVOL_Index'], 'type': 'line', 'name': 'VOL Index', 'yaxis':'y2'}, + ], + 'layout':{ + 'title': 'Volatility Index', + 'height': 700, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + }, + 'legend': {'x': 1.04, 'y': 1.04}, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'yaxis2': { + 'title': 'Volatility Index', + 'titlefont': {'color': 'orange'}, + 'tickfont': {'color': 'orange'}, + 'overlaying': 'y', + 'side': 'right', + 'showspikes': True, + 'spikedash': 'dot', + 'spikemode': 'across', + 'spikesnap': 'cursor', + }, + } + } + ) + ), + + ]) + elif tab == 'tab-3': + graph_output = html.Div([ + html.H3(dcc.Graph( + id='RSI', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['RSI'], 'type': 'line', 'name': 'RSI', 'yaxis': 'y2'}, + ], + 'layout': { + 'title': 'Relative Strength Index', + 'height': 700, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + }, + 'legend': {'x': 1.04, 'y': 1.04}, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'yaxis2': { + 'title': 'Relative Strength Index', + 'titlefont': {'color': 'orange'}, + 'tickfont': {'color': 'orange'}, + 'overlaying': 'y', + 'side': 'right', + 'showspikes': True, + 'spikedash': 'dot', + 'spikemode': 'across', + 'spikesnap': 'cursor', + }, + } + } + )), + ]) + elif tab == 'tab-4': + graph_output = html.Div([ + html.H3(dcc.Graph( + id='MACD', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['MACD'], 'type': 'line', 'name': 'MACD', 'yaxis': 'y2'}, + ], + 'layout': { + 'title': 'Moving Average Divergence Convergence', + 'height': 700, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + }, + 'legend': {'x': 1.04, 'y': 1.04}, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'yaxis2': { + 'title': 'Moving Average Divergence Convergence', + 'titlefont': {'color': 'orange'}, + 'tickfont': {'color': 'orange'}, + 'overlaying': 'y', + 'side': 'right', + 'showspikes': True, + 'spikedash': 'dot', + 'spikemode': 'across', + 'spikesnap': 'cursor', + }, + } + } + )), + + ]) + elif tab == 'tab-5': + graph_output = html.Div([ + html.H3(dcc.Graph( + id='EMA', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['EMA_20'], 'type': 'line', 'name': 'EMA-20'}, + {'x': df['date'], 'y': df['EMA_50'], 'type': 'line', 'name': 'EMA-50'}, + ], + 'layout': { + 'title': 'Exponential Moving Average', + 'height': 700, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + } + } + } + )), + + ]) + elif tab == 'tab-6': + graph_output = html.Div([ + html.H3(dcc.Graph( + id='SMA', + figure={ + 'data': [ + {'x': df['date'], 'y': df['price'], 'type': 'line', 'name': 'Price'}, + {'x': df['date'], 'y': df['BB_upper'], 'type': 'line', 'name': 'Upper BB'}, + {'x': df['date'], 'y': df['BB_lower'], 'type': 'line', 'name': 'Upper BB'}, + ], + 'layout': { + 'title': 'Bollinger Bands', + 'height': 700, + 'xaxis': x_axis, + 'yaxis': y_axis, + 'plot_bgcolor': colors['background2'], + 'paper_bgcolor': colors['background'], + 'font': { + 'color': colors['text'], + 'size':18 + } + } + } + )), + + ]) + return [graph_output, data_table, logout_output] + + +if __name__ == '__main__': + app.run_server(debug=True) diff --git a/Medium_Files/dashboard_demo/requirements.txt b/Medium_Files/dashboard_demo/requirements.txt new file mode 100644 index 0000000..5a6e950 --- /dev/null +++ b/Medium_Files/dashboard_demo/requirements.txt @@ -0,0 +1,12 @@ +dash==1.6.1 +dash-core-components==1.5.1 +dash-html-components==1.0.2 +dash-auth==1.3.2 +dash-table==4.5.1 +Flask==1.0.2 +gunicorn==19.9.0 +numpy==1.15.4 +pandas==0.23.4 +plotly==4.2.1 +PriceIndices==1.1.1 +lxml==4.4.1 \ No newline at end of file diff --git a/Medium_Files/dashboard_demo/users.py b/Medium_Files/dashboard_demo/users.py new file mode 100644 index 0000000..12f6dda --- /dev/null +++ b/Medium_Files/dashboard_demo/users.py @@ -0,0 +1,11 @@ + +user_pwd = {'dash': 'dash@123', + 'dash1': 'dash1@123', + } +user_names = {'dash': ', welcome to the crypto indicators dashboard', + 'dash1': ', welcome to the crypto indicators dashboard', + } + + +def users_info(): + return user_pwd, user_names