diff --git a/README.md b/README.md index b7fd795..b54bb2f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ # aa-tradingview +TradingView小部件集成项目,使用Streamlit创建加密货币概览页面。 + +## 项目结构 + +- `加密货币概览.md` - TradingView小部件的HTML代码 +- `app.py` - Streamlit应用主文件 +- `requirements.txt` - Python依赖包列表 + +## 运行方式 + +```bash +pip install -r requirements.txt +streamlit run app.py +``` + +## 代码索引 + +### 文件说明 +- **app.py**: Streamlit应用主文件,包含TradingView小部件的集成代码 +- **加密货币概览.md**: 原始TradingView小部件HTML代码 +- **requirements.txt**: 项目依赖包配置文件 + +### 主要功能 +- 加密货币市场概览显示 +- TradingView小部件嵌入 +- 响应式页面布局 \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..25045d2 --- /dev/null +++ b/app.py @@ -0,0 +1,126 @@ +""" +TradingView加密货币概览Streamlit应用 + +这个应用集成了TradingView的加密货币市场概览小部件, +提供实时的加密货币价格和市场数据展示。 +""" + +import streamlit as st +import streamlit.components.v1 as components + +def main(): + """ + 主函数:设置页面配置并渲染TradingView小部件 + """ + # 设置页面配置 + st.set_page_config( + page_title="加密货币概览 - TradingView", + page_icon="₿", + layout="wide", + initial_sidebar_state="collapsed" + ) + + # 页面标题 + st.title("🚀 加密货币市场概览") + st.markdown("---") + + # 添加说明文字 + st.markdown(""" + ### 📊 实时加密货币数据 + + 本页面展示了来自TradingView的实时加密货币市场数据,包括: + - 💰 实时价格 + - 📈 涨跌幅 + - 📊 市值排名 + - 🔄 24小时交易量 + + 数据每秒自动更新,为您提供最新的市场信息。 + """) + + # 创建TradingView小部件 + render_tradingview_widget() + +def render_tradingview_widget(): + """ + 渲染TradingView加密货币概览小部件 + + 该函数使用Streamlit的components模块来嵌入TradingView的JavaScript小部件, + 显示加密货币市场的实时数据。 + """ + + # TradingView小部件的HTML代码 + tradingview_html = """ + +
+
+ + +
+ + """ + + # 使用Streamlit components渲染HTML + components.html(tradingview_html, height=1050) + +def add_custom_css(): + """ + 添加自定义CSS样式 + + 为页面添加美观的样式,包括背景色、字体等。 + """ + st.markdown(""" + + """, unsafe_allow_html=True) + +if __name__ == "__main__": + # 添加自定义样式 + add_custom_css() + + # 运行主函数 + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af9c8cb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +# TradingView Streamlit应用依赖包 +# +# 主要依赖: +# - streamlit: Web应用框架 +# +# 安装方式: +# pip install -r requirements.txt + +streamlit>=1.28.0 \ No newline at end of file diff --git a/加密货币概览.md b/加密货币概览.md new file mode 100644 index 0000000..c128c26 --- /dev/null +++ b/加密货币概览.md @@ -0,0 +1,18 @@ + +
+
+ + +
+ \ No newline at end of file