示例#1
0
    def format_yh(self, information):
        super(Entrust, self).format_yh(information)
        if self.status == 'error':
            return 'error'

        if '委托序号' in information:
            self.entrust_no = information['委托序号']
            self.entrust_status = information['状态说明']
            self.stock_name = information['证券名称']
            self.stock_code = information['证券代码']
            self.entrust_price = information['委托价格']
            self.entrust_amount = information['委托数量']
            self.business_amount = information['成交数量']
            if information['买卖标志'] == '买入':
                self.iotype = 'buy'
            elif information['买卖标志'] == '卖出':
                self.iotype = 'sell'
            self.time = date_time.str_to_date(information['委托时间'], '%H:%M:%S')
        else:
            self.entrust_no = information['entrust_num']
            self.entrust_status = information['status']
            self.stock_name = information['name']
            self.stock_code = information['code']
            self.entrust_price = information['price']
            self.entrust_amount = information['volume']
            self.business_amount = information['trans_vol']
            if information['iotype'] == '买入':
                self.iotype = 'buy'
            elif information['iotype'] == '卖出':
                self.iotype = 'sell'
            self.time = date_time.str_to_date(information['time'], '%H:%M:%S')

        return True
示例#2
0
    def format_yh(self, information):
        super(Entrust, self).format_yh(information)
        if self.status == 'error':
            return 'error'

        if information.has_key(u'委托序号'):
            self.entrust_no = information[u'委托序号']
            self.entrust_status = information[u'状态说明']
            self.stock_name = information[u'证券名称']
            self.stock_code = information[u'证券代码']
            self.entrust_price = information[u'委托价格']
            self.entrust_amount = information[u'委托数量']
            self.business_amount = information[u'成交数量']
            self.time = date_time.str_to_date(information[u'委托时间'], '%H:%M:%S')
        else:
            self.entrust_no = information[u'entrust_num']
            self.entrust_status = information[u'status']
            self.stock_name = information[u'name']
            self.stock_code = information[u'code']
            self.entrust_price = information[u'price']
            self.entrust_amount = information[u'volume']
            self.business_amount = information[u'trans_vol']
            self.time = date_time.str_to_date(information[u'time'], '%H:%M:%S')

        return True
示例#3
0
    def get_tick_data(self, code, trade_date, expire=60 * 24 * 365 * 10):
        """
        获取一支股票一天的tick数据保存到本地
        """
        UT.check_dir(CT.TICK_DIR + code)
        file_path = CT.TICK_DIR + code + '/' + trade_date
        symbol = self._code_to_symbol(code)
        trade_date = date_time.date_to_str(date_time.str_to_date(trade_date),
                                           '%Y%m%d')
        expired = UT.check_file_expired(file_path, expire)
        if expired or not os.path.exists(file_path):
            d = ak.stock_zh_a_tick_tx(symbol, trade_date)
            #过掉当天没数据的
            if d is None or len(d) < 10:
                return None
            d.to_csv(file_path, sep='\t')

        if not os.path.exists(file_path):
            return None

        #d = pd.read_csv(file_path, sep='\t', index_col=1)
        d = pd.read_csv(file_path,
                        sep='\t',
                        skiprows=0,
                        parse_dates=True,
                        header=0,
                        index_col=0)

        #过掉当天没数据的
        if d is None or len(d) < 10:
            return None
        return d
示例#4
0
 def _gen_tick_data_url(self, code, date):
     """
     生成历史tick数据获取链接
     http://quotes.money.163.com/cjmx/2016/20160520/0600000.xls
     """
     date = date_time.str_to_date(date)
     y = date_time.date_to_str(date, '%Y')
     d = date_time.date_to_str(date, '%Y%m%d')
     symbol = ne_symbol_of(code)
     if '' == symbol:
         return ''
     return self.tick_data_api % (y, d, symbol)
示例#5
0
    def format_yh(self, information):
        super(Deal, self).format_yh(information)
        if self.status == CT.BROKER_NAME_YINHE:
            return False

        # 当天的成交有 委托序号
        if '委托序号' in information:
            self.entrust_no = information['委托序号']
        self.stock_name = information['证券名称']
        self.stock_code = information['证券代码']
        self.business_price = information['成交价格']
        self.business_amount = information['成交数量']
        self.time = date_time.str_to_date(information['成交日期'] + information['成交时间'], '%Y%m%d%H:%M:%S')

        return True
示例#6
0
    def format_xq(self, information):
        super(Entrust, self).format_yh(information)
        if self.status == Status.STATUS_ERR:
            return False

        self.entrust_no = information['entrust_no']
        self.entrust_status = information['entrust_status']
        self.stock_name = information['stock_name']
        self.stock_code = symbol.code_from_symbol(information['stock_code'])
        self.entrust_price = information['entrust_price']
        self.entrust_amount = information['entrust_amount']
        self.business_amount = information['business_amount']
        self.time = date_time.str_to_date(information['report_time'], '%Y-%m-%d %H:%M:%S')

        return True
示例#7
0
def get_symbol_tick_data_since(symbol, date):
    """
    获取一支股票从指定日期至今所有的tick数据
    --------
    symbol: string,000001
    date: string,1900-01-01
    """
    since = date_time.str_to_date(date)
    today = datetime.datetime.today()
    days = (today - since).days
    t = TushareQuotation()
    for delta in range(0, days + 1):
        day = date_time.compute_date(since, delta)
        t.get_tick_data(symbol, day)

    return True
示例#8
0
    def format_yh(self, information):
        super(Deal, self).format_yh(information)
        if self.status == 'error':
            return 'error'

        #当天的成交有 委托序号
        if information.has_key(u'委托序号'):
            self.entrust_no = information[u'委托序号']
        self.stock_name = information[u'证券名称']
        self.stock_code = information[u'证券代码']
        self.business_price = information[u'成交价格']
        self.business_amount = information[u'成交数量']
        self.time = date_time.str_to_date(
            information[u'成交日期'] + information[u'成交时间'], '%Y%m%d%H:%M:%S')

        return True