默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。
        :return:
775635
def exchangebill(self):
        
        # TODO 目前仅在 华泰子类 中实现
        start_date, end_date = helpers.get_30_date()
        return self.get_exchangebill(start_date, end_date)
1246054
def parse_repeating_time_interval_to_days(date_str):
    

    intervals = {
        'Y': 365,
        'M': 30,
        'W': 7,
        'D': 1,
        'H': 0,
        'S': 0
    }

    if date_str.find('R/P') != 0:  # Periodicity mal formada
        return 0

    date_str = date_str.strip('R/P')
    days = 0
    index = 0
    for interval in intervals:
        value_end = date_str.find(interval)
        if value_end < 0:
            continue
        try:
            days += int(float(date_str[index:value_end]) * intervals[interval])
        # Valor de accrualPeriodicity inválido, se toma como 0
        except ValueError:
            continue
        index = value_end

    # Si el número de días es menor lo redondeamos a 1
    return max(days, 1)
720082
def daysInYear(date):
    
    # map from Qt information
    if type(date).__name__ in ('QDate', 'QDateTime', 'QTime'):
        date = date.toPython()

    if type(date) != int:
        year = date.year
    else:
        year = date

    if not year % 4:
        return 366
    return 365
252294
def previous_day(self):
        """"""
        return HDate(self.gdate + datetime.timedelta(-1), self.diaspora,
                     self.hebrew)
794381
def daily(self, symbol=None):
        '''
        
        '''
        reader = TdxExHqDailyBarReader()
        symbol = self.find_path(symbol)

        if symbol is not None:
            return reader.get_df(symbol)

        return None
1317327
def QA_SU_save_future_day(client=DATABASE, ui_log=None, ui_progress=None):
    '''
     
    '''
    future_list = [
        item for item in QA_fetch_get_future_list().code.unique().tolist()
        if str(item)[-2:] in ['L8',
                              'L9']
    ]
    coll_future_day = client.future_day
    coll_future_day.create_index(
        [("code",
          pymongo.ASCENDING),
         ("date_stamp",
          pymongo.ASCENDING)]
    )
    err = []

    def __saving_work(code, coll_future_day):
        try:
            QA_util_log_info(
                '##JOB12 Now Saving Future_DAY==== {}'.format(str(code)),
                ui_log
            )

            # 首选查找数据库 是否 有 这个代码的数据
            ref = coll_future_day.find({'code': str(code)[0:4]})
            end_date = str(now_time())[0:10]

            # 当前数据库已经包含了这个代码的数据， 继续增量更新
            # 加入这个判断的原因是因为如果股票是刚上市的 数据库会没有数据 所以会有负索引问题出现
            if ref.count() > 0:

                # 接着上次获取的日期继续更新
                start_date = ref[ref.count() - 1]['date']

                QA_util_log_info(
                    'UPDATE_Future_DAY \n Trying updating {} from {} to {}'
                        .format(code,
                                start_date,
                                end_date),
                    ui_log
                )
                if start_date != end_date:
                    coll_future_day.insert_many(
                        QA_util_to_json_from_pandas(
                            QA_fetch_get_future_day(
                                str(code),
                                QA_util_get_next_day(start_date),
                                end_date
                            )
                        )
                    )

            # 当前数据库中没有这个代码的股票数据， 从1990-01-01 开始下载所有的数据
            else:
                start_date = '2001-01-01'
                QA_util_log_info(
                    'UPDATE_Future_DAY \n Trying updating {} from {} to {}'
                        .format(code,
                                start_date,
                                end_date),
                    ui_log
                )
                if start_date != end_date:
                    coll_future_day.insert_many(
                        QA_util_to_json_from_pandas(
                            QA_fetch_get_future_day(
                                str(code),
                                start_date,
                                end_date
                            )
                        )
                    )
        except Exception as error0:
            print(error0)
            err.append(str(code))

    for item in range(len(future_list)):
        QA_util_log_info('The {} of Total {}'.format(item, len(future_list)))

        strProgressToLog = 'DOWNLOAD PROGRESS {} {}'.format(
            str(float(item / len(future_list) * 100))[0:4] + '%',
            ui_log
        )
        intProgressToLog = int(float(item / len(future_list) * 100))
        QA_util_log_info(
            strProgressToLog,
            ui_log=ui_log,
            ui_progress=ui_progress,
            ui_progress_int_value=intProgressToLog
        )

        __saving_work(future_list[item], coll_future_day)

    if len(err) < 1:
        QA_util_log_info('SUCCESS save future day ^_^', ui_log)
    else:
        QA_util_log_info(' ERROR CODE \n ', ui_log)
        QA_util_log_info(err, ui_log)
