language: VB.NET (mono-2.4.2.3)
date: 118 days 13 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
Attribute VB_Name = "modScenario"
Option Explicit
Option Base 1
 
Private oConfig             As Config
Private oAppErrorObject     As AppError
Private oFX                 As FX
Private oFso                As FileSystemObject
Private dBatchQuoteDate     As Date
Private vRiskCl             As Variant
Private oCmdLine            As CmdLineParams
Private dQuoteDate          As Date
Private dcGridPaths         As Dictionary
 
 
Private Enum ColsScenario
    RiskClass = 1
    Ticket
    BookType
    BookRegion
    TradeName
    ScenarioName
    Index
    Tranche
    Tenor
    Delta
    
    LastField
    NoOfCols = LastField - 1
End Enum
 
 
Private Enum ColsOldStyle
    TradeName = 1
    Group
    OBSTicketNo
    OBSGroupNo
    TradeType
    RiskClass
    CCY
    StartDate
    Curve
    Bucket
    BucketDate
    Tv
    RealDelta
    Delta
    ProductDelta
    MarketFactorDelta
    LiborGamma
    TVChange
    DeltaChange
    ProductDeltaChange
    UniversalCurrency
    RealDeltaChange
    CreditCurveShocks
    ScenarioName
    Index
    Tenor
    Tranche
    BookType
    
    LastField
    NoOfCols = LastField - 1
 
End Enum
 
 
 
Private Const thisObjectName    As String = "modScenario"
Private Const PIVOT_DATA_RANGE  As String = "PivotData"
Private Const PIVOT_TABLE_NAME  As String = "ScenarioPivotTable"
 
 
'Rev 29 -   Addition of RegionToIndex function within config class, rename of output fields + the addtion of bookregion,
'           Indexname, tranche & tenor as new data items.
    
'#############################################################################################
'   METHODS
'#############################################################################################
Public Sub Main()
    Dim xBatch      As IXMLDOMElement
    Dim xCopyTo     As IXMLDOMElement
    Dim xList       As IXMLDOMNodeList
    Dim xList2      As IXMLDOMNodeList
    Dim vFeed       As Variant
    Dim sPath       As String
        
On Error GoTo GenErr
    
    WriteToLog LogTypes.loginfo, "Batch creation begins for Quotedate:" & Format(RunDate, "dd-mmm-yyyy") & " Version: " & App.Major & "." & App.Minor & ":" & App.Revision
    
    Set xList = modScenario.Config.ConfigFile.selectNodes("app/batches/batch")
    'for each batch do
    For Each xBatch In xList
        'if all batches are meant to be run, or this specific batch is one targeted by command line param
        If CommandLineParams.BatchName = "" Or UCase(xBatch.getAttribute("name")) = CommandLineParams.BatchName Then
            
            'Create the report data from trade valuation source data
            WriteToLog LogTypes.loginfo, "Creating report data for batch (" & xBatch.getAttribute("name") & ")"
            vFeed = BuildReport(dQuoteDate, xBatch.getAttribute("name"), xBatch.getAttribute("skew_pattern"))
            
            'OUtput to where ever
            sPath = ""
            If Config.Environment = "UAT" Then
                If Not IsNull(xBatch.getAttribute("output_path_uat")) And xBatch.getAttribute("output_path_uat") <> "" Then
                    sPath = Config.OverlayDateString(xBatch.getAttribute("output_path_uat"), dQuoteDate)
                End If
            End If
            If sPath = "" Then
                sPath = Config.OverlayDateString(xBatch.getAttribute("output_path"), dQuoteDate)
            End If
            WriteToLog LogTypes.loginfo, "Outputing data to (" & sPath & ")"
            
            SaveFeed dQuoteDate, sPath, vFeed
            
            'Free Unlimited 'Copy To's!!!
            Set xList2 = xBatch.selectNodes("copyto")
            For Each xCopyTo In xList2
                sPath = Config.OverlayDateString(xCopyTo.getAttribute("output_path"), dQuoteDate)
                SaveFeed dQuoteDate, sPath, vFeed
            Next xCopyTo
            
        End If
    Next xBatch
    
    WriteToLog LogTypes.loginfo, "Generation COMPLETE"
    'close down
On Error GoTo 0
    Exit Sub
GenErr:
    'Log any errors that crop up
    WriteToLog LogTypes.LogError, AppErrors.Description
End Sub
 
 
Public Sub SaveFeed(ByVal QuoteDate As Date _
                        , ByVal Path As String _
                        , ByVal FeedData As Variant)
    Dim lRow    As Long
    Dim lField  As Long
    Dim sString As String
    Dim oStrm   As TextStream
On Error GoTo GenErr
    Set oStrm = FSO.CreateTextFile(Path, QuoteDate)
    For lRow = LBound(FeedData, 2) To UBound(FeedData, 2)
        sString = FeedData(LBound(FeedData), lRow)
        For lField = LBound(FeedData) + 1 To UBound(FeedData)
            sString = sString & vbTab & FeedData(lField, lRow)
        Next lField
        oStrm.WriteLine (sString)
    Next lRow
    oStrm.Write (sString)
    oStrm.Close
    Set oStrm = FSO.CreateTextFile(Left(Path, Len(Path) - Len(FSO.GetExtensionName(Path)) - 1) & ".done")
On Error GoTo 0
    Exit Sub
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..SaveFeed" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Sub
 
 
Private Function BuildReport(ByVal QuoteDate As Date _
                        , ByVal ReportAlias As String _
                        , ByVal SkewGridPattern As String) As Variant
    Dim xElem   As IXMLDOMElement
    Dim xDom    As DOMDocument
    Dim vOutput As Variant
    Dim vTrade  As Variant
    Dim lRow    As Long
    Dim lRowSub As Long
    Dim lField  As Long
    Dim oFso    As FileSystemObject
    Dim oFile   As File
    Dim sFile   As Variant
    Dim bLoaded As Boolean
    Dim oStrm   As TextStream
    
