Ejemplo n.º 1
0
    def loadProductData(self, as_of_date, load_from_cache=False):
        if self.pg != None:
            self.pg.startSubProcess(self.pg.cur_sub_proc_total * .4, 2.0)

        cp = self.cache_path
        if not load_from_cache:
            f_def = open("def/product_def.dat")
            f_res = open("def/product_res.dat")

            if self.pg != None:
                self.pg.addMessage("Downloading Product Data")
                self.pg.incSub("running products report.....")

            product_rep = self.bsdm.runProductsReport(f_def.read(),
                                                      f_res.read(), as_of_date)
            product_bal = {}

            if self.pg != None:
                self.pg.incSub("finished products report.....")
                self.pg.startSubProcess(self.pg.cur_sub_proc_total * .6,
                                        len(product_rep))

            for p in product_rep:
                if self.pg != None:
                    self.pg.incSub("getting " + p[1][1] + " data")
                bal = self.bsdm.getProductBalances(int(p[0][1]), date.today(),
                                                   date.today())
                product_bal[int(p[0][1])] = float(bal[0][1])

            product_data = [product_rep, product_bal]

            shutil.rmtree(cp + "products/")
            os.mkdir(cp + "products/")

            rep_file = open(cp + "reports/product_rep.cache", 'w')
            cPickle.dump(product_data, rep_file)
            rep_file.close()
        else:
            rep_file = open(cp + "reports/product_rep.cache")
            product_data = cPickle.load(rep_file)
            product_bal = product_data[1]
            product_rep = product_data[0]
            rep_file.close()

        for p in product_rep:
            if int(p[0][1]) not in self.products.keys():
                tmp_product = Product()
                tmp_product.backstop_id = int(p[0][1])
                tmp_product.name = p[1][1]
                tmp_product.balance = product_bal[tmp_product.backstop_id]
                if tmp_product.balance > 0:
                    self.products[int(p[0][1])] = tmp_product
        self.loaded[1] = True
Ejemplo n.º 2
0
 def loadProductData(self,as_of_date,load_from_cache=False):
     if self.pg != None:
         self.pg.startSubProcess(self.pg.cur_sub_proc_total*.4,2.0)
     
     cp = self.cache_path
     if not load_from_cache:
         f_def = open("def/product_def.dat")
         f_res = open("def/product_res.dat")
         
         if self.pg != None:
             self.pg.addMessage("Downloading Product Data")
             self.pg.incSub("running products report.....")
             
         product_rep = self.bsdm.runProductsReport(f_def.read(),f_res.read(),as_of_date)
         product_bal = {}
         
         if self.pg != None:
             self.pg.incSub("finished products report.....")
             self.pg.startSubProcess(self.pg.cur_sub_proc_total*.6,len(product_rep))
         
         for p in product_rep:
             if self.pg != None:
                 self.pg.incSub("getting " + p[1][1] + " data")
             bal = self.bsdm.getProductBalances(int(p[0][1]),date.today(),date.today())
             product_bal[int(p[0][1])] = float(bal[0][1])
         
         product_data = [product_rep,product_bal]
         
         shutil.rmtree(cp + "products/")
         os.mkdir(cp + "products/")
     
         rep_file = open(cp + "reports/product_rep.cache",'w')
         cPickle.dump(product_data,rep_file)
         rep_file.close() 
     else:
         rep_file = open(cp + "reports/product_rep.cache")
         product_data = cPickle.load(rep_file)
         product_bal = product_data[1]
         product_rep = product_data[0]            
         rep_file.close()
     
     for p in product_rep:
         if int(p[0][1]) not in self.products.keys():
             tmp_product = Product()
             tmp_product.backstop_id = int(p[0][1])
             tmp_product.name = p[1][1]
             tmp_product.balance = product_bal[tmp_product.backstop_id]
             if tmp_product.balance > 0:
                 self.products[int(p[0][1])] = tmp_product
     self.loaded[1] = True
Ejemplo n.º 3
0
 def __init__(self):
     self.product = Product()
     self.product_id = 0
     self.fund = Fund()
     self.fund_id = 0
     self.type = ""
     self.date = ""
     self.amount = 0
Ejemplo n.º 4
0
 def loadProductData(self):
     cp = self.cache_path
     rep_file = open(cp + "reports/product_rep.cache")
     product_data = cPickle.load(rep_file)
     product_rep = product_data[0]
     product_bal = product_data[1]
     rep_file.close()
           
     for p in product_rep:
         if int(p[0][1]) not in self.products.keys():
             tmp_product = Product()
             tmp_product.backstop_id = int(p[0][1])
             tmp_product.name = p[1][1]
             tmp_product.balance = product_bal[tmp_product.backstop_id]
             if tmp_product.balance > 0:
                 self.products[int(p[0][1])] = tmp_product
     self.loaded[1] = True
Ejemplo n.º 5
0
 def __init__(self):
     self.product = Product()
     self.product_id = 0
     self.fund = Fund.Fund()
     self.fund_id = 0
     self.date = date.today()
     self.amount = 0
     self.type = ""
     self.percent = 0