Hi guys,
I'm starting my EPAT course this week and I'm very excited.
I'm trying to figure out how to analyze a long/short portfolio of stocks and its performance in Python. The trades are from a system that is not run in Python. How can I analyze that performance in Python?
Also, is there a way for me to develop my own Python portfolio analysis tool where I can check every week what the beta of my stocks are, their volatility against my benchmark, my sector allocation and etc etc etc… ?
Thank you,
Bruno
Hi Bruno,
There are several performance measures such as Sharpe ratio, maximum drawdown, annualised returns, Sortino ratio, etc. to analyse the performance of the strategy. You can create a Python function for these measures and also reuse these functions to analyse the performance daily, weekly, etc (with the change in data).
Some of these measures and their implementation in Python are covered in EPAT curriculum.
Yeah I know. I was wondering the best way to perform those analysis from trades that are not from a Python strategy. I'm trying to analyze the performance of a discretionary portfolio of equities.
The best way to do this is to export the trade details or portfolio daily dollar value into a CSV or Excel file and import in Python. You can import the CSV and Excel file in Python using pandas read_csv or read_excel function. After this, you can write functions to various portfolio analysis and call these functions on the imported data.
For example,
If you have following trade details in 'trades.csv' then you can import in python as
import pandas as pd
trade_details = pd.read_csv('trades.csv')
then you can call the below function to calculate the total PnL
trade_details.PnL.sum()
Similarly, you can call different functions to compute the advanced analytics.
I hope this helps.