Esempio n. 1
0
 def loadDummyIRCurve(self, pricingDate):
     curve = InterestRateCurve()
     curve.ccy = 'USD'
     curve.index = Enum.Index('LIBOR')
     curve.term = 'M'
     curve.numTerms = 3
     curve.pricingDate = pricingDate
     curve.marketId = 'TEST1'
     r1 = InterestRate()
     r1.type = 'Deposit'
     r1.term = 'M'
     r1.numTerms = 1
     r1.mid = 0.01
     r1.curve = curve
     r2 = InterestRate()
     r2.type = 'Deposit'
     r2.term = 'M'
     r2.numTerms = 3
     r2.mid = 0.01
     r2.curve = curve
     r3 = InterestRate()
     r3.type = 'Swap'
     r3.term = 'Y'
     r3.numTerms = 1
     r3.mid = 0.01
     r3.curve = curve
     r4 = InterestRate()
     r4.type = 'Swap'
     r4.term = 'Y'
     r4.numTerms = 5
     r4.mid = 0.01
     r4.curve = curve
     r5 = InterestRate()
     r5.type = 'Swap'
     r5.term = 'Y'
     r5.numTerms = 10
     r5.mid = 0.01
     r5.curve = curve
     r6 = InterestRate()
     r6.type = 'Swap'
     r6.term = 'Y'
     r6.numTerms = 30
     r6.mid = 0.01
     r6.curve = curve
     curve.addRate(r1)
     curve.addRate(r2)
     curve.addRate(r3)
     curve.addRate(r4)
     curve.addRate(r5)
     curve.addRate(r6)
     curve.save()
Esempio n. 2
0
 def loadInterestRateFromCSVFile(self, fileName):
     '''
     Downloads prices from fileName. fileName needs to include full path
     '''
     file = open(fileName,'r')
     lastDate = Date.Date(month=1,day=1,year=1972)
     for line in file:
         items = line.split(',')
         #skip first line which is headers
         if items[0] == 'date':
             continue
         #create new curve if date has changed
         curveDate = self.createDateFromString(items[0])
         if curveDate <> lastDate:
             newCurve = InterestRateCurve()
             newCurve.pricingDate = curveDate
             newCurve.ccy = items[1]
             newCurve.index = items[2]
             newCurve.marketId = items[3]
             newCurve.term = items[4]
             newCurve.numTerms = int(items[5])
             newCurve.save()
             newCurve.load()
             #Delete all rates in case the curve already existed
             rates = InterestRate.objects.filter(curve=newCurve)
             if rates:
                 rates.delete()
         curve = InterestRateCurve()
         curve.pricingDate = curveDate
         curve.ccy = items[1]
         curve.index = items[2]
         curve.marketId = items[3]
         curve.term = items[4]
         curve.numTerms = int(items[5])
         curve.load()
         rate = InterestRate()
         rate.curve = curve
         rate.type = items[6]
         rate.term = items[7]
         rate.numTerms = int(items[8])
         rate.mid = float(items[9])
         rate.save()
         lastDate = curveDate