75971
def daily(date=nil)
      date = DateTime.parse(date) if date.is_a?(String)
      if date.respond_to?(:yday)
        response = self.class.get("/daily/#{date.yday}/#{date.year}")
      else
        response = self.class.get('/daily')
      end
      response
    end
34399
def crawl(self, *args, **kwargs):
        '''
        
        '''
        temp = tempfile.NamedTemporaryFile(mode='w+t')

        try:
            crawler = CrawlerScript()
            # 调试时可指定明确日期参数，如：date='20180423'
            crawler.crawl(output_file=temp.name, *args, **kwargs)

            temp.seek(0)
            content = json.loads(temp.read(), encoding='UTF-8')
        finally:
            temp.close()

        print('抓取完毕！')
        return content
1147367
def timestamp_after_timestamp(self, timestamp=None, seconds=0, minutes=0, hours=0, days=0):
        
        #1. 默认时间戳为当前时间
        timestamp = self.get_current_timestamp() if timestamp is None else timestamp
        #2. 先转换为datetime
        d1 = datetime.datetime.fromtimestamp(timestamp)
        #3. 根据相关时间得到datetime对象并相加给定时间戳的时间
        d2 = d1 + datetime.timedelta(seconds=int(seconds), minutes=int(minutes), hours=int(hours), days=int(days))
        #4. 返回某时间后的时间戳
        return int(time.mktime(d2.timetuple()))
289769
def day_of_year(self):
        
        k = 1 if self.is_leap_year() else 2

        return (275 * self.month) // 9 - k * ((self.month + 9) // 12) + self.day - 30
1115312
def _getLocalWhen(self, date_from, num_days=1):
        
        dateFrom, timeFrom = getLocalDateAndTime(date_from, self.time_from,
                                                 self.tz, dt.time.min)
        if num_days > 1 or self.time_to is not None:
            daysDelta = dt.timedelta(days=self.num_days - 1)
            dateTo, timeTo = getLocalDateAndTime(date_from + daysDelta,
                                                 self.time_to, self.tz)
        else:
            dateTo = dateFrom
            timeTo = None

        if dateFrom == dateTo:
            retval = _("{date} {atTime}").format(
                    date=dateFormat(dateFrom),
                    atTime=timeFormat(timeFrom, timeTo, gettext("at ")))
        else:
            # Friday the 10th of April for 3 days at 1pm to 10am
            localNumDays = (dateTo - dateFrom).days + 1
            retval = _("{date} for {n} days {startTime}").format(
                    date=dateFormat(dateFrom),
                    n=localNumDays,
                    startTime=timeFormat(timeFrom, prefix=gettext("starting at ")))
            retval = _("{dateAndStartTime} {finishTime}").format(
                    dateAndStartTime=retval.strip(),
                    finishTime=timeFormat(timeTo, prefix=gettext("finishing at ")))
        return retval.strip()
1356205
def inc_date(date_obj, num, date_fmt):
    
    return (date_obj + timedelta(days=num)).strftime(date_fmt)
1283013
def nextday(self):
        ''' 
        '''
        nextday = self.__zero.date() + timedelta(days=1)
        return datetime.combine(nextday, time())
20065
def daily_table(context, day, start=8, end=20, increment=30):
    
    user = context['request'].user
    addable = CHECK_EVENT_PERM_FUNC(None, user)
    if 'calendar' in context:
        addable = addable and CHECK_CALENDAR_PERM_FUNC(context['calendar'], user)
    context['addable'] = addable
    day_part = day.get_time_slot(day.start + datetime.timedelta(hours=start), day.start + datetime.timedelta(hours=end))
    # get slots to display on the left
    slots = _cook_slots(day_part, increment)
    context['slots'] = slots
    return context
