Output the results in an excel or other format file

Hi Team
I am running strategy in multipass mode. Is there a way to get the key result statistics in an excel or text file for analysis?

@anshul96go Hello, for the analysis probably you need the weights and the data. The weights can be downloaded in csv format inside the "Sent strategies" area.
More in general, you can simply save csv files inside your online root directory, and then click on the "Download" buttons for storing them locally.
You can convert them to csv using:
weights.to_pandas().to_csv("weights.csv")
You can also use pickle:
import os import pickle def save_object(obj, filename): with open(filename, 'wb') as output: pickle.dump(obj, output, pickle.HIGHEST_PROTOCOL) save_object(indicators, 'indicators.pkl')

@anshul96go
To get the actual statistics you currently have to calculate them like so:import qnt.stats as qns data = qndata.cryptodaily_load_data(min_date="20140101") # or whenever your backtest started stats = qns.calc_stat(data, weights)
And if you really need them as xls file you can do:
stats.to_pandas().to_excel('stats.xls') # I got a ModuleNotFoundError the first time  pip install did the trick.
Allthough I can't recommend xls because at least LibreOffice becomes very slow / unresponsive when handling such a file.
Getting the statistics after a backtest could be a little simpler, which brings me to a feature request:
@support
Do you think you could add a parameter to the backtester which makes it return the statistics? They get calculated anyway by default, but we only see a truncated printout or the plots and can't use them for further analysis.
.
In my local environment I did it like this in qnt.backtester.py: Add the parameter return_stats: bool = False to the parameters of the backtest function
 From line 353 onward my backtester now looks like this:
qnout.write(result) qnstate.write(state) if return_stats: analyze = True out = [result] if analyze: log_info("") stats = analyze_results(result, data, competition_type, build_plots, start_date) if return_stats: out.append(stats) if args_count > 1: out.append(state) if len(out) == 1: out = out[0] return out finally: qndc.set_max_datetime(None)
 And of course I made analyze_results return the statistics like so (line 458 in the original):
if not build_plots: log_info(stat_global.to_pandas().tail()) return stat_global # here log_info("") log_info("Calc stats per asset...") stat_per_asset = qnstat.calc_stat(data, output, per_asset=True) stat_per_asset = stat_per_asset.loc[output.time.values[0]:] if is_notebook(): build_plots_jupyter(output, stat_global, stat_per_asset) else: build_plots_dash(output, stat_global, stat_per_asset) return stat_global # and there
This might not be the most elegant solution but you get the idea.
Now I can get the statistics immediately after the backtest withweights, stats = backtest(...return_stats=True)
and can do further analysis.
For instance, I started to calculate the correlations between my strategies to avoid uploading more of the same to the contest.It would be nice to have this feature in a future version, so I don't have to mess with the backtester after each update
Best regards