Example #1
0
    def run_updater(self):
        app = application.Application.start('%s/bin/DataTools.exe' % self._tradeappdir)
        time.sleep(0.5)

        mainwin = app.window_(title_re="DataTools.*[0-9\.]+")        
        mainwin.Wait('ready')
        mainwin.MenuSelect('File->Update Data...')
        time.sleep(0.5)

        while True:
            try:
                updatewin = app.window_(title='Update Data')
                updatewin.Wait('ready')
                updatewin.Update.Click()
                break
            except:
                time.sleep(0.5)
        
        while True:
            try:
                text = updatewin['TRichEdit'].Texts()[0]
                if text.find('This Distribution Complete.') != -1:
                    time.sleep(1.0)
                    break
            except:
                time.sleep(0.5)

        while True:
            try:
                if len(app.windows_(title=u'Update Data')) == 0:
                    break
                else:                                     
                    updatewin.Exit.Click()
            except:
                time.sleep(0.5)

        while True:
            try:
                if not 'DataTools.exe' in get_process_list():
                    break
                else:                                     
                    mainwin.MenuSelect('File->Exit')
            except:
                time.sleep(0.5)
Example #2
0
    def run_exporter(self):
        app = application.Application.start('%s/Premium Data Converter.exe' % self._dataconvdir)
        time.sleep(0.5)
        mainwin = app.window_(title_re="Premium Data Converter.*[0-9\.]+")

        destfolder = self._datadir
        text = ''
        while text != destfolder:
            try:
                mainwin['Edit7'].SetEditText(destfolder)
                text = mainwin['Edit7'].TextBlock()
            except:
                tb = traceback.format_exc()
                print tb
                time.sleep(0.5)

        while True:
            try:
                mainwin.ConverttoText.Click()
                break
            except:
                time.sleep(0.5)

        while True:
            try:
                text = mainwin['WindowsForms10.RichEdit20W.app.0.378734a'].Texts()[0]
                if text.find('Finished.') != -1:
                    time.sleep(1.0)
                    break
            except:
                time.sleep(0.5)

        while True:
            try:
                if not 'Premium Data Converter.exe' in get_process_list():
                    break
                else:                                     
                    mainwin.Close()
            except:
                time.sleep(0.5)
Example #3
0
    def run_filter_update(self):
        filtbase = os.path.join(self._basedir,'filters')
        
        # update our trade filters long first
        filtlong = os.path.join(filtbase,'filt_long')
        
        # copy the new tssb_(long|short) files
        shutil.copy('tssb_long.csv', os.path.join(filtlong,'tssb_long.csv'))
 
        cwd = os.getcwd()       
        os.chdir(filtlong)
        
        # before we try to delete the db directory we need to make sure there
        # aren't any tssb processes running since they will likely have open
        # files in there
        while 'tssb64.exe' in get_process_list():
            print 'Warning...tssb64.exe process already running, attempting to kill'
            kill_tssb()
            time.sleep(1)
        
        # important to clear any previous db directory because TSSB doesn't
        # overwrite database files (and silently :()
        if os.path.exists('db'):
            shutil.rmtree('db')
        cmd = 'python %s/build_ind_dbs.py TREND_VOLATILITY3.txt db' % os.path.join(self._basedir,'tssb','bin')
        os.system(cmd)
        
        self.run_tssb_wrapper(os.path.join(filtlong,"preselect_test.txt"),'pselect_test_audit.log')
        longparse = AuditParser('pselect_test_audit.log')
        longdb = DbParser('FILTLONG.DAT')
        os.chdir(cwd)
            
        # then short...
        filtshort = os.path.join(filtbase,'filt_short')
        
        # copy the new tssb_(long|short) files
        shutil.copy('tssb_short.csv', os.path.join(filtshort,'tssb_short.csv'))
        
        cwd = os.getcwd()       
        os.chdir(filtshort)
        if os.path.exists('db'):
            shutil.rmtree('db')
        cmd = 'python %s/build_ind_dbs.py TREND_VOLATILITY3.txt db' % os.path.join(self._basedir,'tssb','bin')
        os.system(cmd)
        
        self.run_tssb_wrapper(os.path.join(filtshort,"preselect_test.txt"),'pselect_test_audit.log')
        shortparse = AuditParser('pselect_test_audit.log')
        shortdb = DbParser('FILTSHORT.DAT')
        os.chdir(cwd)

        for alert in self._alerts:
            # model values are hard-coded for the year based on the tradefilt run
            if alert.action == 'BUY':
                parse = longparse
                db = longdb
                model = 'COMM5'
            else:
                parse = shortparse
                db = shortdb
                model = 'COMM5'
            self.check_filter(alert, parse, db, model)