예제 #1
0
파일: operator.py 프로젝트: cmbclh/vnpy1.7
    def updateStatus(self, status):
        sql = " SELECT * " \
                  " FROM aif_calculator_status " \
              " WHERE name = '%s'" % (self.__class__.__name__)
        calculator_status = caiiasdata.getDataBySQL('index', sql)

        if (status is self.STATUS_RUNNING) or (status is self.STATUS_FAILED):
            sql = " UPDATE aif_calculator_status " \
                     " SET status = '%d' " \
                  " WHERE name = '%s' "  %(status, self.__class__.__name__)
            caiiasdata.updateData('index', sql)
        else:
            calculator_status.finish_num[
                0] = calculator_status.finish_num[0] + 1
            if calculator_status.max_finish_num[
                    0] > calculator_status.finish_num[0]:
                sql = " UPDATE aif_calculator_status " \
                      " SET status = '%d', " \
                          " finish_num = %d"\
                      " WHERE name = '%s'" % (status, calculator_status.finish_num[0], self.__class__.__name__)
            else:
                next_day = days_after(
                    datetime.datetime.strptime(self.cal_end_date, '%Y%m%d'), 1)
                sql = " UPDATE aif_calculator_status " \
                      " SET status = '%d', " \
                          " finish_num = 0, "\
                          " trans_date = '%s' "\
                      " WHERE name = '%s'" % (status, next_day, self.__class__.__name__)
            caiiasdata.updateData('index', sql)
예제 #2
0
파일: operator.py 프로젝트: cmbclh/vnpy1.7
 def loadData(self):
     data = dict()
     for table in self.org_table_list:
         database, sql = self.org_table_list[table]
         info = caiiasdata.getDataBySQL(database, sql)
         data[table] = info
     return data
예제 #3
0
파일: operator.py 프로젝트: cmbclh/vnpy1.7
 def get_start_date(self):
     sql = "select max(date) max_date from %s " % (self.table_name)
     try:
         max_date = caiiasdata.getDataBySQL('index', sql)
         if max_date.empty or max_date['max_date'][0] is None:
             return self.DEFAULT_CAL_START_DATE
         else:
             return max_date['max_date'][0]
     except Exception as e:
         return self.DEFAULT_CAL_START_DATE
예제 #4
0
파일: operator.py 프로젝트: cmbclh/vnpy1.7
    def __init__(self):
        #默认执行的开始日期
        if self.cal_start_date in (None, '', '0'):
            self.cal_start_date = self.get_start_date()
            self.cal_start_date = days_after(
                datetime.datetime.strptime(self.cal_start_date, '%Y%m%d'),
                1)  # 当前数据库最大日期后一日

        #默认执行的截止日期
        if self.cal_end_date in (None, '', '0'):
            #self.cal_end_date = datetime.date.today().strftime("%Y%m%d")
            #self.cal_end_date = '20170804'
            sql = " SELECT * " \
                  " FROM aif_calculator_status " \
                  " WHERE name = '%s'" % (self.__class__.__name__)
            calculator_status = caiiasdata.getDataBySQL('index', sql)
            self.cal_end_date = calculator_status.trans_date[0]
예제 #5
0
파일: operator.py 프로젝트: cmbclh/vnpy1.7
 def __get_fund_start_date(self, code):
     sql_start_info = " SELECT F_INFO_SETUPDATE " \
                      " FROM wd_chinamutualfunddescription" \
                      " WHERE F_INFO_WINDCODE = '%s' " % (code)
     fund_info = caiiasdata.getDataBySQL('orig', sql_start_info)
     return fund_info['F_INFO_SETUPDATE'][0]