账户的起始交易日期(只在回测中使用)

        Raises:
            RuntimeWarning -- [description]

        Returns:
            [type] -- [description]
765531
def start_date(self):
        
        if self.start_==None:
            if len(self.time_index_max) > 0:
                return str(min(self.time_index_max))[0:10]
            else:
                print(
                    RuntimeWarning(
                        'QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE'
                    )
                )
        else:
            return self.start_
814819
def date(fmt=None,timestamp=None):
    ""
    if fmt=='U': # return timestamp
        t = datetime.datetime.now()
        return int(time.mktime(t.timetuple()))
    if fmt=='c': # return isoformat 
        d = datetime.datetime.fromtimestamp(timestamp)
        return d.isoformat()
    if fmt=='Ymd':
        d = datetime.datetime.now()
        return d.strftime("%Y%m%d")
228425
def timestamp(value):
    
    value = value if timezone.is_naive(value) else timezone.localtime(value)
    return value.strftime(settings.DATE_FORMAT)
222521
def _getFromTime(self, atDate=None):
        
        return getLocalTime(self.date, self.time_from, self.tz)
1174776
def listing(self):
        

        now = Environment.get_instance().calendar_dt
        return self.listed_date <= now <= self.de_listed_date
1147214
def parse_date(ims):
    
    try:
        ts = email.utils.parsedate_tz(ims)
        return time.mktime(ts[:8] + (0,)) - (ts[9] or 0) - time.timezone
    except (TypeError, ValueError, IndexError):
        return None
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
268749
def date(date):
    
    date = date.value
    return (datetime.strptime(date[:-5], '%Y-%m-%dT%H:%M:%S')
            if len(date) == 24
            else datetime.strptime(date, '%Y%m%dT%H:%M:%S'))
442184
def run(self):
        
        # 如果出现了日期的改变 才会进行结算的事件
        _date = None

        while QA_util_if_tradetime(self.now):
            for data in self.ingest_data:  # 对于在ingest_data中的数据
                # <class 'QUANTAXIS.QAData.QADataStruct.QA_DataStruct_Stock_day'>
                date = data.date[0]
                if self.market_type is MARKET_TYPE.STOCK_CN:  # 如果是股票市场
                    if _date != date:  # 如果新的date
                        # 前一天的交易日已经过去
                        # 往 broker 和 account 发送 settle 事件
                        try:
                            self.market.trade_engine.join()
                            # time.sleep(2)
                            self.market._settle(self.broker_name)

                        except Exception as e:
                            raise e
                # 基金 指数 期货
                elif self.market_type in [MARKET_TYPE.FUND_CN, MARKET_TYPE.INDEX_CN, MARKET_TYPE.FUTURE_CN]:
                    self.market._settle(self.broker_name)
                # print(data)
                self.broker.run(
                    QA_Event(event_type=ENGINE_EVENT.UPCOMING_DATA, market_data=data))
                # 生成 UPCOMING_DATA 事件放到 队列中去执行

                self.market.upcoming_data(self.broker_name, data)

                self.market.trade_engine.join()

                _date = date
439216
def get_current_time(self):
        
        current_time = c_double()
        self.library.get_current_time.argtypes = [POINTER(c_double)]
        self.library.get_current_time.restype = None
        self.library.get_current_time(byref(current_time))
        return current_time.value
1134285
def strftime(self, dtime, format):      # pylint: disable=redefined-builtin
        
        format = self.STRFTIME_FORMATS.get(format + "_FORMAT", format)
        if six.PY2 and isinstance(format, six.text_type):
            format = format.encode("utf8")
        timestring = dtime.strftime(format)
        if six.PY2:
            timestring = timestring.decode("utf8")
        return timestring
438927
def QA_util_future_to_realdatetime(trade_datetime):
    
    if len(str(trade_datetime)) == 19:
        dt = datetime.datetime.strptime(
            str(trade_datetime)[0:19],
            '%Y-%m-%d %H:%M:%S'
        )
        return dt if dt.time(
        ) < datetime.time(21,
                          0) else QA_util_get_last_datetime(dt,
                                                            1)
    elif len(str(trade_datetime)) == 16:
        dt = datetime.datetime.strptime(
            str(trade_datetime)[0:16],
            '%Y-%m-%d %H:%M'
        )
        return dt if dt.time(
        ) < datetime.time(21,
                          0) else QA_util_get_last_datetime(dt,
                                                            1)
1040835
def runtime(self):
        

        warnings.warn("admm.ADMM.runtime attribute has been replaced by "
                      "an upgraded timer class: please see the documentation "
                      "for admm.ADMM.solve method and util.Timer class",
                      PendingDeprecationWarning)
        return self.timer.elapsed('init') + self.timer.elapsed('solve')
371361
def GetDate(self):
    
    normalized_timestamp = self._GetNormalizedTimestamp()
    if normalized_timestamp is None:
      return None, None, None

    number_of_days, _, _, _ = self._GetTimeValues(normalized_timestamp)

    try:
      return self._GetDateValuesWithEpoch(
          number_of_days, self._EPOCH_NORMALIZED_TIME)

    except ValueError:
      return None, None, None
997864
def getCurrentStrDatetime():
    
    # Generating current time
    i = datetime.datetime.now()
    strTime = "%s-%s-%s_%sh%sm" % (i.year, i.month, i.day, i.hour, i.minute)
    return strTime
681080
def QA_util_get_next_trade_date(cursor_date, n=1):
    

    cursor_date = QA_util_format_date2str(cursor_date)
    if cursor_date in trade_date_sse:
        # 如果指定日期为交易日
        return QA_util_date_gap(cursor_date, n, "gt")
    real_pre_trade_date = QA_util_get_real_date(cursor_date)
    return QA_util_date_gap(real_pre_trade_date, n, "gt")
1202218
def GetDateRange(self):
    
    (minvalue, maxvalue, minorigin, maxorigin) = self.GetDateRangeWithOrigins()
    return (minvalue, maxvalue)