portfolioperformance
v1.1.0
Alat untuk menguji kinerja out-of-sample dari model optimasi portofolio. Berdasarkan kertas: diversifikasi optimal versus naif:
Saya juga telah mengembangkan situs web taman bermain untuk paket ini sehingga Anda dapat dengan mudah menjalankan model ini pada data Anda sendiri. Tautan ke situs 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 ): path ke file csvgammas ( list[int] ): Daftar Nilai GammastimeHorizon ( list[int] ): Daftar Cakrawala Waktumodels ( list[Model] ): Daftar kelas modeldateFormat ( str ): Format Waktu Tanggal PANDAS, default = "%y-%m-%d"dateRange ( [str, str] ): Tanggal mulai dan akhir, default = []delim ( str ): Tipe pembatasan, baik "," atau " s+" (whitespace), default = ","logScale ( bool ): Apakah data dalam skala log atau tidak, default = falseriskFactorPositions ( list ): Posisi kolom aset faktor risiko (di mana posisi 1 adalah kolom tanggal), default = []riskFreePosition ( int ): Posisi kolom aset bebas risiko, default = 1 getSharpeRatios() -> dict[str, float]Dapatkan Rasio Sharpe
dict[str, float] : Kamus dengan nama model dan rasio Sharpe sebagai pasangan bernilai kunci getStatisticalSignificanceWRTBenchmark(benchmark) -> dict[str, float]Dapatkan signifikansi statistik sehubungan dengan model benchmark
Parameter:
benchmark ( Model ): Model Benchmarkdict[str, float] : Kamus dengan nama model dan rasio Sharpe sebagai pasangan bernilai kunci 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 functionsHarap buat permintaan pull untuk memasukkan perubahan Anda ke repo ini. Perubahan ini akan tercermin di situs web taman bermain yang ditautkan di atas.
pip install -e . Untuk menginstal paket secara lokal.setup.py . Harap gunakan sistem Semantic Versioning 2.0.0. Klik untuk mempelajari lebih lanjut.python setup.py sdist bdist_wheel untuk membuat roda python.1.1.0
quadprog == 0.1.12 Pembaruanpandas terbaru1.0.0
Python <= 3.9.9quadprog <= 0.1.11