Beispiel #1
0
def test2():
    ts_pro = ls.get_ts_pro()
    print(ts_pro)

    df = ts_pro.index_basic(market='SZSE')

    print(df)
Beispiel #2
0
def update_db_stock_basic(list_status):
    pro = ls.get_ts_pro()
    print(pro)
    data = pro.stock_basic(
        exchange_id='',
        list_status=list_status,
        fields='ts_code,symbol,name,area,industry,fullname,enname,'
        'market,exchange_id,curr_type,list_status,list_date,delist_date,is_hs')
    if data.shape[0] > 0:
        for row in data.iterrows():
            ts_code, symbol, name, area, industry, fullname, enname, market, exchange_id, curr_type, list_status, list_date, delist_date, is_hs = \
                row[-1]
            stock_basic = StockBasic(ts_code=ts_code,
                                     symbol=symbol,
                                     name=name,
                                     area=area,
                                     industry=industry,
                                     fullname=fullname,
                                     enname=enname,
                                     market=market,
                                     exchange_id=exchange_id,
                                     curr_type=curr_type,
                                     list_status=list_status,
                                     list_date=list_date,
                                     delist_date=delist_date,
                                     is_hs=is_hs)
            stock_basic.save()
Beispiel #3
0
def stock_dividend_save(ts_code):
    print("stock_dividend_save :%s" % ts_code)
    ts_pro = ls.get_ts_pro()
    print(ts_pro)
    if ts_code is None:
        raise Exception
    df = ts_pro.dividend(ts_code=ts_code)
    df.to_csv(__path_dividend__ + ts_code + __csv__)
    return df
Beispiel #4
0
def stock_daily_save(ts_code):
    ts_pro = ls.get_ts_pro()
    print(ts_pro)

    df1 = ts_pro.daily(ts_code=ts_code,
                       start_date='19900101',
                       end_date='19941231')
    df1['date'] = pd.to_datetime(df1['trade_date'])
    df1.set_index("date", inplace=True)

    df2 = ts_pro.daily(ts_code=ts_code,
                       start_date='19950101',
                       end_date='19991231')
    df2['date'] = pd.to_datetime(df2['trade_date'])
    df2.set_index("date", inplace=True)

    df3 = ts_pro.daily(ts_code=ts_code,
                       start_date='20000101',
                       end_date='20041231')
    df3['date'] = pd.to_datetime(df3['trade_date'])
    df3.set_index("date", inplace=True)

    df4 = ts_pro.daily(ts_code=ts_code,
                       start_date='20050101',
                       end_date='20091231')
    df4['date'] = pd.to_datetime(df4['trade_date'])
    df4.set_index("date", inplace=True)

    df5 = ts_pro.daily(ts_code=ts_code,
                       start_date='20100101',
                       end_date='20141231')
    df5['date'] = pd.to_datetime(df5['trade_date'])
    df5.set_index("date", inplace=True)

    df6 = ts_pro.daily(ts_code=ts_code,
                       start_date='20150101',
                       end_date='20191231')
    df6['date'] = pd.to_datetime(df6['trade_date'])
    df6.set_index("date", inplace=True)

    # df11 = pd.DataFrame(df1)
    # df22 = pd.DataFrame(df2)
    # df = pd.concat(df11, df22)
    """

    df1['date'] = pd.to_datetime(df1['trade_date'])
    df1.set_index("date", inplace=True)

    df2['date'] = pd.to_datetime(df2['trade_date'])
    df2.set_index("date", inplace=True)
    """
    df = pd.concat([df1, df2, df3, df4, df5, df6])
    df = df.sort_index()
    df.to_csv(__path_daily__ + ts_code + __csv__)
    return df
Beispiel #5
0
def stock_basic_save(path):
    file_path = __path__ if path is None else path
    ts_pro = ls.get_ts_pro()
    print(ts_pro)
    df = ts_pro.stock_basic(
        list_status='L',
        fields=
        'ts_code,symbol,name,fullname,enname,exchange_id,curr_type,list_date,is_hs'
    )
    df.to_csv(__path__ + "stock_basic.csv")
    return df
Beispiel #6
0
def test1():
    ts_pro = ls.get_ts_pro()
    print(ts_pro)

    df1 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='19900101',
                       end_date='19941231')
    df2 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='19950101',
                       end_date='19991231')
    df3 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='20000101',
                       end_date='20041231')
    df4 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='20050101',
                       end_date='20091231')
    df5 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='20100101',
                       end_date='20141231')
    df6 = ts_pro.daily(ts_code='000001.SZ',
                       start_date='20150101',
                       end_date='20191231')

    # df11 = pd.DataFrame(df1)
    # df22 = pd.DataFrame(df2)
    # df = pd.concat(df11, df22)
    """

    df1['date'] = pd.to_datetime(df1['trade_date'])
    df1.set_index("date", inplace=True)

    df2['date'] = pd.to_datetime(df2['trade_date'])
    df2.set_index("date", inplace=True)
    """
    df = pd.concat([df1, df2, df3, df4, df5, df6])
    print(df.dtypes)
    print(df.head())
    print(df.tail())
Beispiel #7
0
def test3():
    ts_pro = ls.get_ts_pro()

    df = ts.get_realtime_quotes('601318')
    print(df)
Beispiel #8
0
"""
挖地兔微信号
https://mp.weixin.qq.com/s/P4Suh-JnBsI9cA43GuftuQ
"""
import os
import sys

sys.path.insert(0, '/Users/momantang/PycharmProjects/cobrass/')
sys.path

import tushare as ts
import tushare.futures
import pandas as pd
from local import local_setting as ls

pro = ls.get_ts_pro()

df = pro.stock_basic(exchange_id='',
                     list_status='L',
                     fields='ts_code,name,area,industry,list_date,market')
data = pd.crosstab(df.area, df.market)
print(data)