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 ) : 팬더 날짜 시간 형식, default = "%y-%m-%d"dateRange ( [str, str] ) : 시작 및 종료 날짜, 기본값 = []delim ( str ) : 구분 유형, "또는" s+"(whitespace), default =", "logScale ( bool ) : 데이터가 로그 스케일인지 아닌지, default = falseriskFactorPositions ( list ) : 위험 계수 자산 열 위치 (위치 1은 날짜 열입니다), default = []riskFreePosition ( int ) : 위험이없는 자산 열 위치, 기본값 = 1 getSharpeRatios() -> dict[str, float]Sharpe 비율을 얻으십시오
dict[str, float] : 모델 이름과 샤프 비율이 키 값 쌍으로 샤프 비율을 가진 사전 getStatisticalSignificanceWRTBenchmark(benchmark) -> dict[str, float]벤치 마크 모델에 대한 통계적 유의성을 얻으십시오.
매개 변수 :
benchmark ( Model ) : 벤치 마크 모델dict[str, float] : 주요 값 쌍으로 모델 이름과 Sharpe 비율이있는 사전 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변경 사항을이 레포에 포함시키기위한 풀 레퍼스트를 작성하십시오. 이러한 변경 사항은 위에 연결된 놀이터 웹 사이트에 반영됩니다.
pip install -e . 로컬로 패키지를 설치합니다.setup.py 에서 버전 번호를 업데이트합니다. 시맨틱 버전 2.0.0 시스템을 사용하십시오. 자세한 내용은 클릭하십시오.python setup.py sdist bdist_wheel 실행하여 파이썬 휠을 만듭니다.1.1.0
quadprog == 0.1.12 업데이트pandas 버전의 코드를 업데이트하십시오1.0.0
Python <= 3.9.9quadprog <= 0.1.11