Here is the VBA code for "portfolio" module (I have redacted lot of stuff for ease):
Code:
Option Explicit
Private emflag As Boolean
'Private numberOfCDOs As Integer
Private numberOfAssets As Integer
Private numberOfObligors As Integer
Private numberOfIndustries As Integer
Private numberOfPools As Integer
Private numberOfRegions As Integer
Private totalDealDays As Double
Private deltaT As Double
Private assetArray() As asset
Private obligorArray() As obligor
Private pools() As pool
'Private assetsInObligor() As Integer
' Weighted average default probability
Private wadp As Double
Private totalNotional As Double
Public reinvmultiplier As Double
'_________________Generic Functions_______________________
Private Sub Class_Initialize()
Dim state As Integer
state = Application.Calculation
Application.Calculation = xlCalculationManual
Mode = Range("mode").Value
numberOfPeriods = Range("portfolio.num_periods").Value
numberOfYears = Range("portfolio.num_years").Value
paymentFrequency = Range("Frequency").Value
numberOfAssets = Range("portfolio.num_assets").Value
numberOfObligors = Range("portfolio.num_obligors").Value
numberOfCurrencies = Range("portfolio.num_currencies")
numberOfAssetClasses = Range("portfolio.number_asset_classes").Value
totalDealDays = Range("portfolio.total_deal_days").Value
If (Range("useDays360").Value = "y") Then
deltaT = 1 / 360
Else
deltaT = 1 / 365.25
End If
recoveryLag = Range("portfolio.recovery_delay").Value * paymentFrequency
emflag = Range("portfolio.emflag").Value
totalNotional = Range("portfolio.total_collateral_balance").Value
maturityAdjustment = Range("portfolio.maturityAdjustment").Value
Call getPeriodSizes
' Read the pool information
dealType = string2dealType(Range("portfolio.deal_type").Value)
If (dealType = CDO_1) Then
maxRevolvPd = Range("Revolv_PD").Value
numberOfPools = numberOfCurrencies * numberOfAssetClasses
Call readPoolInformation
numberOfCDOs = 0
Else
' In case of CDO^2 pool information is specific to CDOs
numberOfCDOs = Range("cdo_2.number_cdos").Value
End If
' Read default prob matrices
Call updateDefProb(Mode)
' Read the asset information
If (Mode = 2) Then
Call readAssetInformationMoodys
ElseIf (Mode = 3) Then
Call readAssetInformationSP
End If
'Setup the FX and Interest Curves
Call initalizeFXInterest
Application.Calculation = state
End Sub
Public Sub readPoolInformation()
Dim i As Integer, j As Integer
ReDim pools(0 To numberOfPools - 1) As pool
' Read the pool information
For i = 0 To numberOfCurrencies - 1
For j = 0 To numberOfAssetClasses - 1
Set pools(i * numberOfAssetClasses + j) = New pool
Call pools(i * numberOfAssetClasses + j).readPool(i, j)
Next j
Next i
End Sub
If this doesn't help spot the obvious cause, I can post the full code.