portfolioperformance
v1.1.0
Outil pour tester les performances hors échantillon des modèles d'optimisation du portefeuille. Basé sur l'article: diversification optimale et naïve:
J'ai également développé un site Web de jeux pour ce package afin que vous puissiez facilement exécuter ces modèles sur vos propres données. Lien vers le site Web
pip install portfolioperformance
# Each model takes a name parameter
ew = 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" ) import numpy as np
from portfolioperformance import *
# Risk aversion levels
GAMMAS = [ 1 , 2 , 3 , 4 , 5 , 10 ]
# Time horizons
TIME_HORIZON = [ 60 , 120 ]
benchmark = < benchmark model >
# List of models
models = [
benchmark ,
# <add other list of models>
]
app = App ( < data path > , GAMMAS , TIME_HORIZON , models , dateFormat = < pandas datetime format > ,
dateRange = [ "01011990" , "01012010" ], delim = < "," or " \ s+" > ,
riskFactorPositions = [ positions for risk factor column ],
riskFreePosition = < risk free asset column > )
sr = app . getSharpeRatios ()
sig = app . getStatisticalSignificanceWRTBenchmark ( benchmark )path ( str ): chemin vers un fichier csvgammas ( list[int] ): liste des valeurs des gammastimeHorizon ( list[int] ): liste des horizons temporelsmodels ( list[Model] ): liste des classes de modèlesdateFormat ( str ): Pandas Date Heure Format, Default = "% Y-% M-% D"dateRange ( [str, str] ): Date de démarrage et de fin, par défaut = []delim ( str ): type de délimitation, "," ou " s +" (Whitespace), default = ","logScale ( bool ): si les données sont ou non dans l'échelle logarithmique, par défaut = falseriskFactorPositions ( list ): Positions de colonnes d'actifs de facteur de risque (où la position 1 est la colonne de date), par défaut = []riskFreePosition ( int ): Position de colonne d'actifs sans risque, par défaut = 1 getSharpeRatios() -> dict[str, float]Obtenez les ratios Sharpe
dict[str, float] : un dictionnaire avec nom de modèle et ratio Sharpe comme paire à valeur clé getStatisticalSignificanceWRTBenchmark(benchmark) -> dict[str, float]Obtenez la signification statistique par rapport à un modèle de référence
Paramètres:
benchmark ( Model ): modèle de référencedict[str, float] : un dictionnaire avec nom de modèle et ratio Sharpe comme paire à valeur clé git clone https://github.com/sidnand/portfolioperformancepip install -r requirements.txt .
| -- __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 functionsVeuillez créer une requête pull pour inclure vos modifications sur ce dépôt. Ces modifications seront reflétées sur le site Web de Playground lié ci-dessus.
pip install -e . Pour installer le package localement.setup.py . Veuillez utiliser le système sémantique de version 2.0.0. Cliquez pour en savoir plus.python setup.py sdist bdist_wheel pour créer une roue python.1.1.0
quadprog == 0.1.12 mise à jourpandas1.0.0
Python <= 3.9.9quadprog <= 0.1.11