Python tushare 模块,get_tick_data() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用tushare.get_tick_data()

项目:Book_DeepLearning_Practice    作者:wac81    | 项目源码 | 文件源码
def get_am_pm_price(code, date):
    '''
    :param code: ????
    :param date: ??????
    :return: ??????????????10?,???2:30???
    '''
    if type(code) is not str or type(date) is not str:
        code = str(code)
        date = str(date)
    import tushare as ts
    df = ts.get_tick_data(code, date)
    dtime = df.set_index('time')
    price = dtime['price']
    if price.shape == (0,):
        print code, "can't get ", date, "am_pm data!"
        return float('nan'), float('nan')
    else:
        return price[-1], price[len(df.time)/4]
项目:QUANTAXIS    作者:yutiansut    | 项目源码 | 文件源码
def QA_fetch_get_stock_tick(name, date):
    if (len(name) != 6):
        name = str(name)[0:6]
    return QATs.get_tick_data(name, date)
项目:TuShare    作者:andyzsf    | 项目源码 | 文件源码
def nosql():
    import pymongo
    import json
    conn = pymongo.Connection('127.0.0.1', port=27017)
    df = ts.get_tick_data('600848',date='2014-12-22')
    print(df.to_json(orient='records'))

    conn.db.tickdata.insert(json.loads(df.to_json(orient='records')))

#     print conn.db.tickdata.find()
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def get_mount():
    df = ts.get_tick_data('300141', date='2016-07-25')
    df.plot()
    print df
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def getBigVol(code):
    #???????

    #today_vol=ts.get_today_ticks(code)
    #hist_vol=ts.get_tick_data(code,date='2016-11-28')
    #print today_vol.head(10)

    #print hist_vol

    hist_big_deal = ts.get_sina_dd(code, date='2016-12-01', vol=500)
    if hist_big_deal is None:
        print "No Big Deal"
    else:
        print hist_big_deal
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def sql_store():
    df = ts.get_tick_data('300333', date='2016-12-22')
    df.to_sql('tick_data', engine)
#empty_type()
#exception_test()
#get_basic()
#detail_tushare()

#empty_type()
#exception_test()
#get_basic()
#detail_tushare()
#get_all_stock_id()
#get_real_time()
#get_mount()
#for_test()
#get_each_mount()
#plot_test2()
#save_excel()

#get_real_time()
#gsz()
#new_api()
#filename="mystock.txt"
#getStockList(filename)
#getBigVol('300527')
#get_real_time()

#get_k_test()
#holiday()
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def get_tick(stockCode=None, date=None):
    """
    ???????????????/????????
    Return
    --------
    DataFrame
    """
    tick_data = ''
    if date != None and date != '':
        tick_data = ts.get_tick_data(stockCode, date)
    else:
        tick_data = ts.get_today_ticks(stockCode)
    if not tick_data.dropna(axis=0, how='any', thresh=None).empty:
        tick_data.insert(0, 'code', stockCode) #????????
    return tick_data
项目:python_data_tools    作者:king3366ster    | 项目源码 | 文件源码
def get_tick_data(self, code, t_date = None):
        if t_date is None:
            t_date = dataTime.datetimeRelative(delta = 0)
        t_date = t_date.replace(' 00:00:00', '')
        df = ts.get_tick_data(code, date = t_date)
        df = self.format_date_to_datetime(df, t_date = t_date)
        return df
项目:quant    作者:yutiansut    | 项目源码 | 文件源码
def QA_fetch_get_stock_tick(name, date):
    if (len(name) != 6):
        name = str(name)[0:6]
    return QATs.get_tick_data(name, date)
项目:tushare-data-sync    作者:HUMANAMUH    | 项目源码 | 文件源码
def fetch_tick(stock, date):
    with timer(logtime("ts.get_tick_data('%s', date='%s')" % (stock, date))):
        df = await wait_concurrent(event_loop, proc_pool, ts.get_tick_data, stock, date=date, pause=0.1)
    if df is None or (len(df) > 0 and "??????" in df['time'][0]):
        # no data found
        logging.debug("no tick data for stock: ts.get_tick_data('%s', date='%s')" % (stock, date))
        return
    # with timer(logtime("tick_data_proc")):
    df['stock'] = stock
    df['time'] = (date + ' ' + df['time']).map(lambda x: pd.Timestamp(datetime.strptime(x, time_fmt)).strftime(format="%Y-%m-%d %H:%M:%S%z"))
    return tick_buffer.proc_data(df)
项目:StockRecommendSystem    作者:doncat99    | 项目源码 | 文件源码
def updating_stock_tick_data(root_path, exception_df, symbol, date_list):
    file_path = root_path + "/Data/CSV/tick/" + symbol + "/"
    exception_file = root_path + "/Data/CSV/exception/" + symbol + ".csv"

    if os.path.exists(file_path) == False:
        os.mkdir(file_path)

    now_date = (datetime.datetime.now()).strftime("%Y-%m-%d")
    need_update_exception = False
    need_update_data = False
    #pbar = trange(len(date_list), leave=False)
    #for i in pbar: 

    temp_list = []

    for date in date_list:
        #start = time.time()
        #date = date_list[i]

        new_file_name = file_path + symbol + "_" + date + ".csv"
        if os.path.exists(new_file_name):
            continue
        try:
            temp_list.append(date)
            data = ts.get_tick_data(symbol ,date=date, src ='tt')
        except:
            print("stock:", symbol, " date:", date, "get data failed")

        if data is not None:
            need_update_data = True
            data.to_csv(new_file_name)
        else:
            need_update_exception = True
            exception_df.loc[len(exception_df)] = [date, 1, now_date]
            # print("tick data", symbol, date, "is None")

        #outMessage = '%s processed in: %.4s seconds' % (date, (time.time() - start))
        #pbar.set_description(outMessage)

    if need_update_exception:
        exception_df = exception_df.groupby(["date"]).agg({'retry':'sum', 'last_update':'max'}).reset_index()
        exception_df.to_csv(exception_file)

    if len(temp_list) > 0: print(symbol, temp_list)

    return need_update_data