On Error GoTo GenErr
    lRow = 1
    ReDim vOutput(ColsOldStyle.NoOfCols, 1)
    
    'Seed output array
    vOutput(ColsOldStyle.Bucket, 1) = "Bucket"
    vOutput(ColsOldStyle.BucketDate, 1) = "BucketDate"
    vOutput(ColsOldStyle.CCY, 1) = "CCY"
    vOutput(ColsOldStyle.CreditCurveShocks, 1) = "CreditCurveShocks"
    vOutput(ColsOldStyle.Curve, 1) = "Curve"
    vOutput(ColsOldStyle.Delta, 1) = "Delta"
    vOutput(ColsOldStyle.DeltaChange, 1) = "DeltaChange"
    vOutput(ColsOldStyle.Group, 1) = "Group"
    vOutput(ColsOldStyle.LiborGamma, 1) = "LiborGamma"
    vOutput(ColsOldStyle.MarketFactorDelta, 1) = "MarketFactorDelta"
    vOutput(ColsOldStyle.OBSGroupNo, 1) = "OBSGroupNo"
    vOutput(ColsOldStyle.OBSTicketNo, 1) = "OBSTicketNo"
    vOutput(ColsOldStyle.ProductDelta, 1) = "ProductDelta"
    vOutput(ColsOldStyle.ProductDeltaChange, 1) = "ProductDeltaChange"
    vOutput(ColsOldStyle.RealDelta, 1) = "RealDelta"
    vOutput(ColsOldStyle.RealDeltaChange, 1) = "RealDeltaChange"
    vOutput(ColsOldStyle.RiskClass, 1) = "RiskClass"
    vOutput(ColsOldStyle.ScenarioName, 1) = "ScenarioName"
    vOutput(ColsOldStyle.Index, 1) = "Index"
    vOutput(ColsOldStyle.Tenor, 1) = "Tenor"
    vOutput(ColsOldStyle.Tranche, 1) = "Tranche"
    vOutput(ColsOldStyle.BookType, 1) = "BookType"
    vOutput(ColsOldStyle.StartDate, 1) = "StartDate"
    vOutput(ColsOldStyle.TradeName, 1) = "TradeName"
    vOutput(ColsOldStyle.TradeType, 1) = "TradeType"
    vOutput(ColsOldStyle.Tv, 1) = "Tv"
    vOutput(ColsOldStyle.TVChange, 1) = "TVChange"
    vOutput(ColsOldStyle.UniversalCurrency, 1) = "UniversalCurrency"
    
    Set oFso = New FileSystemObject
    Set xDom = New DOMDocument
    With xDom
        .async = True
        .validateOnParse = False
    End With
    
    For Each sFile In modScenario.Config.FileGroups("trade_valuation_info", QuoteDate)
        'Get the source file
        WriteToLog LogTypes.loginfo, "Converting TradeValuation file (" & sFile & ")"
        If oFso.FileExists(sFile) Then
            Set oFile = oFso.GetFile(sFile)
            
            'Load source file into xml dom, and loop thru each trade
            'bLoaded = xDom.Load(oFile.Path)
            Set oStrm = oFile.OpenAsTextStream
            oStrm.ReadLine
            bLoaded = xDom.loadXML(oStrm.ReadAll)
            If bLoaded Then
                For Each xElem In xDom.selectNodes("ValuationReport/TradeReport")
                    If Config.DebugLevel = 1 Then WriteToLog LogTypes.LogDebug, "Converting trade (" & xElem.selectSingleNode("TradeDetails/TradeName").Text & ")"
                    
                    'Build the sub report per trade, this is the bit that does the work.
                    vTrade = GenerateScenario(xElem, QuoteDate, ReportAlias, SkewGridPattern)
                    If IsArray(vTrade) Then
                    
                        'store in master array
                        ReDim Preserve vOutput(ColsOldStyle.NoOfCols, UBound(vOutput, 2) + UBound(vTrade, 2))
                        For lRowSub = LBound(vTrade, 2) To UBound(vTrade, 2)
                            lRow = lRow + 1
                            For lField = LBound(vTrade) To UBound(vTrade)
                                vOutput(lField, lRow) = vTrade(lField, lRowSub)
                            Next lField
                        Next lRowSub
                    Else
                        WriteToLog LogTypes.LogWarning, "Conversion of data for trade(" & xElem.selectSingleNode("TradeDetails/TradeName").Text & ")" _
                                    & " returned an empty array, TradeType(" & xElem.selectSingleNode("TradeDetails/TradeType").Text & ")"
                    End If
                Next xElem
            Else
                WriteToLog LogTypes.LogError, "A required source file is corrupt and cannot be loaded : " & sFile
            End If
        Else
            On Error GoTo 0
            WriteToLog LogTypes.LogError, "A required source file is missing : " & sFile
        End If
    Next sFile
    
    BuildReport = vOutput
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..BuildReport" _
                , Err.Source & ":" & Err.Description
    Exit Function
    Resume 0
