Spaces:
Sleeping
Sleeping
hoangSnapeV
commited on
Commit
·
c14336c
1
Parent(s):
e0d52cf
Add repo from thinhVu to test and deploy
Browse files- README.md +2 -1
- app.py +89 -2
- assets/images/huggingface_streamlit_space_creation_vnstock_learn-anything-thinhvu.png +0 -0
- assets/images/streamlit_cloud_deploy_from_github_repo.png +0 -0
- assets/images/streamlit_cloud_setup_new_repo_thinhvu_vnstock_learn-anything.png +0 -0
- assets/images/thinhvu_momo_qr.png +0 -0
- requirements.txt +15 -0
README.md
CHANGED
@@ -5,9 +5,10 @@ colorFrom: indigo
|
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.39.0
|
8 |
-
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
5 |
colorTo: green
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.39.0
|
8 |
+
short_description: Template Streamlit App from ThinhVu
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
app_file: app.py
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -1,4 +1,91 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import json
|
3 |
+
# from pygwalker.api.streamlit import StreamlitRenderer, init_streamlit_comm
|
4 |
+
from vnstock import *
|
5 |
|
6 |
+
# start with wide mode
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
+
|
9 |
+
st.image('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9oKwC5bqBD08w-m0l0nJo7uKpv6VOSZZU2TvkKVGJ8slWt4GguXfUdyD0sE2F31NsDoM&usqp=CAU', width=120)
|
10 |
+
st.header("Thư viện mẫu Streamlit Web App cho người mới bắt đầu")
|
11 |
+
|
12 |
+
# Create 3 tabs
|
13 |
+
screener, help, credit = st.tabs(["Bộ lọc cổ phiếu", "Hướng dẫn", "Giới thiệu"])
|
14 |
+
|
15 |
+
|
16 |
+
default_query = {"exchangeName": "HOSE,HNX,UPCOM",
|
17 |
+
"marketCap": (100, 1000)}
|
18 |
+
|
19 |
+
@st.cache_data
|
20 |
+
def tcbs_screener(query, limit=1700):
|
21 |
+
screener_df = stock_screening_insights (query, size=limit, drop_lang='en')
|
22 |
+
return screener_df
|
23 |
+
|
24 |
+
# def pygwalker_part (df):
|
25 |
+
# # Initialize pygwalker communication
|
26 |
+
# init_streamlit_comm()
|
27 |
+
# renderer = StreamlitRenderer(df, spec="./gw_config.json", debug=False)
|
28 |
+
# renderer.render_explore()
|
29 |
+
|
30 |
+
# Define the content of each tab
|
31 |
+
with screener:
|
32 |
+
st.markdown("## Bộ lọc cổ phiếu")
|
33 |
+
|
34 |
+
# define 3 columns with equally width
|
35 |
+
col1, col2, col3 = st.columns([1.5, 1, 1])
|
36 |
+
with col1:
|
37 |
+
# allow user to select exchange from HOSE, HNX, UPCOM
|
38 |
+
exchange = st.multiselect("Sàn giao dịch", ["HOSE", "HNX", "UPCOM"], default=["HOSE", "HNX", "UPCOM"])
|
39 |
+
with col2:
|
40 |
+
# allow user to input market cap range
|
41 |
+
market_cap = st.slider("Vốn hóa thị trường", 0, 10000, (100, 1000))
|
42 |
+
with col3:
|
43 |
+
# show a number input to define the limit of the result
|
44 |
+
limit = st.number_input("Số lượng cổ phiếu tối đa", min_value=10, max_value=2000, value=1700)
|
45 |
+
|
46 |
+
# update the query with the user input
|
47 |
+
query = {"exchangeName": ",".join(exchange),
|
48 |
+
"marketCap": market_cap}
|
49 |
+
# call the function to get the result
|
50 |
+
screener_df = tcbs_screener(query, limit)
|
51 |
+
# show the result in a table
|
52 |
+
st.write(screener_df)
|
53 |
+
|
54 |
+
# st.markdown('## Khám phá')
|
55 |
+
# pygwalker_part (screener_df)
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
with help:
|
61 |
+
st.markdown("## Hướng dẫn")
|
62 |
+
help_details = """
|
63 |
+
## Sử dụng Streamlit Cloud
|
64 |
+
1. Tạo Github repository bằng cách folk repo này trên Github hoặc tạo mới một repo và copy toàn bộ nội dung trong thư mục repo này vào.
|
65 |
+
2. Truy cập Streamlit Cloud (cần đăng ký mới nếu chưa có tài khoản tại: https://share.streamlit.io). Bạn có thể đăng nhập bằng tài khoản Github hiện có.
|
66 |
+
3. Tạo ứng dụng mới trên Streamlit Share bằng cách chọn New app > Use existing repo và chọn repo bạn chuẩn bị sẵn trên Github
|
67 |
+
![](./assets/images/streamlit_cloud_setup_new_repo_thinhvu_vnstock_learn-anything.png)
|
68 |
+
## Sử dụng Hugging Face Spaces
|
69 |
+
1. Tạo tài khoản Hugging Face tại: https://huggingface.co
|
70 |
+
2. Truy cập Hugging Face Spaces tại: https://huggingface.co/new-space để tạo một không gian mới
|
71 |
+
3. Đặt tên url cho không gian của bạn, ví dụ `vnstock-app`
|
72 |
+
4. Chọn Space SDK là Streamlit
|
73 |
+
5. Chọn chế độ chia sẻ công khai (Public) hay riêng tư (Private)
|
74 |
+
6. Chọn Create Space để hoàn tất.
|
75 |
+
7. Truy cập tab `Files` và chọn nút (button) `Upload files` để tải lên toàn bộ nội dung trong thư mục repo này.
|
76 |
+
"""
|
77 |
+
st.markdown(help_details)
|
78 |
+
|
79 |
+
with credit:
|
80 |
+
credit_details = """
|
81 |
+
## Giới thiệu
|
82 |
+
|
83 |
+
Đây là mẫu Web App đơn giản minh họa cho người mới làm quen với việc xây dựng Data app trên nền tảng Web bằng streamlit trong Python.
|
84 |
+
|
85 |
+
## Tác giả
|
86 |
+
* Tác giả: [Thinh Vu](https://thinhvu.com) @ vnstock.site
|
87 |
+
* Email: support@vnstock.site
|
88 |
+
* Website: [vnstock.site](https://vnstock.site)
|
89 |
+
* Bạn có thể gửi tặng tác giả Cafe qua QR thay lời cảm ơn. Chi tiết [tại đây](https://docs.vnstock.site/community/tai-tro-du-an-vnstock/)
|
90 |
+
"""
|
91 |
+
st.markdown(credit_details)
|
assets/images/huggingface_streamlit_space_creation_vnstock_learn-anything-thinhvu.png
ADDED
![]() |
assets/images/streamlit_cloud_deploy_from_github_repo.png
ADDED
![]() |
assets/images/streamlit_cloud_setup_new_repo_thinhvu_vnstock_learn-anything.png
ADDED
![]() |
assets/images/thinhvu_momo_qr.png
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
bs4
|
3 |
+
pandas==2.2.1
|
4 |
+
requests==2.31.0
|
5 |
+
bs4==0.0.2
|
6 |
+
vnai>=0.1.0
|
7 |
+
openpyxl==3.1.2
|
8 |
+
vnstock_ezchart==0.0.2
|
9 |
+
fake_useragent==1.5.1
|
10 |
+
cryptography==42.0.5
|
11 |
+
psutil==6.0.0
|
12 |
+
click==8.1.7
|
13 |
+
click-repl==0.3.0
|
14 |
+
seaborn==0.13.2
|
15 |
+
IPython
|