rstallman hfwittmann commited on
Commit
a9384ce
0 Parent(s):

Duplicate from d8aai/finance-dashboard

Browse files

Co-authored-by: H. Felix Wittmann <hfwittmann@users.noreply.huggingface.co>

.env ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ PYTHONPATH=.
2
+ HOST=https://dax-backend.arthought.com
3
+ # financebackend:8000
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.vscode/launch.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Python: Current File",
9
+ "type": "python",
10
+ "request": "launch",
11
+ "module": "streamlit",
12
+ "args": [
13
+ "run",
14
+ "app.py"
15
+ ],
16
+ "console": "integratedTerminal",
17
+ "justMyCode": true
18
+ }
19
+ ]
20
+ }
README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Finance Dashboard by d8a.ai
3
+ emoji: 🦀
4
+ colorFrom: pink
5
+ colorTo: gray
6
+ sdk: streamlit
7
+ sdk_version: 1.17.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ duplicated_from: d8aai/finance-dashboard
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
15
+
16
+ The code is derived from https://github.com/hfwittmann/financial-timeseries-dashboard/tree/kedro-based
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import date
2
+ import json
3
+ import plotly
4
+ from re import sub
5
+ from plotly import graph_objects as go
6
+
7
+ import streamlit as st
8
+
9
+ st.set_page_config(layout="wide")
10
+
11
+ from subs.access_backend import get_tickerlist
12
+ from subs.access_backend import get_plot
13
+
14
+ tickerTable = get_tickerlist().set_index("Ticker")
15
+
16
+ PrimeStandardSector = "Prime Standard Sector"
17
+ sectors = tickerTable[PrimeStandardSector].unique()
18
+ sectors.sort()
19
+ sector = st.selectbox(
20
+ label="Select a Sector. Remark: This sets the default for the selected stocks",
21
+ options=sectors,
22
+ )
23
+
24
+ default_index = tickerTable[PrimeStandardSector] == sector
25
+
26
+ default = tickerTable[default_index]
27
+
28
+ selections = st.multiselect(
29
+ label="Dax Constituents",
30
+ options=list(tickerTable.index),
31
+ format_func=lambda x: tickerTable.at[x, "Company"],
32
+ default=list(default.index),
33
+ )
34
+
35
+ for selection in selections:
36
+
37
+ try:
38
+
39
+ fig_scatter = get_plot(selection, "scatter")
40
+ fig_returns = get_plot(selection, "returns")
41
+ fig_histogram = get_plot(selection, "histogram")
42
+
43
+ st.header(tickerTable.at[selection, "Company"])
44
+ c1, _, c2, _, c3 = st.columns((10, 1, 10, 1, 10))
45
+
46
+ c1.plotly_chart(fig_scatter, use_container_width=True)
47
+ c2.plotly_chart(fig_returns, use_container_width=True)
48
+ c3.plotly_chart(fig_histogram, use_container_width=True)
49
+
50
+ except Exception as e:
51
+ st.header(tickerTable.at[selection, "Company"])
52
+ st.markdown(
53
+ f"Data for {tickerTable.at[selection, 'Company']} not available",
54
+ unsafe_allow_html=False,
55
+ )
56
+ # print(selection)
57
+ # print(e)
58
+
59
+ if __name__ == "__main__":
60
+ print(tickerTable)
61
+ print(tickerTable.index[:3])
62
+
63
+ print(sectors)
64
+ print(tickerTable["Prime Standard Sector"] == sector)
65
+ print(default)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ environs==9.5.0
2
+ lxml==4.9.2
3
+ pandas-datareader==0.10.0
4
+ pandas==1.5.3
5
+ plotly==5.13.1
6
+ altair<5
subs/access_backend.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from subs.orderdict import orderByValue
2
+ import requests
3
+ import json
4
+ import streamlit as st
5
+ import pandas as pd
6
+
7
+ from environs import Env
8
+
9
+ env = Env()
10
+ env.read_env()
11
+
12
+ # @st.cache
13
+ def get_tickerlist():
14
+
15
+ response = requests.get(f"{env('HOST')}/Tickerlist_provider?datatype=tickerlist")
16
+
17
+ response_json = response.json()
18
+
19
+ companyTicker = pd.read_json(response_json["myData"])
20
+
21
+ return companyTicker
22
+
23
+
24
+ # @st.cache
25
+ def get_plot(selection: str, plottype: str):
26
+
27
+ assert plottype in ["scatter", "returns", "histogram"]
28
+
29
+ response = requests.get(
30
+ f"{env('HOST')}/Stockticker_provider?plottype={plottype}&selection={selection}"
31
+ )
32
+
33
+ blub = response.json()
34
+
35
+ fig = json.loads(blub["plot"])
36
+
37
+ return fig
38
+
39
+
40
+ if __name__ == "__main__":
41
+ print(get_tickerlist())
42
+
43
+ print(get_plot("ADS.DE", "scatter"))
toml/config.prod.toml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Below are all the sections and options you can have in ~/.streamlit/config.toml.
2
+
3
+ [global]
4
+
5
+ # By default, Streamlit checks if the Python watchdog module is available and, if not, prints a warning asking for you to install it. The watchdog module is not required, but highly recommended. It improves Streamlit's ability to detect changes to files in your filesystem.
6
+ # If you'd like to turn off this warning, set this to True.
7
+ # Default: false
8
+ disableWatchdogWarning = false
9
+
10
+ # Configure the ability to share apps to the cloud.
11
+ # Should be set to one of these values: - "off" : turn off sharing. - "s3" : share to S3, based on the settings under the [s3] section of this config file.
12
+ # Default: "off"
13
+ sharingMode = "off"
14
+
15
+ # If True, will show a warning when you run a Streamlit-enabled script via "python my_script.py".
16
+ # Default: true
17
+ showWarningOnDirectExecution = true
18
+
19
+ # Level of logging: 'error', 'warning', 'info', or 'debug'.
20
+ # Default: 'info'
21
+ logLevel = "debug"
22
+
23
+
24
+ [client]
25
+
26
+ # Whether to enable st.cache.
27
+ # Default: true
28
+ caching = true
29
+
30
+ # If false, makes your Streamlit script not draw to a Streamlit app.
31
+ # Default: true
32
+ displayEnabled = true
33
+
34
+
35
+ [runner]
36
+
37
+ # Allows you to type a variable or string by itself in a single line of Python code to write it to the app.
38
+ # Default: true
39
+ magicEnabled = true
40
+
41
+ # Install a Python tracer to allow you to stop or pause your script at any point and introspect it. As a side-effect, this slows down your script's execution.
42
+ # Default: false
43
+ installTracer = false
44
+
45
+ # Sets the MPLBACKEND environment variable to Agg inside Streamlit to prevent Python crashing.
46
+ # Default: true
47
+ fixMatplotlib = true
48
+
49
+
50
+ [server]
51
+
52
+ # List of folders that should not be watched for changes. Relative paths will be taken as relative to the current working directory.
53
+ # Example: ['/home/user1/env', 'relative/path/to/folder']
54
+ # Default: []
55
+ folderWatchBlacklist = ['']
56
+
57
+
58
+ # If false, will attempt to open a browser window on start.
59
+ # Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) server.liveSave is set.
60
+ headless = true
61
+
62
+ # Immediately share the app in such a way that enables live monitoring, and post-run analysis.
63
+ # Default: false
64
+ liveSave = false
65
+
66
+ # Automatically rerun script when the file is modified on disk.
67
+ # Default: false
68
+ runOnSave = false
69
+
70
+ # The port where the server will listen for client and browser connections.
71
+ # Default: 8501
72
+ port = 8501
73
+
74
+ # Enables support for Cross-Origin Request Sharing, for added security.
75
+ # Default: true
76
+ enableCORS = false
77
+
78
+
79
+ [browser]
80
+
81
+ # Internet address of the server server that the browser should connect to. Can be IP address or DNS name.
82
+ # Default: 'env("HOST")'
83
+ serverAddress = "0.0.0.0"
84
+
85
+ # Whether to send usage statistics to Streamlit.
86
+ # Default: true
87
+ gatherUsageStats = true
88
+
89
+ # Port that the browser should use to connect to the server when in liveSave mode.
90
+ # Default: whatever value is set in server.port.
91
+ serverPort = 8501
92
+
93
+ [s3]
94
+
95
+ # Name of the AWS S3 bucket to save apps.
96
+ # Default: (unset)
97
+ #bucket =
98
+
99
+ # URL root for external view of Streamlit apps.
100
+ # Default: (unset)
101
+ #url =
102
+
103
+ # Access key to write to the S3 bucket.
104
+ # Leave unset if you want to use an AWS profile.
105
+ # Default: (unset)
106
+ #accessKeyId =
107
+
108
+ # Secret access key to write to the S3 bucket.
109
+ # Leave unset if you want to use an AWS profile.
110
+ # Default: (unset)
111
+ #secretAccessKey =
112
+
113
+ # The "subdirectory" within the S3 bucket where to save apps.
114
+ # S3 calls paths "keys" which is why the keyPrefix is like a subdirectory. Use "" to mean the root directory.
115
+ # Default: ""
116
+ keyPrefix = ""
117
+
118
+ # AWS region where the bucket is located, e.g. "us-west-2".
119
+ # Default: (unset)
120
+ #region =
121
+
122
+ # AWS credentials profile to use.
123
+ # Leave unset to use your default profile.
124
+ # Default: (unset)
125
+ #profile =
toml/credentials.prod.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [general]
2
+
3
+ email=""