End Function
 
 
Private Function GenerateScenario(TradeValueInfo As IXMLDOMElement _
                    , ByVal QuoteDate As Date _
                    , ByVal ReportAlias As String _
                    , Optional ByVal SkewGridPattern As String) As Variant
    
    Dim dbEquivAttach       As Double
    Dim dbEquivDetach       As Double
    Dim dbAttachSens        As Double
    Dim dbDetachSens        As Double
    Dim dbCorrDeltaDetach   As Double
    Dim dbCorrDeltaAttach   As Double
    Dim dbCorrDeltaBaseDetach As Double
    Dim dbCorrDeltaBaseAttach As Double
    
    Dim sRegions            As String
    Dim sCalibration        As String
    Dim sPortfolio          As String
    Dim sIndex              As String
    Dim vRegions            As Variant
    Dim vTenors             As Variant
    Dim vTranches           As Variant
    Dim vSkewTable          As Variant
    Dim sTicket             As String
    Dim sRiskCl             As String
    Dim sTradeName          As String
    Dim lMaturity           As Long
    Dim lValid              As Long
    Dim vReturn             As Variant
    Dim sCalibFullPath      As String
    Dim iRegion             As Integer
    Dim iMat                As Integer
    Dim iTranche            As Integer
    Dim iNoTranche          As Integer
    Dim sCCY                As String
    Dim dFX                 As Double
    Dim sSkewsRoot          As String
    Dim sTrancheAlias       As String
    Dim sStartDate          As String
    Dim sGroup              As String
    Dim vRiskClassDetails   As Variant
    Dim bIsValid            As Boolean
    Dim bCalcTrueTVChange   As Boolean
    Dim dLastTVChange       As Double
    Dim vTenorDates         As Variant
    Dim dRollDate           As Date
    
On Error GoTo GenErr
    'Get the trade value information from the xml blob
    sTicket = TradeValueInfo.selectSingleNode("TradeDetails/TicketNum").Text
    sGroup = TradeValueInfo.selectSingleNode("TradeDetails/DealGroupBy").Text
    sRiskCl = TradeValueInfo.selectSingleNode("TradeDetails/RiskClass").Text
    sTradeName = TradeValueInfo.selectSingleNode("TradeDetails/TradeName").Text
    lMaturity = CDate(TradeValueInfo.selectSingleNode("TradeDetails/Maturity").Text)
    sStartDate = TradeValueInfo.selectSingleNode("TradeDetails/StartDate").Text
    
    'get xml data data
    If Not TradeValueInfo.selectNodes("ValuationInfoReport/o/r") Is Nothing Then
        GetTradeValueData TradeValueInfo, dbEquivAttach, dbEquivDetach, dbAttachSens, dbDetachSens, sCCY, bIsValid
    Else
        GetTradeValueData_TVXML TradeValueInfo, dbEquivAttach, dbEquivDetach, dbAttachSens, dbDetachSens, sCCY, bIsValid
    End If
    
    If Not bIsValid Then Exit Function
    dFX = modScenario.FxObject.FxSpotRate(QuoteDate, sCCY, RegionCutsFX.EMEA)
    dbAttachSens = dbAttachSens * dFX
    dbDetachSens = dbDetachSens * dFX
    
    If Config.DebugLevel = 1 Then
        WriteToLog LogTypes.LogDebug, "ValuationInfo" & vbTab & sTradeName & vbTab & dbEquivAttach & vbTab _
                            & dbEquivDetach & vbTab & dbAttachSens & vbTab & dbDetachSens & vbTab & sCCY
    End If
    
    'Get RiskCL
    If Not Config.RiskClassStatic.Exists(sRiskCl) Then
        WriteToLog LogTypes.LogError, "Unknown RiskClass :" & sRiskCl & ", ignoring. (Ticket:" & sTicket & " TradeName:" & sTradeName
        Exit Function
    End If
    
    vRiskClassDetails = Config.RiskClassStatic(sRiskCl)
    sRegions = vRiskClassDetails(ColsRiskCl.IndexRegion)
    sCalibration = vRiskClassDetails(ColsRiskCl.CalibrationName)
    
    
    lValid = 1
    'put in base valuation data, not needed really, but olap wont work without it for LBCBR
    ReDim vReturn(ColsOldStyle.NoOfCols, 1)
    vReturn(ColsOldStyle.TradeName, lValid) = sTradeName
    vReturn(ColsOldStyle.RiskClass, lValid) = sRiskCl
    vReturn(ColsOldStyle.Group, lValid) = sRiskCl & "_" & sTicket
    vReturn(ColsOldStyle.OBSTicketNo, lValid) = sTicket
    vReturn(ColsOldStyle.OBSGroupNo, lValid) = sGroup
    vReturn(ColsOldStyle.StartDate, lValid) = sStartDate
    vReturn(ColsOldStyle.CCY, lValid) = sCCY
    vReturn(ColsOldStyle.TVChange, lValid) = 0
    
    'Get the relevant skew grid
    vRegions = Split(sRegions, "_")
    sSkewsRoot = GetSkewgridRootPath(QuoteDate, sCalibration)
    sCalibFullPath = sSkewsRoot & "\" & sCalibration & ".txt"
    vSkewTable = modScenario.Config.SkewGrid(sCalibFullPath)
    
    'Get the tenor list, assume that the tenor list is the same for both regions if there are mulitple ones.
    modScenario.Config.RegionDetails vRegions(LBound(vRegions)), sIndex, sPortfolio, vTranches, vTenors, dRollDate
    ReDim vTenorsDates(LBound(vTenors) To UBound(vTenors))
    For iMat = LBound(vTenors) To UBound(vTenors)
        If dRollDate = 0 Then
            vTenorsDates(iMat) = Format(GetIndexMaturityDate(vTenors(iMat), QuoteDate), "ddmmmyy")
        Else
            vTenorsDates(iMat) = Format(GetIndexMaturityDateForRollDate(vTenors(iMat), dRollDate), "ddmmmyy")
        End If
    Next iMat
    
    'derive the Base Att/Det pts.
    dbCorrDeltaBaseAttach = CorrelationDeltaInterpFromSkewTable(dbEquivAttach / 100, lMaturity, vSkewTable, vTenorsDates)
    dbCorrDeltaBaseDetach = CorrelationDeltaInterpFromSkewTable(dbEquivDetach / 100, lMaturity, vSkewTable, vTenorsDates)
    
    'for each region, do
    For iRegion = LBound(vRegions) To UBound(vRegions)
        modScenario.Config.RegionDetails vRegions(iRegion), sIndex, sPortfolio, vTranches, vTenors, dRollDate
        ReDim vTenorsDates(LBound(vTenors) To UBound(vTenors))
        For iMat = LBound(vTenors) To UBound(vTenors)
            If dRollDate = 0 Then
                vTenorsDates(iMat) = Format(GetIndexMaturityDate(vTenors(iMat), QuoteDate), "ddmmmyy")
            Else
                vTenorsDates(iMat) = Format(GetIndexMaturityDateForRollDate(vTenors(iMat), dRollDate), "ddmmmyy")
            End If
        Next iMat
 
        For iMat = LBound(vTenors) To UBound(vTenors)
            dLastTVChange = 0
            For iTranche = 1 To UBound(vTranches)
            
                'if this is lbcr, need to override Eq to 0
                If vTranches(iTranche) = "Eq" And ReportAlias = "lbcr" Then
                    vTranches(iTranche) = "0"
                End If
            
                If InStr(1, SkewGridPattern, "#TranchEnd#") Then
                    If iTranche = UBound(vTranches) Then
                        Exit For
                    End If
                    sTrancheAlias = vTranches(iTranche) & "-" & vTranches(iTranche + 1)
                Else
                    sTrancheAlias = vTranches(iTranche)
                End If
                
                lValid = lValid + 1
                ReDim Preserve vReturn(ColsOldStyle.NoOfCols, lValid)
                If iTranche = UBound(vTranches) Then
                    bCalcTrueTVChange = False
                    sCalibFullPath = BuildSkewGridPath(sSkewsRoot, SkewGridPattern, sPortfolio _
                                                    , vTenors(iMat), sCalibration, vTranches(iTranche))
                Else
                    bCalcTrueTVChange = True
                    sCalibFullPath = BuildSkewGridPath(sSkewsRoot, SkewGridPattern, sPortfolio _
                                                    , vTenors(iMat), sCalibration, vTranches(iTranche) _
                                                    , vTranches(iTranche + 1))
                End If
                
                'basic data
                vReturn(ColsOldStyle.TradeName, lValid) = sTradeName
                vReturn(ColsOldStyle.RiskClass, lValid) = sRiskCl
                vReturn(ColsOldStyle.Group, lValid) = sRiskCl & "_" & sTicket
                vReturn(ColsOldStyle.OBSTicketNo, lValid) = sTicket
                vReturn(ColsOldStyle.OBSGroupNo, lValid) = sGroup
                vReturn(ColsOldStyle.StartDate, lValid) = sStartDate
                vReturn(ColsOldStyle.CCY, lValid) = sCCY
                'Added for CMV2.0 - Hack for the scenario name
                'Replace Eq with 0
                vReturn(ColsOldStyle.ScenarioName, lValid) = Replace(sTrancheAlias, "Eq", 0) & vRegions(iRegion) & vTenors(iMat)
                vReturn(ColsOldStyle.Index, lValid) = sIndex
                vReturn(ColsOldStyle.Tenor, lValid) = vTenors(iMat)
                vReturn(ColsOldStyle.Tranche, lValid) = sTrancheAlias
                
                'Delta
                vSkewTable = modScenario.Config.SkewGrid(sCalibFullPath)
                dbCorrDeltaDetach = CorrelationDeltaInterpFromSkewTable(dbEquivDetach / 100, lMaturity, vSkewTable, vTenorsDates)
                dbCorrDeltaAttach = CorrelationDeltaInterpFromSkewTable(dbEquivAttach / 100, lMaturity, vSkewTable, vTenorsDates)
                
                'Hibbinni: Since CMV 2.5 we multiply this by -1 as the bump direction has been reversed.
                vReturn(ColsOldStyle.TVChange, lValid) = -((dbCorrDeltaBaseDetach - dbCorrDeltaDetach) * dbDetachSens _
                                        + (dbCorrDeltaBaseAttach - dbCorrDeltaAttach) * dbAttachSens) * 100 * -1
                vReturn(ColsOldStyle.DeltaChange, lValid) = vReturn(ColsOldStyle.TVChange, lValid) - dLastTVChange
                dLastTVChange = vReturn(ColsOldStyle.TVChange, lValid)
            Next iTranche
        Next iMat
    Next iRegion
    GenerateScenario = vReturn
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..GenerateScenario" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Function
 
