BasisSwapPortfolio Example VB6





http://www.QuantTools.com
CapeTools Basis Swap Portfolio function list
BasisSwapPortfolio function

Welcome | Documentation format | QuantTools Groups | QuantTools Categories | Licence

Key TAGs | Excel Index | API Index



Example Visual Basic 6 Driver function. Preparing the parameters and the final function call (the result).

High level view of the code structure (resulting in the final function call to BasisSwapPortfolio() )

These are the financial QuantTools function calls that are used within the examples :





The objects generated by these functions are inter-connected in the following way :




VB6 Example - BasisSwapPortfolio





    '     ##################################################################################
    '     The first function here BasisSwapPortfolio(), contains a series of
    '     function calls leading upto the main function call, the second function
    '     within this file ( BasisSwapPortfolioPart() ).
    '     which contains the answer that we are looking for.

    '     The first function here is simply an example of how to construct the parameters 
    '     in order acquire either a string Key (that is to be passed to other functions) 
    '     or a computed result.

    '     If you are viewing this source code from the chm or web help file you can use the
    '     outlining features to collapse certain sections of the code for better readability. 
    '     ##################################################################################
                        


' Add a reference to the CTQL.dll ActiveX library (dll)

' Some global parameter in order to append to user defined keys.
' We use it here to ensure that we have unique Keys (in the case several of our examples
' use the same key-name)
' In normal use, a user defined string will be used and so this variable will be pointless.
Global nCTBSWPortfolioGlobal As Long
    
    
Public Function VB_EX_BasisSwapPortfolio() As String

    nCTBSWPortfolioGlobal = nCTBSWPortfolioGlobal + 1
            
    
