Hi,
Is there a way to extract the daily P&L of a backtest and paste it in excel ?
Thanks
Chris
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Extract daily P&L from backtest for Excel in QuantConnect.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Extract daily P&L from a backtest
Chris D | August 2018
Hi,
Is there a way to extract the daily P&L of a backtest and paste it in excel ?
Thanks
Chris
QuantConnectâ„¢ 2025. All Rights Reserved
Jing Wu
Hi Chris, you can do this locally. Just download the result JSON file from the overview tab, parse the JSON file into your local python environment, extract the strategy P&L and the benchmark P&L then write the dataframe to a csv file. The JSON file should be in the same folder as the .py file.
import json import pandas as pd with open("your_result.json") as data_file: data = json.load(data_file) if "Strategy Equity" in data["Charts"] and "Benchmark" in data["Charts"]: strategySeries = data["Charts"]["Strategy Equity"]["Series"]["Equity"]["Values"] benchmarkSeries = data["Charts"]["Benchmark"]["Series"]["Benchmark"]["Values"] df_strategy = pd.DataFrame(strategySeries).set_index('x') df_benchmark = pd.DataFrame(benchmarkSeries).set_index('x') strategy = df_strategy.set_index(pd.to_datetime(df_strategy.index, unit='s')) benchmark = df_benchmark.set_index(pd.to_datetime(df_benchmark.index, unit='s')) strategy.to_csv(“strategy.csv") benchmark.to_csv(“benchmark.csv")
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Chris D
Thank you Jing.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!