This project is a Streamlit app that uses openbb-sdk to display technical analysis graphs for a given stock. The app allows the user to input a ticker symbol, start date, and end date in the sidebar, and then displays a line chart of the stock’s adjusted close price, as well as a Bollinger Bands graph using the openbb-sdk. The Bollinger Bands graph is saved to an image file and then displayed in the app.
today = datetime.date.today()
def user_input_features():
ticker = st.sidebar.text_input("Ticker", 'ZIM')
start_date = st.sidebar.text_input("Start Date", '2020-05-01')
end_date = st.sidebar.text_input("End Date", f'{today}')
# ta_range = st.sidebar.number_input("TA Range", min_value=1, max_value=50)
return ticker, start_date, end_date # , ta_range
symbol, start, end = user_input_features()
The user_input_features() function is used to get the user input from the sidebar. The user can input a ticker symbol, start date, and end date. The start date and end date are used to get the stock data from the yfinance API. The ticker symbol is used to get the company name from the yfinance API using the open bb load utility.
@st.cache # 👈 Added this
def build_bbands_img(data, symbol, file_name="sample.png"):
...
pass
To improve the performance of the app, you can use Streamlit’s @st.cache decorator on the build_bbands_img() function. This will enable caching of the…