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