Esempio n. 1
0
 def __init__(self,
              details        = None,
              dbobj          = None,
              inst           = None,
              code           = None,
              value_date     = None,
              calc_date      = None,
              append_to_code = '',
              **kwargs):
     self.holding       = details
     self.__pricer      = None
     self.__value_date  = value_date
     self.rateobj       = None
     self.calc_date     = dates.get_livedate(calc_date)
     self.mktprice      = self.notavailable
     self.jsonvals      = None
     self.histories     = {}
     if inst:
         self.__instrument = inst
     else:
         self.__instrument = dbobj.instrument()
     if code == None:
         code = str(self.dbinstrument.code)
     code = '%s%s' % (code, append_to_code)
     super(finins,self).__init__(dbobj = dbobj, code = code, **kwargs)
Esempio n. 2
0
    def get_or_create(self, dte, rjson, inthread=False):
        '''
        Create or return an element associated with date 'dte'
        dte      date
        rjson    boolean. If true a check on timestamp is performed
        '''
        dte = get_livedate(dte)
        dt = dte.dateonly

        if rjson:
            lm = self.lastmodified()
            if lm > self.timestamp:
                self.timestamp = now()
                self.ts = dateseries()

        # thread safe creation
        self.__lock.acquire()
        try:
            if self.has_key(dt):
                return self.ts[dt]
            else:
                res = self.create(dte)
                if res:
                    self.ts[dt] = res
                self.build(res, inthread)
                return res
        except Exception, e:
            self.err(e)
            return None
Esempio n. 3
0
 def get_or_create(self, dte, rjson, inthread = False):
     '''
     Create or return an element associated with date 'dte'
     dte      date
     rjson    boolean. If true a check on timestamp is performed
     '''
     dte = get_livedate(dte)
     dt  = dte.dateonly
     
     if rjson:
         lm  = self.lastmodified()
         if lm > self.timestamp:
             self.timestamp = now()
             self.ts        = dateseries()
     
     # thread safe creation
     self.__lock.acquire()
     try:
         if self.has_key(dt):
             return self.ts[dt]
         else:
             res = self.create(dte)
             if res:
                 self.ts[dt] = res
             self.build(res,inthread)
             return res
     except Exception, e:
         self.err(e)
         return None
Esempio n. 4
0
 def __init__(self, holder=None, dte=None):
     Rate.__init__(self, holder)
     lazyrate.__init__(self)
     self.__date = dates.get_livedate(dte)
Esempio n. 5
0
 def __init__(self, holder=None, dte=None, *args, **kwargs):
     Rate.__init__(self, holder)
     composite.__init__(self)
     self.__date = get_livedate(dte)
Esempio n. 6
0
 def get_livedate(self, dte):
     dte = dates.get_livedate(dte)
     if not self.livecalc and dte.live:
         return dates.get_livedate(dates.prevbizday())
     else:
         return dte
Esempio n. 7
0
File: rate.py Progetto: OspreyX/flow
 def __init__(self, holder = None, dte = None):
     Rate.__init__(self, holder)
     lazyrate.__init__(self)
     self.__date = dates.get_livedate(dte)
Esempio n. 8
0
 def __init__(self, holder = None, dte = None, *args, **kwargs):
     Rate.__init__(self,holder)
     composite.__init__(self)
     self.__date = get_livedate(dte)
Esempio n. 9
0
 def get_livedate(self, dte):
     dte = dates.get_livedate(dte)
     if not self.livecalc and dte.live:
         return dates.get_livedate(dates.prevbizday())
     else:
         return dte