Private Sub GetTradeValueData_TVXML(TradeValueXml As IXMLDOMElement _
                                , Attach As Double _
                                , Detach As Double _
                                , AttachSensitivity As Double _
                                , DetachSensitivity As Double _
                                , ValuationCcy As String _
                                , isValidCaOutput As Boolean)
 
    Dim lAttrib As Long
    Dim sAttach As String
    Dim sWidth  As String
    Dim sDetach As String
    Dim sAttachSensitivity  As String
    Dim sDetachSensitivity  As String
    
On Error GoTo GenErr
    'Check data exists
    If TradeValueXml.selectSingleNode("TVReport/EquivSubord") Is Nothing _
    Or TradeValueXml.selectSingleNode("TVReport/EquivWidth") Is Nothing _
    Or TradeValueXml.selectSingleNode("TVReport/dBasePVdRho") Is Nothing _
    Or TradeValueXml.selectSingleNode("TVReport/dTopPVdRho") Is Nothing _
    Or TradeValueXml.selectSingleNode("TVReport/TV") Is Nothing Then
        
        isValidCaOutput = False
        Exit Sub
    
    End If
       
    sAttach = TradeValueXml.selectSingleNode("TVReport/EquivSubord").Attributes.getNamedItem("value").Text
    If IsNumeric(sAttach) Then
        Attach = sAttach
    End If
    
    sWidth = TradeValueXml.selectSingleNode("TVReport/EquivWidth").Attributes.getNamedItem("value").Text
    If IsNumeric(sWidth) Then
        Detach = Attach + sWidth
    End If
    
    sAttachSensitivity = TradeValueXml.selectSingleNode("TVReport/dBasePVdRho").Attributes.getNamedItem("value").Text
    If IsNumeric(sAttachSensitivity) Then
        AttachSensitivity = sAttachSensitivity
    End If
    
    sDetachSensitivity = TradeValueXml.selectSingleNode("TVReport/dTopPVdRho").Attributes.getNamedItem("value").Text
    If IsNumeric(sDetachSensitivity) Then
        DetachSensitivity = sDetachSensitivity
    End If
        
    ValuationCcy = TradeValueXml.selectSingleNode("TVReport/TV").Attributes.getNamedItem("currency").Text
        
    isValidCaOutput = True
