Package: portfolioperformance
Portfolio PerformanceTool to  test the out-of-sample performance of portfolio optimization models. Based on the paper:Optimal Versus Naive Diversification:I have also developed a playground website for this package so you can easily run these models on your own data.Link to websiteUsageInstallationpip install portfolioperformanceModels# Each model takes a name parameterew=EqualWeight("Equal Weight")minVar=MinVar("Minimum Variance")JagannathanMa=JagannathanMa("Jagannathan Ma")minVarShortSellCon=MinVarShortSellCon("Minimum Variance with Short Sell Constrains")kanZhouEw=KanZhouEw("Kan Zhou EW")meanVar=MeanVar("Mean Variance (Markowitz)")meanVarShortSellCon=MeanVarShortSellCon("Mean Variance with Short Sell Constrains")kanZhou=KanZhou("Kan Zhou Three Fund")bayesStein=BayesStein("Bayes Stein")bayesSteinShortSellCon=BayesSteinShortSellCon("Bayes Stein with Short Sell Constrains")macKinlayPastor=MacKinlayPastor("MacKinlay and Pastor")Exampleimportnumpyasnpfromportfolioperformanceimport*# Risk aversion levelsGAMMAS=[1,2,3,4,5,10]# Time horizonsTIME_HORIZON=[60,120]benchmark=<benchmarkmodel># List of modelsmodels=[benchmark,# <add other list of models>]app=App(<datapath>,GAMMAS,TIME_HORIZON,models,dateFormat=<pandasdatetimeformat>,dateRange=["01011990","01012010"],delim=<","or"\s+">,riskFactorPositions=[positionsforriskfactorcolumn],riskFreePosition=<riskfreeassetcolumn>)sr=app.getSharpeRatios()sig=app.getStatisticalSignificanceWRTBenchmark(benchmark)APIApp ClassParameterspath(str): Path to acsvfilegammas(list[int]): List of gammas valuestimeHorizon(list[int]): List of time horizonsmodels(list[Model]): List of Model classesdateFormat(str): Pandas date time format, default = "%Y-%m-%d"dateRange([str, str]): Start and end date, default = []delim(str): Delimitation type, either "," or "\s+" (whitespace), default = ","logScale(bool): Whether or not data is in log-scale, default = FalseriskFactorPositions(list): Risk factor asset column positions (where position 1 is the date column), default = []riskFreePosition(int): Risk free asset column position, default = 1MethodsgetSharpeRatios() -> dict[str, float]Get the sharpe ratiosReturns: -dict[str, float]: A dictionary with model name and sharpe ratio as a key-valued pairgetStatisticalSignificanceWRTBenchmark(benchmark) -> dict[str, float]Get the statistical significance with respect to a benchmark modelParameters:benchmark(Model): Benchmark modelReturns:dict[str, float]: A dictionary with model name and sharpe ratio as a key-valued pairDevelopmentSetupClone project:git clone https://github.com/sidnand/portfolioperformanceInstall packages:pip install -r requirements.txtMake project:setappMake changes!Folder Structure.|--__init__.py# import /src/app.py and all models|--/src|--app.py# code for running all the optimiation models|--model.py# parent class to all the models|--modelNoGamma.py# class for models that don't take extra parameters|--modelGamma.py# class for models that take an extra gamma parameter; gamma is a list of constants for the investors risk-aversion level|--./models# all the models|--./utils|--filter.py# includes a function that is used to filter the parameters passed to a function|--quadprog.py# quadratic programming|--sharedOptions.py# models options that are in common with >2 models|--statistics.py# statistics functionsCreate Pull-RequestPlease create a pull-request to include your changes onto this repo. These changes will be reflected on the playground website linked above.Runpip install -e .to install the package locally.Make changes.Update version number insetup.py. Please use the Semantic Versioning 2.0.0 system.Click to learn more.Runpython setup.py sdist bdist_wheelto create a python wheel.Create a pull-request!