quantstats icon indicating copy to clipboard operation
quantstats copied to clipboard

Showing qs.reports.html in streamlit

Open ceciliabonucchi opened this issue 2 years ago • 7 comments

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!

ceciliabonucchi avatar Apr 05 '22 22:04 ceciliabonucchi

Would love to see this ^ +1 on the up vote.

eervin123 avatar Apr 27 '22 18:04 eervin123

@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.

jamesfulford avatar Nov 02 '22 00:11 jamesfulford

@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)

TradingDominion avatar Jan 23 '23 18:01 TradingDominion

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.

TradingDominion avatar Jan 26 '23 05:01 TradingDominion

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()...

georgosqlab avatar Apr 27 '23 11:04 georgosqlab