On Error GoTo 0
    Exit Sub
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..GetTradeValueData_TVXML" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Sub
 
 
 
Private Sub GetTradeValueData(TradeValueXml As IXMLDOMElement _
                                , Attach As Double _
                                , Detach As Double _
                                , AttachSensitivity As Double _
                                , DetachSensitivity As Double _
                                , ValuationCcy As String _
                                , isValidCaOutput As Boolean)
    Dim lRow            As Long
    Dim lRowAttach      As Long
    Dim lRowWidth       As Long
    Dim lColAttDetach   As Long
    Dim lColSensitivity As Long
    Dim lCol            As Long
    Dim dWidth          As Double
    Dim xRow            As IXMLDOMElement
    Dim bStart          As Boolean
    Dim lCurrentFound   As Long
    
    Const maxColsToFind   As Long = 2
    Const maxRowsToFind   As Long = 2
    
On Error GoTo GenErr
    For Each xRow In TradeValueXml.selectNodes("ValuationInfoReport/o/r")
        lCurrentFound = 0
        'Get valuation ccy
        If xRow.childNodes(0).Text = Config.TvRowTradeValuekey Then ValuationCcy = xRow.childNodes(2).Text
        
        'Get main measures
        If Not bStart Then
            If xRow.childNodes(0).Text = Config.TvStartkey Then
                bStart = True
                For lCol = 0 To xRow.childNodes.length - 1
                    Select Case xRow.childNodes(lCol).Text
                        Case Config.TvcolAttachkey
                            lColAttDetach = lCol
                            lCurrentFound = lCurrentFound + 1
                        Case Config.TvcolSensitivitykey
                            lColSensitivity = lCol
                            lCurrentFound = lCurrentFound + 1
                    End Select
                    If lCurrentFound = maxColsToFind Then
                        Exit For
                    End If
                Next lCol
                If lCurrentFound <> maxColsToFind Then
                    WriteToLog LogTypes.LogWarning, "XML appears incomplete for this trade, unable to find required data. (Initial Value is 0) " _
                            & "Attach/Detach Column : " & lColAttDetach & ".  Sensitivity Column : " & lColSensitivity
                    Exit Sub
                End If
            End If
        Else
            Select Case xRow.childNodes(0).Text
                Case Config.TvRowAttachkey
                    If IsNumeric(xRow.childNodes(lColAttDetach).Text) Then
                        Attach = xRow.childNodes(lColAttDetach).Text
                    Else
                        WriteToLog LogTypes.LogWarning, "Attach value is non numeric (" & xRow.childNodes(lColAttDetach).Text & ")"
                        Exit Sub
                    End If
                    If IsNumeric(xRow.childNodes(lColSensitivity).Text) Then
                        AttachSensitivity = xRow.childNodes(lColSensitivity).Text
                    Else
                        On Error GoTo 0
                        WriteToLog LogTypes.LogWarning, "AttachSensitivity value is non numeric (" & xRow.childNodes(lColSensitivity).Text & ")"
                        Exit Sub
                    End If
                    Detach = Attach + dWidth
                    lCurrentFound = lCurrentFound + 1
                Case Config.TvRowWidthkey
                    If IsNumeric(xRow.childNodes(lColAttDetach).Text) Then
                        dWidth = xRow.childNodes(lColAttDetach).Text
                    Else
                        On Error GoTo 0
                        WriteToLog LogTypes.LogWarning, "Width value is non numeric (" & xRow.childNodes(lColAttDetach).Text & ")"
                        Exit Sub
                    End If
                    If IsNumeric(xRow.childNodes(lColSensitivity).Text) Then
                        DetachSensitivity = xRow.childNodes(lColSensitivity).Text
                    Else
                        On Error GoTo 0
                        WriteToLog LogTypes.LogWarning, "DetachSensitivity value is non numeric (" & xRow.childNodes(lColSensitivity).Text & ")"
                        Exit Sub
                    End If
                    Detach = Attach + dWidth
                    lCurrentFound = lCurrentFound + 1
            End Select
            If lCurrentFound = maxRowsToFind Then Exit For
        End If
    Next xRow
    
    'If it wasn't found, return false
    isValidCaOutput = bStart
On Error GoTo 0
    Exit Sub
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..GetTradeValueData" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Sub
 
Private Function GetSkewgridRootPath(ByVal QuoteDate As Date _
                                    , ByVal CalibrationName As String)
    Dim lShift  As Long
    Dim sPath   As String
    Dim oFso    As FileSystemObject
On Error GoTo GenErr
    If dcGridPaths Is Nothing Then
        Set dcGridPaths = New Dictionary
    End If
    
    'supress the error that may be returned because folder doesn't exist
    If Not dcGridPaths.Exists(QuoteDate & "~" & CalibrationName) Then
On Error Resume Next
        sPath = modScenario.Config.Path("skew_grids", QuoteDate)
        Set oFso = New FileSystemObject
        
        If sPath = "" Or Not oFso.FileExists(oFso.BuildPath(sPath, CalibrationName & ".txt")) Then
            If sPath <> "" Then
                WriteToLog LogTypes.LogWarning, "Archive folder exists for " _
                        & Format(QuoteDate, "dd-mmm-yy") & ", but no skew grids for " & CalibrationName & " on path : " & oFso.BuildPath(sPath, CalibrationName & ".txt")
            End If
    
            For lShift = 1 To Config.MaxSkewShift
                sPath = modScenario.Config.Path("skew_grids", QuoteDate - lShift)
                If Err.Number <> 0 Then
                    WriteToLog LogTypes.LogWarning, Err.Description
                ElseIf Not oFso.FileExists(oFso.BuildPath(sPath, CalibrationName & ".txt")) Then
                    WriteToLog LogTypes.LogWarning, "Archive folder exists for " _
                        & Format(QuoteDate - lShift, "dd-mmm-yy") & ", but no skew grids for " & CalibrationName & " on path : " & oFso.BuildPath(sPath, CalibrationName & ".txt")
                    sPath = ""
                Else
                    Exit For
                End If
            Next lShift
        End If
        
