Merge Equity Curves 2.0
Exporting Strategy Performance XML files that use 15 years of 5-minute bars can be cumbersome. Using Maestro can be cumbersome too. I know there are great programs out there that will quickly analyze the XML files and do what we are about to do plus a bunch more. But if you want to do it yourself, try working with 224,377 KB files.
If you want to do a quick merge of equity curves of different markets or systems use this simple method. That is if you have Python, MatPlotLib and Pandas installed on your computer. Installing these are really simple and everybody is doing it. I created this script with the help of a paid version of ChatGPT.
Steps:
1,) Create a folder on you C drive: C:\Data
2.) Put this code into your strategy code. Make sure you change the output file name for each market/system combo that the strategy is applied to.
This will create a csv file that looks like this.
3.) Copy and paste the following code into your favorite Python IDE or IDLE.
4.) Run it and multi-select all the system/market .csv files
5.) Examine the results:
How did I get ChatGPT to code this for me.
I pay $20 a month for Chat and it learns from my workflows. The more I work with it, the more it knows my end goals to the scripts I am asking it to create.
Here are the prompts I provided Chat:
I want the user to be able to use tkinter to select multiple files that contain two columns: 1-date in yyyymmdd format and 2 – the equity value for that date. The filename consists of the system name and the market name and follows the following patterm: system name”-“market name”.csv”. I need you to extract the market from the filename. If the filename is “Gatts-GC.csv”, the market name is “GC.” Once all the files are opened, I need you to align the dates and create a combined equity curve. We can do this in matplotlib if you like. I need you to calculate the total profit and the maximum drawdown among the combined equity curves.
[SCRIPT FAILED]
My data does not included headers. The first column is the date in yyyymmdd with no separators and the second column is a float value. I think your pandas are having a hard time interpreting this
[SCRIPT WORKED]
That is perfect. Can we had a correlation analysis to the equity curves and print that out too.
[SCRIPT WORKED]
Can we plot the draw down on the same canvas as the equity curves?
[SCRIPT WORKED]
Could we put the draw down in a subplot instead of in the profit plot?
[FINAL SCRIPT] Look above
Am I Worried About Being Replaced by Chat GPT?
With Python and its data visualization libraries and EasyLanguage you can overcome some of the limitations of TradeStation. And of course, ChatGPT. I have been programming in Python for nine years now and I am very good at base Python. However, Pandas are still a mystery to me and interfacing with MatPlotLib is not super simple. Does it frustrate me that I don’t know exactly what ChatGPT is coding? Yes, it did at first. But now I use it as a tool. I may not be coding the Python, but I am managing ChatGPT through my well thought out prompts and my feedback. Does my knowledge of Python help streamline this process? – I think it does. And I have trained ChatGPT during the process. I am becoming a manager-programmer and ChatGPT is my assistant.
Discover more from George Pruitt
Subscribe to get the latest posts sent to your email.