CVaR को न्यूनतम करना
यह अभ्यास आपको PyPortfolioOpt के उन टूल्स का अभ्यास कराएगा जो CVaR को जोखिम प्रबंधन के उद्देश्य के रूप में न्यूनतम करने में काम आते हैं.
आप pypfopt.efficient_frontier मॉड्यूल लोड करेंगे और EfficientCVaR क्लास प्राप्त करेंगे, फिर 2005 - 2010 अवधि के निवेश बैंकों की एसेट्स का उपयोग करके इस क्लास का एक इंस्टेंस बनाएँगे.
इसके बाद आप उस इंस्टेंस के min_cvar() मेथड का उपयोग करके ऐसे ऑप्टिमल पोर्टफोलियो वेट्स निकालेंगे जो CVaR को न्यूनतम करें.
पोर्टफोलियो एसेट रिटर्न returns वेक्टर में हैं—इस अभ्यास में एक names डिक्शनरी भी है जो पोर्टफोलियो वेट्स को बैंकों के नामों से मैप करती है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Quantitative Risk Management
अभ्यास निर्देश
pypfopt.efficient_frontierसेEfficientCVaRक्लास इम्पोर्ट करें.returnsका उपयोग करकेEfficientCVaRक्लास काecइंस्टेंस बनाएँ; ध्यान दें कि आपकोexpected_returnsकी ज़रूरत नहीं है, क्योंकि ऑब्जेक्टिव फंक्शन mean-variance optimization से अलग है.ecके.min_cvar()मेथड से ऑप्टिमल पोर्टफोलियो निकालें और दिखाएँ.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import the EfficientCVaR class
from pypfopt.____ import EfficientCVaR
# Create the efficient frontier for CVaR minimization
ec = ____(None, ____)
# Find the cVaR-minimizing portfolio weights at the default 95% confidence level
optimal_weights = ec.____()
# Map the values in optimal_weights to the bank names
optimal_weights = { names[i] : optimal_weights[i] for i in optimal_weights}
# Display the optimal weights
print(optimal_weights)