On Error GoTo GenErr
            
        If sPath = "" Then
            On Error GoTo 0
            modScenario.AppErrors.Raise thisObjectName & "..GetSkewgridRootPath" _
                    , "There are no archived skewgrids in date range start(" & QuoteDate & _
                    ") end(" & QuoteDate - Config.MaxSkewShift & ")"
        Else
            dcGridPaths.Add QuoteDate & "~" & CalibrationName, sPath
        End If
    End If
        
    GetSkewgridRootPath = dcGridPaths.Item(QuoteDate & "~" & CalibrationName)
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..GetSkewgridRootPath" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Function
 
 
Private Function BuildSkewGridPath(ByVal SkewGridRoot As String _
                                    , ByVal SkewGridPattern As String _
                                    , ByVal Portfolio As String _
                                    , ByVal Tenor As String _
                                    , ByVal Calibration As String _
                                    , ByVal TranchStart As String _
                                    , Optional ByVal TranchEnd As String) As String
                                    
On Error GoTo GenErr
    SkewGridPattern = Replace(SkewGridPattern, "#Portfolio#", Portfolio)
    SkewGridPattern = Replace(SkewGridPattern, "#Tenor#", Tenor)
    SkewGridPattern = Replace(SkewGridPattern, "#Calibration#", Calibration)
    SkewGridPattern = Replace(SkewGridPattern, "#TranchStart#", TranchStart)
    SkewGridPattern = Replace(SkewGridPattern, "#TranchEnd#", TranchEnd)
    BuildSkewGridPath = SkewGridRoot & "\" & SkewGridPattern & ".txt"
                        
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..BuildSkewGridPath" _
                , Err.Source & ":" & Err.Description
    Resume Next
End Function
'
'
'Private Function GetIndexForRegion(ByVal Region As String) As String
'On Error GoTo GenErr
'    Select Case Region
'        Case "USD"
'            GetIndexForRegion = "CDX"
'        Case "EUR"
'            GetIndexForRegion = "iTraxx"
'        Case Else
'            modScenario.AppErrors.Raise thisObjectName & "..GetIndexForRegion" _
'                , "Region : " & Region & ", does not have an Index within the config."
'    End Select
'On Error GoTo 0
'    Exit Function
'GenErr:
'    modScenario.AppErrors.Raise thisObjectName & "..GetIndexForRegion" _
'                , Err.Source & ":" & Err.Description
'    Resume Next
'End Function
 
 
Private Function CorrelationDeltaInterpFromSkewTable(dAttachment, maturity, vSkewTable, TenorsDates)
On Error GoTo GenErr
    ' find the parameter cells in the table
    Dim nrow, i, k, NumPages, nRowsPerPage, offset
    Dim iSh As Integer
    Dim iDate   As Integer
    Dim dMat    As Date
    Dim sMat    As String
    Dim n1, n2
    Dim bIsRequired As Boolean
    Dim iActual     As Integer
    
    nrow = UBound(vSkewTable)
    For i = 2 To nrow
        If Not IsNumeric(vSkewTable(i, 1)) Then
            nRowsPerPage = i - 1
            Exit For
        End If
    Next i
    If nRowsPerPage = 0 Then nRowsPerPage = nrow
    NumPages = nrow / nRowsPerPage
    
    ReDim skewPagesParams(1 To 1)
    ReDim trancheBounds(1 To nRowsPerPage - 2, 1 To 1)
    ReDim skewValues(1 To nRowsPerPage - 2, 1 To 1)
    
    For k = 1 To NumPages
        offset = (k - 1) * nRowsPerPage
        'Get the maturity date from teh skew grid
        n1 = InStr(vSkewTable(offset + 1, 1), "MAT=")
        n2 = InStr(n1, vSkewTable(offset + 1, 1), ":")
        sMat = Mid(vSkewTable(offset + 1, 1), n1 + 4, n2 - n1 - 4)
        'Work out if this tenor is required
        bIsRequired = False
        For i = LBound(TenorsDates) To UBound(TenorsDates)
            If TenorsDates(i) = sMat Then
                bIsRequired = True
                Exit For
            'Else
                'Stop
            End If
        Next i
        'If it is, prepare for passing
        If bIsRequired Then
            iActual = iActual + 1
            ReDim Preserve skewPagesParams(1 To iActual)
            ReDim Preserve trancheBounds(1 To nRowsPerPage - 2, 1 To iActual)
            ReDim Preserve skewValues(1 To nRowsPerPage - 2, 1 To iActual)
            skewPagesParams(iActual) = vSkewTable(offset + 1, 1)
            For i = 1 To nRowsPerPage - 2
                trancheBounds(i, iActual) = vSkewTable(offset + 2 + i, 1)
                skewValues(i, iActual) = vSkewTable(offset + 1 + i, 2)
            Next i
        End If
    Next k
    CorrelationDeltaInterpFromSkewTable = CorrelationDeltaInterp(dAttachment, maturity, skewPagesParams, TransposeArray(trancheBounds), TransposeArray(skewValues))
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..CorrelationDeltaInterpFromSkewTable" _
                , Err.Source & ":" & Err.Description
    Resume 0
