Skip to content

Commit

Permalink
Merge pull request #3 from jacquessham/development
Browse files Browse the repository at this point in the history
v0.0.3
  • Loading branch information
jacquessham authored Aug 21, 2024
2 parents f0f442c + b056578 commit 8049802
Show file tree
Hide file tree
Showing 30 changed files with 376 additions and 109 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ The first step is to replicate the sankey chart found in this <a href="https://w
The plan is to develop a dashboard displays the financials of selected publicly traded companies, the details can be found in the [The Plan](plan) folder.

## Dashboard
The Dashboard is under development, but you may check out the progress in the [Dashboard](dashboard) folder.
The Dashboard is under development and only have Google's (GOOGL) selected period of data. You may check out the progress in the [Dashboard](dashboard) folder. More details will be available soon.

<br>
<img src=gallery/income_v002.png>

Screenshot of latest development.

## Reference
<a href="https://www.reddit.com/r/dataisbeautiful/comments/10ur1ya/oc_how_google_makes_money_its_2022_income/">Google Financial Report in Sankey Chart</a>
Expand Down
2 changes: 1 addition & 1 deletion dashboard/balancesheet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
import balancesheet_googl_poc as example
import data.googl.poc_charts.balancesheet_googl_poc as example # For poc purpose, delete later
from data.googl.balance_sheet_googl import *


Expand Down
2 changes: 1 addition & 1 deletion dashboard/cashflow_statement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
import cashflow_googl_poc as example
import data.googl.poc_charts.cashflow_googl_poc as example # For poc purpose, delete later
from data.googl.cashflow_googl import *


Expand Down
22 changes: 14 additions & 8 deletions dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
[Input('dashboard-tabs','value'), Input('company-choices','value')])
def display_period_dropdown(tab, company):
if tab in companies_data[company]:
return companies_data[company][tab]['periods'], \
companies_data[company][tab]['periods'][0]
# Sort Periods here
periods_avail = companies_data[company][tab]['periods']
periods_avail = periods_dropdown(periods_avail)
return periods_avail, periods_avail[0]
# If information is not available
return [], None

Expand All @@ -44,38 +46,42 @@ def display_income_statement(tab, company, period):
if tab == tab_labels[0]:
curr_data = companies_data[company][tab]['data']
curr_data = curr_data[curr_data['Period']==period]
return [html.Div(
return [html.Div([
# P/H1 here if needed
# html.H2(f'{company}\'s Income Statement during {period}'),
# Plotly Chart
dcc.Graph(
figure=income_statement_figure(
company, curr_data
),
style={'height':graph_height}
))]
)] # End Div
)] # End Outer array
# Balance Sheet
if tab == tab_labels[1]:
curr_data = companies_data[company][tab]['data']
curr_data = curr_data[curr_data['Period']==period]
return [html.Div(
return [html.Div([
# P/H1 here if needed
# html.H2(f'{company}\'s Income Statement during {period}'),
# Plotly Chart
dcc.Graph(
figure=balancesheet_figure(company, curr_data),
style={'height':graph_height}

))]
)])]
# Cashflow Statement
curr_data = companies_data[company][tab]['data']
curr_data = curr_data[curr_data['Period']==period]
return [html.Div(
return [html.Div([
# P/H1 here if needed
# html.H2(f'{company}\'s Income Statement during {period}'),
# Plotly Chart
dcc.Graph(
figure=cashflow_statement_figure(company, curr_data),
style={'height':graph_height}

))]
)])]

# Initiate dashboard
if __name__ == '__main__':
Expand Down
27 changes: 27 additions & 0 deletions dashboard/dashboard_structure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
from dash import dcc, html


# Sort periods in Year, then quarter in desc order
## The format must be FYXX or XXQX
def periods_dropdown(periods):
periods_temp = []
for period in periods:
# If this is a Annual report (10-K)
if 'FY' in period:
year = int(period[2:])
quarter = 5 # To rank after all 10-Qs
# If this is a Quarterly report (10-Q)
elif 'Q' in period:
year = int(period[:2])
quarter = int(period[3])
# If this is an Intreim report (Semiannual)
elif 'H' in period:
year = int(period[:2])
quarter = int(period[3])
else:
continue

# (labels, year in int, quarter in int)
periods_temp.append((period, year, quarter))
periods_temp = sorted(periods_temp, key=lambda x: (-x[1],-x[2]))