On Error GoTo err_Generic
        
            
    

    '    UK date calendar used within the UK stock exchange.

    Dim MyCALUKExchange As String
    MyCALUKExchange = _
        CALUKExchangePart()


    

    '    EURO calendar used for holiday adjustments.

    Dim MyEuroCal As String
    MyEuroCal = _
        CALEUROPart()


    

    '    Creates a centralized valuation date object.

    Dim MyValuationDate As String
    MyValuationDate = _
        ValueDateObjPart()


    

    '    UK date calendar.

    Dim MyCALUKSettlement As String
    MyCALUKSettlement = _
        CALUKSettlementPart()


    

    '    TARGET calendar used for holiday adjustments.

    Dim MyTargetCal2 As String
    MyTargetCal2 = _
        CALTARGET__2Part()


    

    '    Creates a Deposit template which is almost identical to a Libor 
    '    Index, but without the YieldCurve information.
    Dim MyGBPDepoTPL As String
    MyGBPDepoTPL = _
        CreateDepoTemplate__3Part( _
        MyCALUKExchange, _
        MyCALUKSettlement)


    

    '    Creates a Swap template which is almost identical to the definition 
    '    of the parameters of a swap contract, but without the swap duration, 
    '    buysell, and YieldCurve information.
    Dim MyGBPSwapTPL As String
    MyGBPSwapTPL = _
        CreateSwapTemplate__4Part( _
        MyCALUKSettlement, _
        MyGBPDepoTPL)


    

    '    Creates a Deposit template which is almost identical to a Libor 
    '    Index, but without the YieldCurve information.
    Dim MyDepoTPL As String
    MyDepoTPL = _
        CreateDepoTemplatePart( _
        MyCALUKExchange, _
        MyEuroCal)


    

    '    Creates a Swap template which is almost identical to the definition 
    '    of the parameters of a swap contract, but without the swap duration, 
    '    buysell, and YieldCurve information.
    Dim MySwapTPL As String
    MySwapTPL = _
        CreateSwapTemplatePart( _
        MyEuroCal, _
        MyDepoTPL)


    

    '    Creates a yield curve using market rates and cross currency 
    '    swaps (against the dollar).
    Dim MyYC_XCCY_DCF As String
    MyYC_XCCY_DCF = _
        MKTYC_XCCY_DPart( _
        MyValuationDate, _
        MyDepoTPL, _
        MySwapTPL)


    

    '    Creates a SABR curve to model the dynamics of the volatility 
    '    curve (smile).
    Dim MySABRVolCurve As String
    MySABRVolCurve = _
        SABRVolCurvePart( _
        MyValuationDate, _
        MyDepoTPL, _
        MySwapTPL)


    

    '    Creates a new Index code.
    Dim My1MIndex As String
    My1MIndex = _
        CreateIndex__5Part( _
        MyCALUKExchange, _
        MyEuroCal, _
        MyYC_XCCY_DCF)


    

    '    Creates a new Index code.
    Dim My2MIndex As String
    My2MIndex = _
        CreateIndex__6Part( _
        MyCALUKExchange, _
        MyEuroCal, _
        MyYC_XCCY_DCF)


    

    '    Creates a new Index code.
    Dim My3MIndex As String
    My3MIndex = _
        CreateIndex__7Part( _
        MyCALUKExchange, _
        MyEuroCal, _
        MyYC_XCCY_DCF)


    

    '    Creates a new Index code.
    Dim My6MIndex As String
    My6MIndex = _
        CreateIndex__8Part( _
        MyCALUKExchange, _
        MyEuroCal, _
        MyYC_XCCY_DCF)


    

    '    Creates a new Index code.
    Dim My12MIndex As String
    My12MIndex = _
        CreateIndex__9Part( _
        MyCALUKExchange, _
        MyEuroCal, _
        MyYC_XCCY_DCF)


    

    '    Creates a new Index based on SWAP details.
    Dim MyCMS5Y As String
    MyCMS5Y = _
        CreateSwapIndex__2Part( _
        MyTargetCal2, _
        My3MIndex)


    

    '    Creates a new Index based on SWAP details.
    Dim MyCMS10Y As String
    MyCMS10Y = _
        CreateSwapIndex__3Part( _
        MyTargetCal2, _
        My3MIndex)


    

    '    Creates a yield curve using market rates (No cross-currency 
    '    Swaps).
    Dim MyGBPYC As String
    MyGBPYC = _
        MKTYC_D__4Part( _
        MyValuationDate, _
        MyGBPDepoTPL, _
        MyGBPSwapTPL)


    

    '    GBPLibor, Pound Sterling LIBOR fixed by BBA.
    Dim MyGBPIndex As String
    MyGBPIndex = _
        IDXGBPLiborPart( _
        MyGBPYC)


    

    '    Creates a container to hold a group of Index objects.
    Dim MyGroupedIndex As String
    MyGroupedIndex = _
        GroupedIndexPart( _
        My1MIndex, _                
        My2MIndex, _                
        My3MIndex, _                
        My6MIndex, _                
        My12MIndex, _                
        MyGBPIndex, _                
        MyCMS5Y, _                
        MyCMS10Y)


    

    '    Creates a basis swap portfolio (same currency) object.
    Dim MyBasisSwapPortfolio As String
    MyBasisSwapPortfolio = _
        BasisSwapPortfolioPart( _
        MyGroupedIndex, _
        MyYC_XCCY_DCF, _
        MySABRVolCurve)

    ' This is the result we are looking for.
    VB_EX_BasisSwapPortfolio = MyBasisSwapPortfolio

            
    
    Exit Function
err_Generic:
    MsgBox "Error: " & Err.Number & vbCrLf & Err.Description    
    
            
End Function                
        


' ///////////////////////////////////////////////////////////////////

