portfolioperformance
v1.1.0
ポートフォリオ最適化モデルのサンプル外のパフォーマンスをテストするツール。論文に基づいて:最適と素朴な多様化:
また、このパッケージ用のプレイグラウンド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 ): csvファイルへのパスgammas ( list[int] ):ガンマ値のリストtimeHorizon ( list[int] ):タイムホライトンのリストmodels ( list[Model] ):モデルクラスのリストdateFormat ( str ):pandas date time format、default = "%y-%m-%d"dateRange ( [str, str] ):開始日と終了日、デフォルト= []delim ( str ):区切りタイプ、 "、"または " s+"(whitespace)、default = "、"logScale ( bool ):データがログスケールにあるかどうか、default = 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このリポジトリに変更を含めるために、プルリケストを作成してください。これらの変更は、上記のリンクされた遊び場のウェブサイトに反映されます。
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