Skip to content

Commit b12ce0d

Browse files
yanomalysamjulien
authored andcommitted
Fin dashboard data loading fix (#11)
1 parent b194018 commit b12ce0d

14 files changed

Lines changed: 176 additions & 796 deletions

finance-dashboard/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
WRITER_API_KEY=your-api-key
1+
WRITER_API_KEY=your-api-key
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "type": "page", "content": {"pageMode": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "root", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
2+
{"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", "type": "header", "content": {"text": "Finance Research Dashboard"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
3+
{"id": "kr54hbg2r5fkhsct", "type": "section", "content": {"title": "Select a stock ticker"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
4+
{"id": "s2jsn9u5xb23hase", "type": "tags", "content": {"tags": "{\n \"AAPL\": \"AAPL\",\n \"IBM\": \"IBM\",\n \"NVDA\": \"NVDA\",\n \"MSFT\": \"MSFT\",\n \"TSLA\": \"TSLA\"\n}"}, "handlers": {"wf-tag-click": "stock_tags"}, "isCodeManaged": false, "parentId": "kr54hbg2r5fkhsct", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
5+
{"id": "9eieaedqpr1ickbb", "type": "section", "content": {"containerBackgroundColor": "#e9d3fd", "cssClasses": "", "title": "Investment research options"}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
6+
{"id": "1yuilwwrhm40gxtx", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "9eieaedqpr1ickbb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
7+
{"id": "chwivjdj78wyyi9x", "type": "button", "content": {"text": "Analyze trends"}, "handlers": {"wf-click": "generate_stock_analysis"}, "isCodeManaged": false, "parentId": "1yuilwwrhm40gxtx", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
8+
{"id": "x6p3vxia2xlpbbib", "type": "button", "content": {"text": "Visualize income statement"}, "handlers": {"wf-click": "generate_income_analysis"}, "isCodeManaged": false, "parentId": "1yuilwwrhm40gxtx", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
9+
{"id": "rhomvmilcrm8f2r1", "type": "button", "content": {"text": "Summarize earnings"}, "handlers": {"wf-click": "summarize_earnings"}, "isCodeManaged": false, "parentId": "1yuilwwrhm40gxtx", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
10+
{"id": "8dbcbgiukyg74dkb", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
11+
{"id": "0p1levffmcf4xlpl", "type": "column", "content": {"width": "0.75"}, "handlers": {}, "isCodeManaged": false, "parentId": "8dbcbgiukyg74dkb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
12+
{"id": "i23vdas64ziuiazm", "type": "section", "content": {"title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "0p1levffmcf4xlpl", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
13+
{"id": "1vyfwym5dfh07ihb", "type": "message", "content": {"message": "@{message}"}, "handlers": {}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
14+
{"id": "1c3vvmgyhvkm9d6e", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 1, "visible": {"binding": "show_income_metrics.visible", "expression": "custom", "reversed": false}}
15+
{"id": "e7kux7h89zec8cmh", "type": "metric", "content": {"metricValue": "@{operating_margin}", "name": "Operating Margin", "note": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
16+
{"id": "0u3afw3gbxbj8h1x", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
17+
{"id": "yxm3uezkrgpl11fc", "type": "metric", "content": {"metricValue": "@{gross_margin}", "name": "Gross Margin", "note": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
18+
{"id": "xlzf1vlkmxokw9yj", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
19+
{"id": "nmdddxrvpgirasj6", "type": "metric", "content": {"metricValue": "@{ebitda_margin}", "name": "EBIDTA Margin", "note": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 4, "visible": {"binding": "", "expression": true, "reversed": false}}
20+
{"id": "oo7y10uo68z3ayf8", "type": "plotlygraph", "content": {"spec": "@{bar_graph}"}, "handlers": {"plotly-click": "charts.update_bar_graph"}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 2, "visible": {"binding": "show_bar_graph.visible", "expression": "custom", "reversed": false}}
21+
{"id": "a8a854zgzdrcel9j", "type": "dropdowninput", "binding": {"eventType": "wf-option-change", "stateRef": "prompt_parameters_lang"}, "content": {"label": "Output language", "options": "@{output_language}"}, "handlers": {"wf-option-change": "handle_prompt_parameters_lang"}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 3, "visible": {"binding": "", "expression": "custom", "reversed": false}}
22+
{"id": "km4vvfnq6bwlakmp", "type": "text", "content": {"text": "@{analysis}", "useMarkdown": "yes"}, "handlers": {}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 4, "visible": {"binding": "show_analysis_text.visible", "expression": "custom", "reversed": false}}
23+
{"id": "h72djsz1oqncb5ls", "type": "section", "content": {"title": "Latest news"}, "handlers": {}, "isCodeManaged": false, "parentId": "0p1levffmcf4xlpl", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
24+
{"id": "zinu9f9cyur23m66", "type": "repeater", "content": {"keyVariable": "itemId", "repeaterObject": "@{articles}", "valueVariable": "item"}, "handlers": {}, "isCodeManaged": false, "parentId": "h72djsz1oqncb5ls", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
25+
{"id": "dbdmqg2z74k4frq4", "type": "columns", "content": {"cssClasses": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "zinu9f9cyur23m66", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
26+
{"id": "p13mw4f6rr4z8d47", "type": "column", "content": {"cssClasses": "", "isCollapsible": "", "isSticky": "yes", "startCollapsed": "", "title": "", "width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "dbdmqg2z74k4frq4", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
27+
{"id": "4avlmncllyffxniu", "type": "section", "content": {"containerBackgroundColor": "#f7f7f7", "containerShadow": "5px 5px 5px 2px #f8f7f7", "primaryTextColor": "#000000", "title": "@{itemId}"}, "handlers": {}, "isCodeManaged": false, "parentId": "p13mw4f6rr4z8d47", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
28+
{"id": "w3wt3976ggvcuwrg", "type": "text", "content": {"alignment": "right", "text": "**@{item.published_at}**", "useMarkdown": "yes"}, "handlers": {}, "isCodeManaged": false, "parentId": "4avlmncllyffxniu", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
29+
{"id": "tji08jpu1y52kzz1", "type": "link", "content": {"cssClasses": "link", "primaryTextColor": "#1d53d3", "text": "@{item.source}", "url": "@{item.url}"}, "handlers": {}, "isCodeManaged": false, "parentId": "4avlmncllyffxniu", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
30+
{"id": "334d69p14onyi9wq", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "8dbcbgiukyg74dkb", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
31+
{"id": "yzujnjalyh2s2x16", "type": "tabs", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "334d69p14onyi9wq", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
32+
{"id": "18wepug77yr8m1iu", "type": "tab", "content": {"name": "Performance"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 0}
33+
{"id": "c52e2wkln9shvcoq", "type": "section", "content": {"containerBackgroundColor": "#FFE999", "title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "18wepug77yr8m1iu", "position": 0, "visible": {"binding": "demo_mode.visible", "expression": "custom", "reversed": false}}
34+
{"id": "3knng5h0zv8i3xra", "type": "text", "content": {"text": "@{tab_message}", "useMarkdown": "yes"}, "handlers": {}, "isCodeManaged": false, "parentId": "c52e2wkln9shvcoq", "position": 0, "visible": {"binding": "", "expression": "custom", "reversed": false}}
35+
{"id": "1db76a00z7imlyz1", "type": "section", "content": {"title": "@{symbol} stock performance"}, "handlers": {}, "isCodeManaged": false, "parentId": "18wepug77yr8m1iu", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
36+
{"id": "rgv1dgdrvgiosh42", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
37+
{"id": "oh2g51ixvuu8gdwa", "type": "metric", "content": {"description": "", "metricValue": "@{last_24_hours_open}", "name": "Open", "note": "L24"}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
38+
{"id": "bha2uz0y2jr7eszp", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
39+
{"id": "6646510g33an9r0g", "type": "metric", "content": {"description": "", "metricValue": "@{last_24_hours_high}", "name": "High", "note": "L24"}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
40+
{"id": "nzp2whzndpknrk55", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
41+
{"id": "df3mr8my8ivc8yrt", "type": "metric", "content": {"description": "", "metricValue": "@{last_24_hours_low}", "name": "Low", "note": "L24"}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 4, "visible": {"binding": "", "expression": true, "reversed": false}}
42+
{"id": "g5mgb80xt38atz4f", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
43+
{"id": "e13teponreio9yyz", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "Max"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
44+
{"id": "juip2rw7hywumv35", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "5D"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
45+
{"id": "afamuurw1lpjkkze", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "1M"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
46+
{"id": "77u7x4pf0ximsf0j", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "3M"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
47+
{"id": "fwmg7b84wstpxs7m", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "1Y"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 4, "visible": {"binding": "", "expression": true, "reversed": false}}
48+
{"id": "jcs5oslp27w5v52j", "type": "button", "content": {"buttonColor": "#BFCBFF", "buttonTextColor": "#000000", "cssClasses": "", "text": "5Y"}, "handlers": {"wf-click": "charts.handle_click"}, "isCodeManaged": false, "parentId": "g5mgb80xt38atz4f", "position": 5, "visible": {"binding": "", "expression": true, "reversed": false}}
49+
{"id": "opn16nq04zq9xha8", "type": "plotlygraph", "content": {"spec": "@{scatter_chart}"}, "handlers": {"plotly-click": "charts.update_scatter_chart"}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 2}
50+
{"id": "9v92jyh672s5wjkg", "type": "tab", "content": {"name": "Stock data"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
51+
{"id": "suu5ceib1bqj0si5", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "9v92jyh672s5wjkg", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
52+
{"id": "vyij4ox2ad95xyr9", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "suu5ceib1bqj0si5", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
53+
{"id": "ahwykl4cny005thy", "type": "dataframe", "content": {"dataframe": "@{main_df_subset}", "enableSearch": "no", "showIndex": "no"}, "handlers": {}, "isCodeManaged": false, "parentId": "vyij4ox2ad95xyr9", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
54+
{"id": "8yxe1itvlcq4zhpi", "type": "tab", "content": {"name": "Income data"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
55+
{"id": "tmiso5qe0e0jfl4i", "type": "dataframe", "content": {"dataframe": "@{income_statement_df}"}, "handlers": {}, "isCodeManaged": false, "parentId": "8yxe1itvlcq4zhpi", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id": "root", "type": "root", "content": {"appName": "Finance Dashboard"}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id": "workflows_root", "type": "workflows_root", "content": {}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"writer_version": "0.8.3rc2"
3+
}

finance-dashboard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ To learn more, check out the [full documentation for Writer Framework](https://d
2424

2525
## About Writer
2626

27-
Writer is the full-stack generative AI platform for enterprises. Quickly and easily build and deploy generative AI apps with a suite of developer tools fully integrated with our platform of LLMs, graph-based RAG tools, AI guardrails, and more. Learn more at [writer.com](https://www.writer.com?utm_source=github&utm_medium=readme&utm_campaign=framework).
27+
Writer is the full-stack generative AI platform for enterprises. Quickly and easily build and deploy generative AI apps with a suite of developer tools fully integrated with our platform of LLMs, graph-based RAG tools, AI guardrails, and more. Learn more at [writer.com](https://www.writer.com?utm_source=github&utm_medium=readme&utm_campaign=framework).

finance-dashboard/charts.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import plotly.graph_objects as go
44
from plotly.subplots import make_subplots
55

6+
67
def handle_click(state, context: dict, ui):
78
# Resetting the classes for active button
89
if state["active_button"]:
@@ -18,12 +19,13 @@ def handle_click(state, context: dict, ui):
1819
button_text = button.content["text"]
1920
_handle_time_period(state, button_text)
2021
button.content["cssClasses"] = "button-click"
21-
22+
2223
button_max = ui.find("e13teponreio9yyz")
2324
button_max.content["cssClasses"] = ""
24-
25+
2526
ui.component_tree.updated = True
2627

28+
2729
def _handle_time_period(state, period):
2830
state["main_df_subset"] = state["main_df"]
2931
if period == "5D":
@@ -41,9 +43,10 @@ def _handle_time_period(state, period):
4143
pass
4244
update_scatter_chart(state)
4345

46+
4447
def update_scatter_chart(state):
4548
fig = px.line(state["main_df_subset"], x="Date", y="Open", height=400)
46-
49+
4750
df1 = state["main_df_subset"]
4851
df2 = state["another_df"]
4952
df2 = df2.head(len(df1))
@@ -61,13 +64,13 @@ def update_scatter_chart(state):
6164

6265
# Add traces for the primary y-axis (Main_DF)
6366
fig.add_trace(
64-
go.Scatter(x=df1["Date"], y=df1["Open"], name=state["symbol"], mode='lines'),
67+
go.Scatter(x=df1["Date"], y=df1["Open"], name=state["symbol"], mode="lines"),
6568
secondary_y=False,
6669
)
6770

6871
# Add traces for the secondary y-axis (Another_DF)
6972
fig.add_trace(
70-
go.Scatter(x=df2["Date"], y=df2["Open"], name="S&P 500", mode='lines'),
73+
go.Scatter(x=df2["Date"], y=df2["Open"], name="S&P 500", mode="lines"),
7174
secondary_y=True,
7275
)
7376

@@ -76,16 +79,23 @@ def update_scatter_chart(state):
7679
fig.update_yaxes(title_text="S&P 500", secondary_y=True)
7780

7881
# Update layout
79-
fig.update_layout(height=550, title_text=f"{state['symbol']} Stock vs the S&P 500", title_x = 0.5, title_y = 0.9, legend=dict(
80-
orientation='h',
81-
yanchor='top',
82+
fig.update_layout(
83+
height=550,
84+
title_text=f"{state['symbol']} Stock vs the S&P 500",
85+
title_x=0.5,
86+
title_y=0.9,
87+
legend=dict(
88+
orientation="h",
89+
yanchor="top",
8290
y=-0.2, # Adjust this value as needed
83-
xanchor='center',
84-
x=0.5
85-
))
91+
xanchor="center",
92+
x=0.5,
93+
),
94+
)
8695

8796
state["scatter_chart"] = fig
88-
97+
98+
8999
def update_bar_graph(state):
90100
fig = px.line(state["main_df_subset"], x="Date", y="Open", height=400)
91101

@@ -114,4 +124,4 @@ def update_bar_graph(state):
114124
legend=dict(orientation="h", yanchor="top", y=-0.2, xanchor="center", x=0.5)
115125
)
116126

117-
state["bar_graph"] = fig
127+
state["bar_graph"] = fig

finance-dashboard/earnings-data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)