Example #1
0
def indexed_price(base, target, basePrice, **kw):
    baseMonth = Month.parse(str(base))
    targetMonth = Month.parse(str(target))
    for i in SANTE:
        if i.start <= baseMonth:
            return FixedPoint(basePrice * i.coeff(baseMonth, targetMonth),
                              **kw)
Example #2
0
def indexed_price(base,target,basePrice,**kw):
    baseMonth=Month.parse(str(base))
    targetMonth=Month.parse(str(target))
    for i in SANTE:
        if i.start <= baseMonth:
            return FixedPoint(
                basePrice * i.coeff(baseMonth,targetMonth),**kw)
Example #3
0
        self.values = values

    def coeff(self, baseMonth, newMonth):
        assert baseMonth >= self.start
        baseIndex = self.values[baseMonth - self.start]
        try:
            newIndex = self.values[newMonth - self.start]
        except IndexError, e:
            print newMonth, "-", self.start, "=", newMonth - self.start
            raise
        #print self.start,baseIndex, newIndex
        return newIndex / baseIndex


sante1988 = Index(
    Month.parse('198212'),
    (
        # 1982:
        82.53,
        # 1983:
        83.54,
        84.00,
        84.31,
        84.57,
        85.02,
        85.57,
        86.39,
        87.21,
        87.82,
        87.83,
        88.28,
Example #4
0
 def parse(self, s):
     assert len(s), ERR_PARSE_EMPTY
     return Month.parse(s)
Example #5
0
 def parse(self,s):
     assert len(s), ERR_PARSE_EMPTY
     return Month.parse(s)
Example #6
0
        self.start = start
        self.values=values

    def coeff(self,baseMonth,newMonth):
        assert baseMonth >= self.start
        baseIndex=self.values[baseMonth-self.start]
        try:
            newIndex=self.values[newMonth-self.start]
        except IndexError,e:
            print newMonth, "-", self.start, "=", newMonth-self.start
            raise
        #print self.start,baseIndex, newIndex
        return newIndex / baseIndex
        

sante1988 = Index(Month.parse('198212'), (
# 1982:    
82.53, 
# 1983:
83.54, 84.00, 84.31, 84.57, 85.02, 85.57,
86.39, 87.21, 87.82, 87.83, 88.28, 88.44, 
# 1984:
89.27, 89.94, 90.32, 90.91, 91.11, 91.37,
91.86, 92.22, 92.50, 92.92, 92.96, 93.17,

# 1985:
93.77, 94.74, 95.50, 95.87, 95.97, 95.99,
96.51, 96.51, 96.71, 96.66, 96.89, 96.92,

# 1986:
97.03, 97.11, 96.96, 97.26, 97.04, 97.17,