560884
def warp(self, order):
        

        # 因为成交模式对时间的封装

        if order.order_model == ORDER_MODEL.MARKET:

            if order.frequence is FREQUENCE.DAY:
                # exact_time = str(datetime.datetime.strptime(
                #     str(order.datetime), '%Y-%m-%d %H-%M-%S') + datetime.timedelta(day=1))

                order.date = order.datetime[0:10]
                order.datetime = '{} 09:30:00'.format(order.date)
            elif order.frequence in [FREQUENCE.ONE_MIN,
                                     FREQUENCE.FIVE_MIN,
                                     FREQUENCE.FIFTEEN_MIN,
                                     FREQUENCE.THIRTY_MIN,
                                     FREQUENCE.SIXTY_MIN]:
                exact_time = str(
                    datetime.datetime
                    .strptime(str(order.datetime),
                              '%Y-%m-%d %H:%M:%S') +
                    datetime.timedelta(minutes=1)
                )
                order.date = exact_time[0:10]
                order.datetime = exact_time
            self.market_data = self.get_market(order)
            if self.market_data is None:
                return order
            order.price = (
                float(self.market_data["high"]) +
                float(self.market_data["low"])
            ) * 0.5
        elif order.order_model == ORDER_MODEL.NEXT_OPEN:
            try:
                exact_time = str(
                    datetime.datetime
                    .strptime(str(order.datetime),
                              '%Y-%m-%d %H-%M-%S') + datetime.timedelta(day=1)
                )
                order.date = exact_time[0:10]
                order.datetime = '{} 09:30:00'.format(order.date)
            except:
                order.datetime = '{} 15:00:00'.format(order.date)
            self.market_data = self.get_market(order)
            if self.market_data is None:
                return order
            order.price = float(self.market_data["close"])
        elif order.order_model == ORDER_MODEL.CLOSE:

            try:
                order.datetime = self.market_data.datetime
            except:
                if len(str(order.datetime)) == 19:
                    pass
                else:
                    order.datetime = '{} 15:00:00'.format(order.date)
            self.market_data = self.get_market(order)
            if self.market_data is None:
                return order
            order.price = float(self.market_data["close"])

        elif order.order_model == ORDER_MODEL.STRICT:
            '加入严格模式'
            if order.frequence is FREQUENCE.DAY:
                exact_time = str(
                    datetime.datetime
                    .strptime(order.datetime,
                              '%Y-%m-%d %H-%M-%S') + datetime.timedelta(day=1)
                )

                order.date = exact_time[0:10]
                order.datetime = '{} 09:30:00'.format(order.date)
            elif order.frequence in [FREQUENCE.ONE_MIN,
                                     FREQUENCE.FIVE_MIN,
                                     FREQUENCE.FIFTEEN_MIN,
                                     FREQUENCE.THIRTY_MIN,
                                     FREQUENCE.SIXTY_MIN]:
                exact_time = str(
                    datetime.datetime
                    .strptime(order.datetime,
                              '%Y-%m-%d %H-%M-%S') +
                    datetime.timedelta(minute=1)
                )
                order.date = exact_time[0:10]
                order.datetime = exact_time
            self.market_data = self.get_market(order)
            if self.market_data is None:
                return order
            if order.towards == 1:
                order.price = float(self.market_data["high"])
            else:
                order.price = float(self.market_data["low"])

        return order
298138
def today(self):
        
        if self._today is None:
            self._today = TodayList(self._version, account_sid=self._solution['account_sid'], )
        return self._today
985679
def loaddate(self):
    ''' 
    '''
    ld = csv.reader(open('./%s/opendate.csv' % _CSVFILEPATH, 'r'))
    re = {}
    re['close'] = []
    re['open'] = []

    for i in ld:
      ''' 0 = 休市, 1 = 開市 '''
      if i[1] == '0':
        re['close'] += [datetime.strptime(i[0],'%Y/%m/%d').date()]
      elif i[1] == '1':
        re['open'] += [datetime.strptime(i[0],'%Y/%m/%d').date()]
      else:
        pass
    return re