Beispiel #1
0
 def test_toDataFrameBig(self):
     Input = CRIF.CrifUtil.read_csv(r'..\Testdatensatz1_CRIF.csv')
     crifs = Crifs(Input)
     crif = crifs.get(next(iter(crifs)))
     imTree = StandardCalculation.calculate(crif)
     df = imTree.toDataFrame()
     imTree.printToCsv(r'..\ExampleTreeAsCsv.csv')
Beispiel #2
0
 def test_sample_multiCrifImport(self):
     csvLocation = 'test/UnitTest_CRIF.txt'
     # Use the Crifs class to create a dictionary of crifs of different counterparties, directions and regulations:
     crifs = Crifs(CRIF.CrifUtil.read_csv(csvLocation, sep='\t'))
     # A Crifs object may be used as any other python Dictionary. The key is a concatenated String of the Form
     # counterparty_direction_regulation and the values are the associated Crif Objects.
     print('CRIFS: ' + str(crifs))
     for crifkey, crif in crifs.items():
         print('Selected CRIF: ' + str(crif))
     asdf = 1
Beispiel #3
0
 def test7(self):
     Input = CrifUtil.read_csv(r'../Testdatensatz1_CRIF.csv')
     crifs = Crifs(Input)
     crif = crifs.values().__iter__().__next__()
     leArray = crif.getAllScheduleNotionals()
     value = leArray[0].getAmount().doubleValue()
     self.assertEqual(value, 140002181.4934)
     crif = crifs['CDS-10015292-18_collect_EMIR']
     leArray = crif.getAllScheduleNotionals()
     value = leArray[3].getAmountUSD().doubleValue()
     self.assertEqual(value, 18000000)
Beispiel #4
0
 def test8(self):
     Input = CrifUtil.read_csv(r'../Testdatensatz1_CRIF.csv')
     crifs = Crifs(Input)
     crif = crifs['CDS-10015292-18_collect_EMIR']
     leArray = crif.getAllSchedulePVs()
     value = leArray[0].getAmountUSD().doubleValue()
     self.assertEqual(value, 4831209.57108)
Beispiel #5
0
 def test9(self):
     Input = CrifUtil.read_csv(r'../Unittest_CRIF.txt', sep='\t')
     crifs = Crifs(Input)
     crif = crifs['testAN1_collect_EMIR']
     notionals = crif.getAllAddonNotionals()
     factors = crif.getAllAddOnNotionalFactors()
     notionals = JavaArrayListToPythonList(notionals)
     factors = JavaArrayListToPythonList(factors)
     self.assertEqual(notionals[0].getNotional().doubleValue(), 10000000.0)
     self.assertEqual(factors[0].getFactor().doubleValue(), 6.105)
Beispiel #6
0
 def test_bumpSchedulePVs(self):
     eps = 0.1
     Input = CRIF.CrifUtil.read_csv(r'..\ScheduleTestSet.csv', sep=',')
     crifs = Crifs(Input)
     crif = crifs['Contract_1_collect_EMIR']
     bumpedCrif = BumpedCrif(crif, 'trd1', eps)
     origSchedulePVs = crif.getAllSchedulePVs()
     schedulePVs = bumpedCrif.getAllSchedulePVs()
     self.assertEqual(origSchedulePVs[0].getAmountUSD().doubleValue(), 2200)
     self.assertEqual(origSchedulePVs[1].getAmount().doubleValue(), -4000)
     self.assertEqual(schedulePVs[0].getAmountUSD().doubleValue(), 2420)
     self.assertEqual(schedulePVs[1].getAmount().doubleValue(), -4000)
Beispiel #7
0
 def test_bumpAddOnNotional(self):
     eps = 0.1
     tradeId = 'AN3'
     Input = CRIF.CrifUtil.read_csv(r'..\Unittest_CRIF.txt', sep='\t')
     crifs = Crifs(Input)
     crif = crifs['testAN1_collect_EMIR']
     bumpedCrif = BumpedCrif(crif, tradeId, eps)
     notionals = bumpedCrif.getAllAddonNotionals()
     notionals = JavaArrayListToPythonList(notionals)
     origNotionals = crif.getAllAddonNotionals()
     origNotionals = JavaArrayListToPythonList(origNotionals)
     self.assertEqual(notionals[0].getNotionalUsd().doubleValue(), 11000000)
     self.assertEqual(origNotionals[0].getNotionalUsd().doubleValue(),
                      10000000)
Beispiel #8
0
 def test1(self):
     Input = CrifUtil.read_csv(r'../Testdatensatz1_CRIF.csv')
     crifs = Crifs(Input)
     self.assertEqual('CDS-10005292-18_collect_EMIR', crifs.keys().__iter__().__next__())
Beispiel #9
0
 def test2(self):
     Input = CrifUtil.read_csv(r'../Testdatensatz1_CRIF.csv')
     crifs = Crifs(Input)
     self.assertEqual(crifs.__len__(), 8)
Beispiel #10
0
 def test_ScheduleOnly(self):
     df = CRIF.CrifUtil.read_csv('../ScheduleTestSet.csv')
     crif = Crifs(df)['Contract_1_collect_EMIR']
     imTree = StandardCalculation.calculate(crif)
     self.assertEqual(round(imTree.get_node(0).data.ExposureAmount,0), 50400)
 def testNettingsAsExpectedPv(self):
     crifs = Crifs(CRIF.CrifUtil.read_csv('..\ScheduleTestSet.csv'))
     crif = crifs['NettingsAsExpectedPv_collect_EMIR']
     imTree = StandardCalculation.calculate(crif)
     self.assertEqual(10, imTree.getMargin())
 def testNettingAndAbsoluteNotional(self):
     crifs = Crifs(CRIF.CrifUtil.read_csv('..\ScheduleTestSet.csv'))
     crif = crifs['NettingAndAbsoluteNotional_collect_EMIR']
     imTree = StandardCalculation.calculate(crif)
     self.assertAlmostEquals(8, imTree.getMargin(), places=5)