quantstats
quantstats copied to clipboard
Showing qs.reports.html in streamlit
Hello, thank you so much for developing this amazing library! I am trying to use it in my streamlit app, however even after extensive research I was not able to make it work. It doesn't seems to save the html output if I'm working outside of a Jupyter notebook.
Here's the code I came up with:
stock = qs.utils.download_returns('QQQ', period="10y") qs.reports.html(stock, "SPY", title="QQQ vs. SPY", output='Output.html')
#Show import streamlit.components.v1 as components HtmlFile = open('Output.html', 'r', encoding='utf-8') source_code = HtmlFile.read() print(source_code) components.html(source_code, height = 900)
But it's not working. Can you help me? Thank you very much!
Would love to see this ^ +1 on the up vote.
@ceciliabonucchi I haven't tried in streamlit, but I know I have to specify output=filepath, download_filename=filepath
for it to actually save to that filepath. Maybe that's the problem here, if your print
is printing nothing.
@ceciliabonucchi
You can do it like this:
stock = qs.utils.download_returns('AAPL')
fig = qs.plots.snapshot(stock, title='AAPL Performance', show=False)
st.write(fig)
Now that I've managed to get the plots working in Streamlit, I've been trying to get them converted over to Plotly format in order to make them interactive. I've tried a whole bunch of variations but I haven't had any luck. If someone figures out, please post the solution in this thread.
Could someone tell me how to integrate qs.reports.metrics report into streamlit app? Unfortunately it does not work with st.write() st.table(), st.markdown()...