portfolioperformance
v1.1.0
測試投資組合優化模型的樣本外部性能的工具。基於論文:最佳與天真多樣化:
我還為此軟件包開發了一個遊樂場網站,因此您可以在自己的數據上輕鬆運行這些模型。鏈接到網站
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 ):通往csv文件的路徑gammas ( list[int] ):伽馬值列表timeHorizon ( list[int] ):時間範圍列表models ( list[Model] ):模型類列表dateFormat ( str ):熊貓日期時間格式,默認值=“%y-%m%d”dateRange ( [str, str] ):開始和結束日期,默認值= []delim ( str ):劃界類型,“”或“ s+”(whitespace),默認=“,”logScale ( bool ):數據是否在日誌尺度中,默認值= falseriskFactorPositions ( list ):風險因素資產列位置(位置1是日期列),默認值= []riskFreePosition ( int ):無風險資產列位置,默認值= 1 getSharpeRatios() -> dict[str, float]獲得夏普比率
dict[str, float] :具有型號名稱和夏普比率的詞典作為鑰匙值對getStatisticalSignificanceWRTBenchmark(benchmark) -> dict[str, float]獲得基準模型的統計意義
參數:
benchmark ( Model ):基準模型dict[str, float] :具有模型名稱和夏普比率的字典作為鑰匙值對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 functions請創建一個plupquest,以將您的更改包括在此存儲庫中。這些更改將反映在上面鏈接的操場網站上。
pip install -e .在本地安裝軟件包。setup.py中。請使用語義版本2.0.0系統。單擊以了解更多信息。python setup.py sdist bdist_wheel以創建python輪。1.1.0
quadprog == 0.1.12更新pandas版本的代碼1.0.0
Python <= 3.9.9quadprog <= 0.1.11