thinh-vu commited on
Commit
0f49d97
·
verified ·
1 Parent(s): 4d54fd7

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -91
main.py DELETED
@@ -1,91 +0,0 @@
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://vnstock.site/wp-content/uploads/2023/07/vnstock-logo-120x60.jpg', 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)