Download streamlit.plotly from Chen0324/4-19-test: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/spaces/Chen0324/4-19-test/resolve/main/streamlit.plotly
- Command line
-
hf download hf://spaces/Chen0324/4-19-test/streamlit.plotly
-
curl -L -o streamlit.plotly https://huggingface.co/spaces/Chen0324/4-19-test/resolve/main/streamlit.plotly
978 Bytes
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import plotly.graph_objs as go | |
| import plotly.express as ex | |
| import yfinance as yf | |
| import pandas as pd | |
| import pandas_ta | |
| import datetime as dt | |
| import streamlit as st | |
| start = dt.datetime(2020, 1, 1).strftime('%Y-%m-%d') | |
| end = dt.date.today() | |
| ticker='1301.TW' | |
| df = yf.download(ticker, start = start, end = end) | |
| df['stoch_k'] = pandas_ta.stochrsi(close=df['Adj Close'],length=20).iloc[:,0] | |
| df['stoch_d'] = pandas_ta.stochrsi(close=df['Adj Close'],length=20).iloc[:,1] | |
| df['bb_lower'] = pandas_ta.bbands(close=df['Adj Close'],length=20).iloc[:,0] | |
| df['bb_upper'] = pandas_ta.bbands(close=df['Adj Close'],length=20).iloc[:,2] | |
| df['forward_1d'] = df['Adj Close'].pct_change(1).shift(-1) | |
| fig=ex.line(df, x=df.index, y=['Adj Close','bb_lower','bb_upper'], title='台塑公司 (1301.TW) 股價走勢圖') | |
| fig.update_layout(title_text=f'台塑公司 (1301.TW) 股價走勢圖', title_x=0.5) | |
| st.plotly_chart(fig, use_container_width=True) |