├── scripts
├── __init__.py
├── fundamentals.py
└── plotly_layouts.py
├── .idea
├── .gitignore
├── vcs.xml
├── inspectionProfiles
│ └── profiles_settings.xml
├── modules.xml
├── misc.xml
└── Webpage_Tutorial.iml
├── requirements.txt
├── run.py
├── templates
├── home.html
└── layouts
│ └── main.html
├── README.md
└── static
└── css
├── style.css
├── normalize.css
└── skeleton.css
/scripts/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | datapane==0.14.0
2 | Flask==2.2.1
3 | pandas==1.2.2
4 | plotly==5.9.0
5 | yfinance==0.1.74
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 | 12 |
13 | 14 |
23 |
24 |
25 |
26 |
27 |
28 | {% endblock %}
--------------------------------------------------------------------------------
/scripts/fundamentals.py:
--------------------------------------------------------------------------------
1 | import yfinance as yf
2 | import pandas as pd
3 | import scripts.plotly_layouts as ply
4 | import datetime as dt
5 | import datapane as dp
6 |
7 | def get_dividends(ticker):
8 |
9 | ticker = yf.Ticker(ticker)
10 |
11 | ## Dividends
12 | dividends = ticker.get_dividends()
13 | dividends = dividends.to_frame()
14 | dividends = dividends.reset_index()
15 | dividends["year"] = dividends["Date"].dt.year
16 | dividends = dividends.groupby("year")["Dividends"].sum()
17 | dividends = dividends.to_frame()
18 | dividends = dividends.reset_index()
19 |
20 | return ply.create_plotly(dividends)
21 |
22 | def upload_to_datapane(plot, title):
23 | report = dp.Report(dp.Plot(plot)) # Create a report
24 | report.upload(name=title, open=True, visibility='PUBLIC')
25 |
26 | print("success")
27 |
28 | return True
29 |
30 |
31 | if __name__ == '__main__':
32 | plot = get_dividends("AAPL")
33 | upload_to_datapane(plot, "AAPL Dividends Plot")
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## How to use this template?
3 |
4 | This template is based on python and the flask framework.
5 | Here is the full step-by-step guide on how to use it:
6 | ([Link](https://wire.insiderfinance.io/develop-your-own-financial-dashboard-with-flask-and-plotly-46f8150364e6))
7 |
8 | ## Quick start in your terminal
9 | - git clone https://github.com/AntonioBlago/Webpage_Tutorial_2.git
10 | - cd Webpage_Tutorial_2
11 | - conda create --name flask_tutorial_2
12 | - pip install -r requirements.txt
13 | - conda activate flask_tutorial_2
14 |
15 |
16 | ## Run the app and see the dashboard
17 | - python run.py
18 |
19 | ## Deploy your app to [pythonanywhere*](https://www.pythonanywhere.com/?affiliate_id=007ce8a4)
20 | - Part 4: Flask tutorial: How to deploy and publish an app on pythonanywhere ([Link](https://antonioblago.medium.com/flask-tutorial-how-to-deploy-and-publish-an-app-on-pythonanywhere-225314160914))
21 |
22 |
23 | ## Support me 👋
24 |
25 |
26 |
27 |
28 | [![medium][medium-badge]][medium-url]
29 | [![paypal][paypal-badge]][paypal-url]
30 |
31 |
32 |
33 |
34 | [medium-badge]: https://img.shields.io/static/v1?color=292a2c&label=%20&labelColor=100f0d&logo=medium&logoColor=ffffff&message=Medium&style=for-the-badge
35 | [paypal-badge]:https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif
36 |
37 |
38 | [medium-url]: https://antonioblago.medium.com
39 | [paypal-url]: https://www.paypal.com/donate/?hosted_button_id=4VVNDJLCR7DCW
40 |
--------------------------------------------------------------------------------
/scripts/plotly_layouts.py:
--------------------------------------------------------------------------------
1 |
2 | import plotly.express as px
3 |
4 | def create_plotly(data):
5 |
6 | color_palette = ["#557B83","#39AEA9","#A2D5AB","#E5EFC1"]
7 |
8 | fig = px.bar(data,
9 | x="year",
10 | y="Dividends",
11 | title="Dividends",
12 | barmode='group',
13 | color_discrete_sequence =color_palette[:1])
14 | fig = fig_layout(fig, ytitle= "", ytickfromat = None, xtitle= "Year", ticker= "AAPL",
15 | legendtitle = "Debt and Liabilites", type_of_plot = "Dividends", yaxis_tickprefix='$',)
16 | fig
17 |
18 | return fig
19 |
20 |
21 | def fig_layout(fig, ytitle, ytickfromat, xtitle,ticker, legendtitle, type_of_plot, yaxis_tickprefix=None):
22 | fig.update_layout(
23 | yaxis={
24 | "title": ytitle,
25 | "tickformat": ytickfromat,
26 |
27 | },
28 | yaxis_tickprefix = yaxis_tickprefix,
29 | paper_bgcolor="#FFFFFF", # rgba(0,0,0,0)',
30 | plot_bgcolor="#FFFFFF", # 'rgba(0,0,0,0)',
31 | # autosize=True,
32 | legend=dict(
33 | title=legendtitle,
34 | yanchor="top",
35 | y=0.99,
36 | xanchor="left",
37 | x=0.01
38 | ),
39 | title={
40 | 'text': '{} - {}
tenxassets.com'.format(type_of_plot,ticker),
41 | 'y': 0.85,
42 | 'x': 0.5,
43 | 'xanchor': 'center',
44 | 'yanchor': 'top'},
45 | titlefont=dict(
46 | size=12,
47 | color="black"),
48 |
49 | template="simple_white",
50 | xaxis=dict(
51 | title=xtitle,
52 | showticklabels=True),
53 | showlegend=True,
54 | font=dict(
55 | # family="Courier New, monospace",
56 | size=12,
57 | color="black"
58 | ),
59 | )
60 | return fig
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/templates/layouts/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {% block head %} {% endblock %} 24 | 25 |
62 |