Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion finance-dashboard/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WRITER_API_KEY=your-api-key
WRITER_API_KEY=your-api-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "type": "page", "content": {"pageMode": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "root", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"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}}
{"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}}
{"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}}
{"id": "1yuilwwrhm40gxtx", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "9eieaedqpr1ickbb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"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}}
{"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}}
{"id": "8dbcbgiukyg74dkb", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "0p1levffmcf4xlpl", "type": "column", "content": {"width": "0.75"}, "handlers": {}, "isCodeManaged": false, "parentId": "8dbcbgiukyg74dkb", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "i23vdas64ziuiazm", "type": "section", "content": {"title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "0p1levffmcf4xlpl", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "1vyfwym5dfh07ihb", "type": "message", "content": {"message": "@{message}"}, "handlers": {}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "1c3vvmgyhvkm9d6e", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "i23vdas64ziuiazm", "position": 1, "visible": {"binding": "show_income_metrics.visible", "expression": "custom", "reversed": false}}
{"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}}
{"id": "0u3afw3gbxbj8h1x", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"id": "xlzf1vlkmxokw9yj", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1c3vvmgyhvkm9d6e", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"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}}
{"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}}
{"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}}
{"id": "h72djsz1oqncb5ls", "type": "section", "content": {"title": "Latest news"}, "handlers": {}, "isCodeManaged": false, "parentId": "0p1levffmcf4xlpl", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "zinu9f9cyur23m66", "type": "repeater", "content": {"keyVariable": "itemId", "repeaterObject": "@{articles}", "valueVariable": "item"}, "handlers": {}, "isCodeManaged": false, "parentId": "h72djsz1oqncb5ls", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "dbdmqg2z74k4frq4", "type": "columns", "content": {"cssClasses": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "zinu9f9cyur23m66", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"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}}
{"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}}
{"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}}
{"id": "334d69p14onyi9wq", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "8dbcbgiukyg74dkb", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "yzujnjalyh2s2x16", "type": "tabs", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "334d69p14onyi9wq", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "18wepug77yr8m1iu", "type": "tab", "content": {"name": "Performance"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 0}
{"id": "c52e2wkln9shvcoq", "type": "section", "content": {"containerBackgroundColor": "#FFE999", "title": ""}, "handlers": {}, "isCodeManaged": false, "parentId": "18wepug77yr8m1iu", "position": 0, "visible": {"binding": "demo_mode.visible", "expression": "custom", "reversed": false}}
{"id": "3knng5h0zv8i3xra", "type": "text", "content": {"text": "@{tab_message}", "useMarkdown": "yes"}, "handlers": {}, "isCodeManaged": false, "parentId": "c52e2wkln9shvcoq", "position": 0, "visible": {"binding": "", "expression": "custom", "reversed": false}}
{"id": "1db76a00z7imlyz1", "type": "section", "content": {"title": "@{symbol} stock performance"}, "handlers": {}, "isCodeManaged": false, "parentId": "18wepug77yr8m1iu", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "rgv1dgdrvgiosh42", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"id": "bha2uz0y2jr7eszp", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"id": "nzp2whzndpknrk55", "type": "separator", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "rgv1dgdrvgiosh42", "position": 3, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"id": "g5mgb80xt38atz4f", "type": "horizontalstack", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"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}}
{"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}}
{"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}}
{"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}}
{"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}}
{"id": "opn16nq04zq9xha8", "type": "plotlygraph", "content": {"spec": "@{scatter_chart}"}, "handlers": {"plotly-click": "charts.update_scatter_chart"}, "isCodeManaged": false, "parentId": "1db76a00z7imlyz1", "position": 2}
{"id": "9v92jyh672s5wjkg", "type": "tab", "content": {"name": "Stock data"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 1, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "suu5ceib1bqj0si5", "type": "columns", "content": {}, "handlers": {}, "isCodeManaged": false, "parentId": "9v92jyh672s5wjkg", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "vyij4ox2ad95xyr9", "type": "column", "content": {"width": "1"}, "handlers": {}, "isCodeManaged": false, "parentId": "suu5ceib1bqj0si5", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
{"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}}
{"id": "8yxe1itvlcq4zhpi", "type": "tab", "content": {"name": "Income data"}, "handlers": {}, "isCodeManaged": false, "parentId": "yzujnjalyh2s2x16", "position": 2, "visible": {"binding": "", "expression": true, "reversed": false}}
{"id": "tmiso5qe0e0jfl4i", "type": "dataframe", "content": {"dataframe": "@{income_statement_df}"}, "handlers": {}, "isCodeManaged": false, "parentId": "8yxe1itvlcq4zhpi", "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
1 change: 1 addition & 0 deletions finance-dashboard/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "Finance Dashboard"}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
1 change: 1 addition & 0 deletions finance-dashboard/.wf/components-workflows_root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "workflows_root", "type": "workflows_root", "content": {}, "handlers": {}, "isCodeManaged": false, "position": 0, "visible": {"binding": "", "expression": true, "reversed": false}}
3 changes: 3 additions & 0 deletions finance-dashboard/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.8.3rc2"
}
2 changes: 1 addition & 1 deletion finance-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ To learn more, check out the [full documentation for Writer Framework](https://d

## About Writer

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).
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).
36 changes: 23 additions & 13 deletions finance-dashboard/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import plotly.graph_objects as go
from plotly.subplots import make_subplots


def handle_click(state, context: dict, ui):
# Resetting the classes for active button
if state["active_button"]:
Expand All @@ -18,12 +19,13 @@ def handle_click(state, context: dict, ui):
button_text = button.content["text"]
_handle_time_period(state, button_text)
button.content["cssClasses"] = "button-click"

button_max = ui.find("e13teponreio9yyz")
button_max.content["cssClasses"] = ""

ui.component_tree.updated = True


def _handle_time_period(state, period):
state["main_df_subset"] = state["main_df"]
if period == "5D":
Expand All @@ -41,9 +43,10 @@ def _handle_time_period(state, period):
pass
update_scatter_chart(state)


def update_scatter_chart(state):
fig = px.line(state["main_df_subset"], x="Date", y="Open", height=400)

df1 = state["main_df_subset"]
df2 = state["another_df"]
df2 = df2.head(len(df1))
Expand All @@ -61,13 +64,13 @@ def update_scatter_chart(state):

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

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

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

# Update layout
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(
orientation='h',
yanchor='top',
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(
orientation="h",
yanchor="top",
y=-0.2, # Adjust this value as needed
xanchor='center',
x=0.5
))
xanchor="center",
x=0.5,
),
)

state["scatter_chart"] = fig



def update_bar_graph(state):
fig = px.line(state["main_df_subset"], x="Date", y="Open", height=400)

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

state["bar_graph"] = fig
state["bar_graph"] = fig
2 changes: 1 addition & 1 deletion finance-dashboard/earnings-data.json

Large diffs are not rendered by default.

Loading