Private Function BasisSwapPortfolioPart( _
    MyGroupedIndex As String, _                
    MyYC_XCCY_DCF As String, _                
    MySABRVolCurve As String) As String


    
        '  Create example range for parameter BasisSwapPortfolio_SwapRange


        Dim BasisSwapPortfolio_SwapRange As Variant
        
        BasisSwapPortfolio_SwapRange = vRange.RangeFromStr _
         ( _
        CStr("{") + _
        CStr("SwapName     | PayRec     | StartDate     | EndDate     | Notional     | PrincipalExchange     | IndexCode1     | InArrears1     | Margin1     | CMSRho1     | IndexCode2     | InArrears2     | Margin2     | CMSRho2 ;") + _
        CStr("BSW-123456     | reciever     | #21/Jul/2011#     | #21/Jul/2016#     | 50000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR1M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2012 - EURLIBOR1M     | reciever     | #21/Jul/2012#     | #21/Jul/2017#     | 50000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR1M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2013 - EURLIBOR1M     | reciever     | #21/Jul/2013#     | #21/Jul/2018#     | 50000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR1M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2014 - EURLIBOR1M     | reciever     | #21/Jul/2014#     | #21/Jul/2019#     | 50000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR1M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2015 - EURLIBOR6M     | reciever     | #21/Jul/2015#     | #21/Jul/2020#     | 50000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR6M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2016 - EURLIBOR6M     | payer     | #21/Jul/2016#     | #21/Jul/2021#     | 10000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR6M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2017 - EURLIBOR6M     | payer     | #21/Jul/2017#     | #21/Jul/2022#     | 10000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR6M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2018 - EURLIBOR12M     | payer     | #21/Jul/2018#     | #21/Jul/2023#     | 10000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR12M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2019 - EURLIBOR12M     | payer     | #21/Jul/2019#     | #21/Jul/2024#     | 10000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR12M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2020 - EURLIBOR12M     | payer     | #21/Jul/2020#     | #21/Jul/2025#     | 10000000     | False     | EURLIBOR3M     | False     | 0.0002     | 0     | EURLIBOR12M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2021 - EURLIBOR12M     | payer     | #21/Jul/2021#     | #21/Jul/2026#     | 10000000     | False     | EURLIBOR3M     | True     | 0.0002     | 0     | EURLIBOR12M     | False     | 0.0002     | 0 ;") + _
        CStr("BSW : 21-Jul-2022 - EURCMS5Y     | payer     | #21/Jul/2022#     | #21/Jul/2027#     | 10000000     | False     | EURLIBOR3M     | True     | 0.0002     | 0     | EURCMS5Y     | False     | 0.0002     | 0.8 ;") + _
        CStr("BSW : 21-Jul-2023 - EURCMS5Y     | payer     | #21/Jul/2023#     | #21/Jul/2028#     | 10000000     | False     | EURLIBOR3M     | True     | 0.0002     | 0     | EURCMS5Y     | False     | 0.0002     | 0.8 ;") + _
        CStr("BSW : 21-Jul-2024 - EURCMS10Y     | payer     | #21/Jul/2024#     | #21/Jul/2029#     | 10000000     | False     | EURLIBOR3M     | True     | 0.0002     | 0     | EURCMS10Y     | False     | 0.0002     | 0.8 ;") + _
        CStr("BSW : 21-Jul-2025 - EURCMS10Y     | payer     | #21/Jul/2025#     | #21/Jul/2030#     | 10000000     | False     | EURLIBOR3M     | True     | 0.0002     | 0     | EURCMS10Y     | False     | 0.0002     | 0.8") + _
        CStr("}") _
         )
    



    '    Key Handle to be used for the new Portfolio object.
        Dim MyBasisSwapPortfolio As String
        MyBasisSwapPortfolio = "MyBasisSwapPortfolio" & "_" & CStr(nCTBSWPortfolioGlobal)


    '    When creating this object for the first time, set this parameter 
    '    to a positive value.
        Dim Reload As Long
        Reload = 1

                    
    '  Excel function call is : "CT.BOOK.BasisSwapPortfolio()"

    '    Creates a basis swap portfolio (same currency) object.
        Dim rBasisSwapPortfolio As String 
        Dim oCTBSWPortfolio As New CTQL.CTBSWPortfolio
    
        rBasisSwapPortfolio = oCTBSWPortfolio.BasisSwapPortfolio( _
                MyBasisSwapPortfolio, _
                Reload, _
                MyGroupedIndex, _
                MyYC_XCCY_DCF, _
                MySABRVolCurve, _
                BasisSwapPortfolio_SwapRange)


    BasisSwapPortfolioPart = rBasisSwapPortfolio
    
End Function                        








Copyright (c) 2003-2007 CapeTools - All Rights Reserved.