Checked my loop several times. I cannot spot a mistake need another pair of eyes to help out. The code below is returning none while it should return a particular value.
I have checked the value of self.mdlname it is correct. I think there is something to do with with first function curr. It is not correctly reassigning value to self.currency. I see no other reason why it should return a none value.
Below ommitted functions after spartSABR function
import string
datatype = "Inflation SABR Vol ATM ZC"
dataconvention = "UK-RPI-ZERO-COUPON-SWAP-RATE"
mdlname = 'INFLATION_SABR'
t1 = 'should-send-back-none'
class srtqualifier:
def __init__(self,mdlname,datatype, dataconvention,t1):
self.mdlname = mdlname
self.datatype = datatype
self.dataconvention = dataconvention
self.t1 = t1 ##TO BE REMOVED, ONLY USE FOR TESTING##
self.tempholder = self.dataconvention.split("-")
self.currency = self.tempholder[0]
def curr(self):
if self.mdlname == 'INFLATION_SABR':
inflationcurrency = {'UK':'GBP','FR':'EUR','EU':'EUR','US':'USD'}
self.currency = inflationcurrency.get(self.currency)
return self.currency
def spartSABR(self):
if self.dataconvention == 'JPY-SWAPTION-CLEAREDPHYSICAL-SEMI-ACT365F':
return 'LIBOR_JPY_6M'
elif self.dataconvention == 'USD-SIFMA Municipal Swap Index-1W-SWAPTION-PHYSICAL-SEMI-BOND':
secondpartsp = self.tempholder[1].split(" ")
secondpartsp.append(self.tempholder[2])
separator = "_"
secondpart = separator.join(secondpartsp[1:len(secondpartsp)])
secondpart = secondpart.upper()
return secondpart
elif self.mdlname == 'INFLATION_SABR':
secondpartsp = self.tempholder[0:2]
secondpartsp = secondpartsp.append([self.currency,'1Y'])
return secondpartsp
else:
secondpartsp = self.tempholder[1].split(" ")
secondpartsp.append(self.tempholder[2])
secondpartsp.insert(1,self.currency)
separator = "_"
secondpart = separator.join(secondpartsp)
secondpart = secondpart.upper()
return secondpart
test1 = srtqualifier(mdlname,datatype,dataconvention,t1)
print (test1.curr())
print (test1.spartSABR())