End Function
 
 
' given a detachment and a maturity
' and for each skew page:
'  parameters(cell(1,1))
'  the skew boundaries(cell(2,1)..(n,1))
'  the skew values    (cell(2,2)..(n,2))
' this will return the dinterpolated skew value
' (linear in maturity. Cubic spline natural bc's in attachment
Private Function CorrelationDeltaInterp(dAttachment, maturity, skewPageParms, trancheBounds, skewValues)
    ' stage 1 - extract from skewPageParms the maturity dates
    ' is found between "MAT=" and ":"
    Dim n ' no ofpages
    Dim i, n1, n2, sDat
    
On Error GoTo GenErr
    n = UBound(skewPageParms) - LBound(skewPageParms) + 1
    ReDim pageIndices(1 To n) As Long
    ReDim pageDates(1 To n) As Long
    For i = 1 To n
        n1 = InStr(skewPageParms(i), "MAT=")
        If n1 <= 0 Then
            CorrelationDeltaInterp = "Cannot find date in " + skewPageParms(i)
            Exit Function
        End If
        n2 = InStr(n1, skewPageParms(i), ":")
        sDat = Mid(skewPageParms(i), n1 + 4, n2 - n1 - 4)
        pageIndices(i) = i
        sDat = Left(sDat, 2) + "-" + Mid(sDat, 3, 3) + "-" + Right(sDat, Len(sDat) - 5)
        pageDates(i) = CDate(sDat)
    Next i
    
    ' find our date in this range
    ' organise interpolation
    Dim gDate, iDate, fDate, ns
    
    gDate = SimpleInterp(maturity, pageDates, pageIndices)
    If gDate < 1 Then gDate = 1
    If gDate > n Then gDate = n
    
    iDate = Int(gDate)
    fDate = gDate - iDate
    
    ' build interpolated skew curve
    ns = UBound(trancheBounds, 2)
    ReDim TrancheBoundsLessZero(1 To ns)
    ReDim InterpolatedSkews(1 To ns)
    For i = 1 To ns
        TrancheBoundsLessZero(i) = trancheBounds(1, i)
        If fDate = 0 Then
            InterpolatedSkews(i) = skewValues(iDate, i)
        Else
            InterpolatedSkews(i) = (1 - fDate) * skewValues(iDate, i) + fDate * skewValues(iDate + 1, i)
        End If
    Next i
    CorrelationDeltaInterp = SplineMe(dAttachment, TrancheBoundsLessZero, InterpolatedSkews)
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..CorrelationDeltaInterp" _
                , Err.Source & ":" & Err.Description
    Resume Next
End Function
 
Public Function GetIndexMaturityDateForRollDate(ByVal Tenor As String _
                                , Optional ByVal QuoteDate As Date) As Date
    
    Dim lYearShift      As Long
    Dim lMaturityMonth  As Long
    
    lMaturityMonth = Month(QuoteDate)
    
    Select Case UCase(Tenor)
        Case "3YR", "3Y", "03Y"
            lYearShift = 3
        Case "5YR", "5Y", "05Y"
            lYearShift = 5
        Case "7YR", "7Y", "07Y"
            lYearShift = 7
        Case "10YR", "10Y"
            lYearShift = 10
    End Select
 
    GetIndexMaturityDateForRollDate = DateSerial(Year(QuoteDate) + lYearShift, lMaturityMonth + 3, 20)
 
End Function
 
 
Public Function GetIndexMaturityDate(ByVal Tenor As String _
                                , Optional ByVal QuoteDate As Date) As Date
On Error GoTo GenErr
    Dim lMaturityMonth  As Long
    Dim lYearShift      As Long
    Dim bIsRollMonth    As Boolean
    
    If QuoteDate = 0 Then QuoteDate = Date
    Select Case Month(QuoteDate)
        Case Is > 8
            lMaturityMonth = 12
            If Month(QuoteDate) = 9 Then bIsRollMonth = True
        Case Is > 2
            lMaturityMonth = 6
            If Month(QuoteDate) = 3 Then bIsRollMonth = True
        Case Else
            lMaturityMonth = 0
            If Month(QuoteDate) = 12 Then bIsRollMonth = True
    End Select
    If Day(QuoteDate) < 20 And bIsRollMonth Then
        lMaturityMonth = lMaturityMonth - 6
    End If
    Select Case UCase(Tenor)
        Case "3YR", "3Y", "03Y"
            lYearShift = 3
        Case "5YR", "5Y", "05Y"
            lYearShift = 5
        Case "7YR", "7Y", "07Y"
            lYearShift = 7
        Case "10YR", "10Y"
            lYearShift = 10
    End Select
    GetIndexMaturityDate = DateSerial(Year(QuoteDate) + lYearShift, lMaturityMonth, 20)
    If GetIndexMaturityDate = 0 Then
        Stop
    End If
    Exit Function
 
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..CdsMaturityDate" _
                , Err.Description
    Resume Next
End Function
 
Private Function SplineMe(x, px, py)
On Error GoTo GenErr
    Dim vpx, vpy, n, nr
    If TypeName(px) = "Range" Then
        n = px.Cells.Count
        nr = px.Rows.Count
    Else
        n = UBound(px)
        nr = UBound(px)
    End If
    If x <= px(1) Then
        SplineMe = py(1)
    ElseIf x >= px(n) Then
        SplineMe = py(n)
    Else
        Dim d
        If nr > 1 Then
            SplineMe = Spline(px, py, False, 0, False, 0, x, False)
        End If
    End If
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..SplineMe" _
                , Err.Source & ":" & Err.Description
    Resume Next
End Function
 
 
Private Function SimpleInterp(ByVal x As Double _
                            , ByVal px As Variant _
                            , ByVal py As Variant)
    Dim lCount  As Long