# Only returning the labels
return [t[0] for t in periods_temp]

def create_tabs(tab_labels):
tabs = []
for tab_label in tab_labels:
Expand Down
7 changes: 5 additions & 2 deletions dashboard/data/Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Data
This is the Data folder where the dashboard administrator will be preparing the required data to run the dashoard. This directory hosts a variety of publicly traded companies, while each folder represents a company and contains the necessarily dataset and scripts. More instructions will be coming soon...
This is the Data folder where the dashboard administrator will be preparing the required data to run the dashoard. This directory hosts a variety of publicly traded companies, while each folder represents a company and contains the necessarily dataset and scripts. The sample dataset and template files are available in the <i>dataset</i> folder in each company folder. More instructions will be coming soon...

## Google (GOOGL)
The Google folder contains the supporting scripts to create sankey charts on the dashboard, as well as the dataset templates and sample datasets. More instruction in the [Google](googl) folder.
The Google folder contains the supporting scripts to create sankey charts on the dashboard, as well as the dataset templates and sample datasets. More instruction on data parparation in the [Google](googl) folder.

## Template
If you would like to add more company options, you may create more plug-ins. Here are the instructions and guidelines in the [Template](template) folder. Details are coming soon...
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dashboard/data/googl/Images/googl_cshfsmt_cal1_explain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions dashboard/data/googl/data_balsht_googl.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def get_data(df):

## Long-term Asset
for i in range(5,12):
## Node 9 (Intangile Assets, net) stopped reporting in FY23 onward
if i == 9 and i not in df['Node_num'].tolist():
## Skip this node if the entry is missing in the CSV file
continue
curr_value = df[df['Node_num']==i]['Value'].values[0]
link_temp = get_link_direction(i, 13, curr_value,'asset')
## Add links from current node to total asset
Expand Down
21 changes: 12 additions & 9 deletions dashboard/data/googl/data_incsmt_googl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def get_data(df):
# Hardcode the colors
nodes_colors = ['gray']*10 + ['red'] + ['green'] + ['red']*4
# Map each KPI with the preassigned index number in nodes_label
df_temp = {'Items': [k for k in nodes.keys()], 'Node_num':[nodes[k] for k in nodes.keys()]}
df_temp = {'Items': [k for k in nodes.keys()],
'Node_num':[nodes[k] for k in nodes.keys()]}
df = pd.merge(df, pd.DataFrame(df_temp), on='Items', how='inner')

# Add with itemized revenue
Expand All @@ -55,9 +56,11 @@ def get_data(df):
links = add_node_to_link(links, 3, 8, curr_value, 'lightgray')

## Revenue less Other Revenue
links = add_node_to_link(links, 8, 9, srv_value, 'lightgray') # Service Revenue
### Service Revenue
links = add_node_to_link(links, 8, 9, srv_value, 'lightgray')
### Google Clouds
links = add_node_to_link(links, 4, 9,
df[df['Node_num']==4]['Value'].values[0],'lightgray') # Google Clouds
df[df['Node_num']==4]['Value'].values[0],'lightgray')

## Other Revenue - Hedging Gain and Other Bets
for i in range(5,7):
Expand All @@ -72,14 +75,14 @@ def get_data(df):
## Income from Operation
inc_op = 0
### Other income, net
curr_value = -1* df[df['Node_num']==16]['Value'].values[0]
if curr_value >= 0:
links = add_node_to_link(links, 11, 16, curr_value, 'pink')
curr_value = df[df['Node_num']==16]['Value'].values[0]
if curr_value < 0:
links = add_node_to_link(links, 11, 16, -1*curr_value, 'pink')
nodes_colors.append('red')
else:
links = add_node_to_link(links, 16, 11, curr_value, 'lightgreen')
nodes_colors.append('green')
inc_op += curr_value
links = add_node_to_link(links, 16, 11, curr_value, 'lightgray')
nodes_colors.append('gray')
inc_op += -1*curr_value

