Пример #1
0
def bundle(symbol, action, market, output, extension):
    '''
    批量下载行情数据
    :return:
    '''
    client = Quotes.factory(market=market)
    symbol = symbol.replace(',', ',').strip(',').split(',')

    for code in symbol:
        try:
            if action == 'daily':
                frequency = 9
            elif action == 'minute':
                frequency = 8
            elif action == 'fzline':
                frequency = 0
            else:
                frequency = 9

            feed = getattr(client, 'bars')(symbol=code, frequency=frequency)
            to_file(feed, os.path.join(output, '{}.{}'.format(
                code, extension))) if output else None
            print('下载完成 {}'.format(code))
        except Exception as e:
            raise e

    print('[√] 下载文件到 "{}"'.format(os.path.realpath(output)))
Пример #2
0
def getPriceTdx():
    client = Quotes.factory(market='std')
    price = client.index(frequency=9,
                         market=MARKET_SH,
                         symbol='000001',
                         start=1,
                         offset=2)
    to_json = price.to_json(orient="records", force_ascii=False)
    print(type(to_json))
    print(to_json)
Пример #3
0
def getPriceTdx():
    frequency = flask.request.values.get("frequency")
    symbol = flask.request.values.get("symbol")
    start = flask.request.values.get("start")
    offset = flask.request.values.get("offset")
    client = Quotes.factory(market='std')
    price = client.index(frequency=frequency,
                         market=MARKET_SH,
                         symbol=symbol,
                         start=start,
                         offset=offset)
    columns = price.columns
    print(type(columns))
    print(columns)
    to_json = price.to_json(orient="records", force_ascii=False)
    return to_json
Пример #4
0
def getCodeTdx():
    client = Quotes.factory(market='std')
    symbol = client.stocks(market=consts.MARKET_SH)

    print(type(symbol))
    print(symbol)
    print("================")
    columns = symbol.columns
    print(type(columns))
    print(columns)
    print("================")
    code = symbol["code"]
    print(type(code))
    print(code)
    print("================")
    to_json = symbol.to_json(orient="records", force_ascii=False)
    print(type(to_json))
    print(to_json)
def quotes(symbol, action, market, output):
    client = Quotes.factory(market=market, multithread=True, heartbeat=True)

    try:
        action = 'bars' if 'daily' else action
        if action == 'daily':
            frequency = 9
        elif action == 'minute':
            frequency = 8
        elif action == 'fzline':
            frequency = 0
        else:
            frequency = 9

        feed = getattr(client, 'bars')(symbol=symbol, frequency=frequency)
        to_file(feed, output) if output else None
        print(feed)
    except Exception as e:
        raise e
Пример #6
0
    def get_index_k_data(self,symbol, begin, end):
        """
        
        :param symbol: 
        :param begin: 
        :param end: 
        :return: 
        
        
        start = 0 为最新一天数据, offset 为若干条
        
        
        """
        # 确定市场
        if symbol.startswith('399'):
            market = MARKET_SZ
        else:
            market = MARKET_SH

        start, offset = self.good_day(begin,end)
        client = Quotes.factory(market='std')

        pulls, remainder = divmod(offset,800)

        my_data = []
        for each in range(pulls):
            data = client.index(frequency=9, market=market, symbol=symbol, start=start, offset=800)
            my_data.append(data)
            start += 800

        data = client.index(frequency=9, market=market, symbol=symbol, start=start, offset=remainder)
        my_data.append(data)
        my_data.reverse()
        my_data= pd.concat(my_data)

        return my_data
Пример #7
0
 def setUp(self):
     self.client = Quotes.factory(market='std', multithread=True, heartbeat=True) # 标准市场