On Error GoTo GenErr
    If x <= px(1) Then
        SimpleInterp = py(1)
    ElseIf x >= px(UBound(py)) Then
        SimpleInterp = py(UBound(py))
    Else
        For lCount = LBound(px) To UBound(px) - 1
            If x >= px(lCount) And x <= px(lCount + 1) Then
                SimpleInterp = (py(lCount + 1) - py(lCount)) / (px(lCount + 1) - px(lCount)) * (x - px(lCount)) + py(lCount)
                Exit For
            End If
        Next lCount
    End If
On Error GoTo 0
    Exit Function
GenErr:
    modScenario.AppErrors.Raise thisObjectName & "..SimpleInterp" _
                , Err.Source & ":" & Err.Description
    Resume Next
End Function
 
 
Function TransposeArray(ByVal MyArray As Variant _
                            , Optional ByVal TransposeForExcel As Boolean) As Variant
    Dim x As Long, Y As Long
    Dim vTemp       As Variant
    Dim xShift      As Integer
    Dim yShift      As Integer
    
    If IsEmpty(MyArray) Then
        Exit Function
    End If
    
    If TransposeForExcel Then
        xShift = 1 - LBound(MyArray, 2)
        yShift = 1 - LBound(MyArray)
    End If
    
On Error GoTo errTranspose
    ReDim vTemp(LBound(MyArray, 2) + xShift To UBound(MyArray, 2) + xShift, _
                LBound(MyArray) + yShift To UBound(MyArray) + yShift)
    For Y = LBound(MyArray) To UBound(MyArray)
        For x = LBound(MyArray, 2) To UBound(MyArray, 2)
            vTemp(x + xShift, Y + yShift) = MyArray(Y, x)
        Next x
    Next Y
    TransposeArray = vTemp
On Error GoTo 0
    Exit Function
errTranspose:
    modScenario.AppErrors.Raise "modUtil..TransposeArray", _
                "Error Transposing array." & vbLf, _
                Err.Source & ":" & Err.Description
End Function
 
 
 
 
'#############################################################################################
'   PROPERTIES
'#############################################################################################
Public Property Get AppErrors() As AppError
    If oAppErrorObject Is Nothing Then
        Set oAppErrorObject = New AppError
    End If
    Set AppErrors = oAppErrorObject
End Property
 
 
Public Property Get Config() As Config
    If oConfig Is Nothing Then
        Set oConfig = New Config
        If CommandLineParams.ConfigFilePath = "" Then
            Set oConfig.ConfigFile = xmlLoad(App.Path, "app.xml")
        Else
            Dim sPath As String
            sPath = CommandLineParams.ConfigFilePath
            Set oConfig.ConfigFile = xmlLoad(FSO.GetParentFolderName(sPath), FSO.GetFileName(sPath))
        End If
    End If
    Set Config = oConfig
End Property
Public Property Set Config(RHS As Config)
    Set oConfig = RHS
End Property
 
 
Public Property Get FSO() As FileSystemObject
    If oFso Is Nothing Then
        Set oFso = New FileSystemObject
    End If
    Set FSO = New FileSystemObject
End Property
 
 
Sub test()
    MsgBox FxObject.FxSpotRate("8 april 2006", "GBP", RegionCutsFX.EMEA)
End Sub
Public Property Get FxObject() As FX
    If oFX Is Nothing Then Set oFX = New FX
    Set FxObject = oFX
End Property
 
 
Public Property Get RunDate() As Date
    dQuoteDate = CommandLineParams.QuoteDate
    If dQuoteDate = 0 Then
        dQuoteDate = AddWeekDay(Date, -1)
    End If
    RunDate = dQuoteDate
End Property
 
 
Public Property Get CommandLineParams() As CmdLineParams
    'Get the quote date if its been past in command line, else default to previous business date
    If oCmdLine Is Nothing Then Set oCmdLine = New CmdLineParams
    
    Set CommandLineParams = oCmdLine
End Property
 
Visual Basic.Net Compiler version 0.0.0.5914 (Mono 2.4.2 - r)
Copyright (C) 2004-2008 Rolf Bjarne Kvinge. All rights reserved.


/home/VAGQb5/prog.vb (1,11) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (3,12) : Error VBNC30206: 'Option' must be followed by 'Compare', 'Explicit', or 'Strict'.
Error recovery not implemented yet.
/home/VAGQb5/prog.vb (5,16) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (6,24) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (7,12) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (8,13) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (9,24) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (10,16) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (11,17) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (12,19) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (13,20) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (70,14) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (71,14) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (72,14) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (81,11) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (82,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (83,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (84,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (85,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (86,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (87,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (89,3) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (91,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (93,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (95,8) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (97,11) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (100,23) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (101,18) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (104,18) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (105,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (106,19) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (107,26) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (108,23) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (109,19) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (110,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (111,22) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (112,19) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (113,23) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (115,21) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (118,16) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (119,16) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (120,22) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (121,25) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (122,17) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (124,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (125,9) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (127,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (129,3) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (130,9) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (131,7) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (133,15) : Error VBNC30203: Not valid as identifier.
/home/VAGQb5/prog.vb (133,15) : Error VBNC30041: Too many errors.
Exception of type 'vbnc.TooManyErrorsException' was thrown.
  at vbnc.Report.ShowMessage (Boolean SaveIt, vbnc.Message Message) [0x00080] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Report.vb:342 
  at vbnc.Report.ShowMessage (Messages Message, Span Location, System.String[] Parameters) [0x00000] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Report.vb:259 
  at vbnc.Report.ShowMessage (Messages Message, System.String[] Parameters) [0x00054] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Report.vb:269 
  at vbnc.Compiler.Compile () [0x005a3] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Compiler.vb:651 
  at vbnc.Compiler.Compile (System.String[] CommandLine) [0x00057] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Compiler.vb:279 
  at vbnc.Main.Main (System.String[] CmdArgs) [0x0000f] in /var/tmp/portage/dev-lang/mono-basic-2.4.2/work/mono-basic-2.4.2/vbnc/vbnc/source/General/Main.vb:55 
Failed compilation took 00:00:00.5866750