### EBIT
ebit = 0
Expand Down
69 changes: 69 additions & 0 deletions dashboard/data/googl/dataset/googl_balancesheet_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"Items","Period","Value"
"Cash and Cash Equivalents","FY22",21879
"Marketable Securities","FY22",91883
"Accounts Receivale","FY22",40258
"Inventory","FY22",2670
"Other Current Assets","FY22",8105
"Non-marketable Securities","FY22",30492
"Deferred Income Taxes","FY22",5261
"Property and Equipment, net","FY22",112668
"Operating Lease Assets","FY22",14381
"Intangible Assets, net","FY22",2084
"Goodwill","FY22",28960
"Other Non-current Assets","FY22",6623
"Account Payables","FY22",5128
"Accrued Compensation and Benefits","FY22",14028
"Accrued Expenses and Other Current Liabilities","FY22",37866
"Accrued Revenue Share","FY22",8370
"Deferred Revenue","FY22",3908
"Long-term Debt","FY22",14701
"Deferred Revenue, non-current","FY22",599
"Operating Lease Liabilities","FY22",12501
"Other Long-term Liabilities","FY22",12019
"Retained Earnings less Accumulated Loss","FY22",195563
"Common Stocks","FY22",60581
"Cash and Cash Equivalents","FY23",24048
"Marketable Securities","FY23",86868
"Accounts Receivale","FY23",47964
"Inventory","FY23",0
"Other Current Assets","FY23",12650
"Non-marketable Securities","FY23",31008
"Deferred Income Taxes","FY23",12169
"Property and Equipment, net","FY23",134345
"Operating Lease Assets","FY23",14091
"Goodwill","FY23",29198
"Other Non-current Assets","FY23",10051
"Account Payables","FY23",7493
"Accrued Compensation and Benefits","FY23",15140
"Accrued Expenses and Other Current Liabilities","FY23",46168
"Accrued Revenue Share","FY23",8876
"Deferred Revenue","FY23",4137
"Long-term Debt","FY23",13253
"Deferred Revenue, non-current","FY23",911
"Operating Lease Liabilities","FY23",12460
"Other Long-term Liabilities","FY23",10575
"Retained Earnings less Accumulated Loss","FY23",211247
"Common Stocks","FY23",72132
"Cash and Cash Equivalents","23Q3",30702
"Marketable Securities","23Q3",89233
"Accounts Receivale","23Q3",41020
"Inventory","23Q3",2957
"Other Current Assets","23Q3",12398
"Non-marketable Securities","23Q3",30907
"Deferred Income Taxes","23Q3",10983
"Property and Equipment, net","23Q3",125705
"Operating Lease Assets","23Q3",14199
"Intangible Assets, net","23Q3",1833
"Goodwill","23Q3",29146
"Other Non-current Assets","23Q3",7628
"Account Payables","23Q3",5803
"Accrued Compensation and Benefits","23Q3",12562
"Accrued Expenses and Other Current Liabilities","23Q3",55602
"Accrued Revenue Share","23Q3",8025
"Deferred Revenue","23Q3",4303
"Long-term Debt","23Q3",13781
"Deferred Revenue, non-current","23Q3",884
"Operating Lease Liabilities","23Q3",8038
"Other Long-term Liabilities","23Q3",1433
"Retained Earnings less Accumulated Loss","23Q3",205647
"Common Stocks","23Q3",67555
49 changes: 49 additions & 0 deletions dashboard/data/googl/dataset/googl_cashflow_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"Items","Period","Value"
"Net Income","FY22",59972
"Depreciation and Impairment of Property and Equipment","FY22",15287
"Amortization and Impairment of Intangible Assets","FY22",641
"Stock-based Compensation Expense","FY22",19362
"Deferred Income Taxes","FY22",-8061
"(Gain) Loss on Debt and Equity Securities, net","FY22",5519
"Other Adjustment","FY22",1030
"Change in Assets and Liabilities, net of effects of Acquisitions","FY22",-2235
"Capital Expenditure","FY22",-31485
"Securities Investment","FY22",16567
"Acquisitions","FY22",-6969
"Other Investment Activities","FY22",1589
"Repurchase of Stock and Stock-based Award Activities","FY22",-68596
"Debt-related Activities","FY22",-1196
"Effect of Exchange Rate on Cash","FY22",-506
"Net Increase in Cash","FY22",934
"Net Income","23Q3",53108
"Depreciation and Impairment of Property and Equipment","23Q3",10010
"Amortization and Impairment of Intangible Assets","23Q3",373
"Stock-based Compensation Expense","23Q3",16801
"Deferred Income Taxes","23Q3",-6093
"(Gain) Loss on Debt and Equity Securities, net","23Q3",1294
"Other Adjustment","23Q3",912
"Change in Assets and Liabilities, net of effects of Acquisitions","23Q3",6426
"Capital Expenditure","23Q3",-21232
"Securities Investment","23Q3",1787
"Acquisitions","23Q3",-466
"Other Investment Activities","23Q3",-985
"Repurchase of Stock and Stock-based Award Activities","23Q3",-52470
"Debt-related Activities","23Q3",-315
"Effect of Exchange Rate on Cash","23Q3",-327
"Net Increase in Cash","23Q3",8823
"Net Income","FY23",73795
"Depreciation and Impairment of Property and Equipment","FY23",11946
"Amortization and Impairment of Intangible Assets","FY23",0
"Stock-based Compensation Expense","FY23",22460
"Deferred Income Taxes","FY23",-7763
"(Gain) Loss on Debt and Equity Securities, net","FY23",823
"Other Adjustment","FY23",4330
"Change in Assets and Liabilities, net of effects of Acquisitions","FY23",-3885
"Capital Expenditure","FY23",-32251
"Securities Investment","FY23",5787
"Acquisitions","FY23",-495
"Other Investment Activities","FY23",-1051
"Repurchase of Stock and Stock-based Award Activities","FY23",-71341
"Debt-related Activities","FY23",-752
"Effect of Exchange Rate on Cash","FY23",-421
"Net Increase in Cash","FY23",2169
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"Items","Period","Value"
"Net Income","Year 1",0
"Depreciation and Impairment of Property and Equipment","Year 1"0
"Depreciation and Impairment of Property and Equipment","Year 1",0
"Amortization and Impairment of Intangible Assets","Year 1",0
"Stock-based Compensation Expense","Year 1",0
"Deferred Income Tax","Year 1",0
"Deferred Income Taxes","Year 1",0
"(Gain) Loss on Debt and Equity Securities, net","Year 1",0
"Other Adjustment","Year 1",0
"Change in Assets and Liabilities, net of effects of Acquisitions","Year 1",0
Expand All @@ -13,5 +13,5 @@
"Other Investment Activities","Year 1",0
"Repurchase of Stock and Stock-based Award Activities","Year 1",0
"Debt-related Activities","Year 1",0
"Effect of Exchange Rate on Cash",,"Year 1",0
"Effect of Exchange Rate on Cash","Year 1",0
"Net Increase in Cash","Year 1",0
46 changes: 46 additions & 0 deletions dashboard/data/googl/dataset/googl_income_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"Items","Period","Value"
"Cost of Revenue","FY22",126203
"Research & Development","FY22",39500
"Sales & Marketing","FY22",26567
"General & Administrative","FY22",15724
"EBIT","FY22",71328
"Income Tax","FY22",11356
"Other Income (Expense), net","FY22",-3514
"Net Income","FY22",59972
"Google Search & Other","FY22",162450
"Google Network","FY22",32780
"YouTube Ads","FY22",29243
"Other Platforms","FY22",29055
"Google Clouds","FY22",26280
"Hedging Gains","FY22",1960
"Other Bets","FY22",1068
"Cost of Revenue","FY21",110939
"Research & Development","FY21",31562
"Sales & Marketing","FY21",22912
"General & Administrative","FY21",13510
"EBIT","FY21",90734
"Income Tax","FY21",14701
"Other Income (Expense), net","FY21",12020
"Net Income","FY21",76033
"Google Search & Other","FY21",148951
"Google Network","FY21",31701
"YouTube Ads","FY21",28845
"Other Platforms","FY21",28032
"Google Clouds","FY21",19206
"Hedging Gains","FY21",753
"Other Bets","FY21",149
"Cost of Revenue","23Q3",33229
"Research & Development","23Q3",11258
"Sales & Marketing","23Q3",6884
"General & Administrative","23Q3",3979
"EBIT","23Q3",21343
"Income Tax","23Q3",1508
"Other Income (Expense), net","23Q3",0
"Net Income","23Q3",19689
"Google Search & Other","23Q3",44026
"Google Network","23Q3",7669
"YouTube Ads","23Q3",7952
"Other Platforms","23Q3",8339
"Google Clouds","23Q3",8411
"Hedging Gains","23Q3",-1
"Other Bets","23Q3",297
Loading

0 comments on commit 8049802

Please sign in to comment.