Exemple #1
0
 def __init__(self, tushare_pro: TuShareProData):
     dict_all_symbol = tushare_pro.stock_basic(
         exchange="SSE").set_index("ts_code").to_dict("index")
     dict_all_symbol.update(
         tushare_pro.stock_basic(
             exchange="SZSE").set_index("ts_code").to_dict("index"))
     self._dict_all_symbols: Dict[str, Dict] = dict_all_symbol
     """ symbol 的详细信息内容"""
Exemple #2
0
def upsert_chn_stock_info_in_yahoo():
    set_http_proxy()
    tushare = TuShareProData()
    df = tushare.stock_basic(exchange="SSE", cols=["ts_code", "name"])
    for idx, row in df.iterrows():
        symbol = row["ts_code"].replace("SH", "SS")  # YAHOO 上海股市的后缀是 SS
        logger.info(f"[{idx}] {symbol}({row['name']}) symbol data in yahoo")
        upsert_yahoo_financial_instrument_info(symbol, True)

    df = tushare.stock_basic(exchange="SZSE", cols=["ts_code", "name"])
    for idx, row in df.iterrows():
        symbol = row["ts_code"]  # 深圳股市的后缀是相同的
        logger.info(f"[{idx}] {symbol}({row['name']}) symbol data in yahoo")
        upsert_yahoo_financial_instrument_info(symbol, True)
Exemple #3
0
def upsert_chn_stock_name():
    tushare = TuShareProData()
    df = tushare.stock_basic(exchange="SSE", cols=["ts_code", "name"])
    for idx, row in df.iterrows():
        symbol = row["ts_code"].replace("SH", "SS")  # YAHOO 上海股市的后缀是 SS
        symbol_obj = FinancialInstrumentSymbol(symbol=symbol,
                                               full_name=row['name'])
        upsert_document(symbol_obj, False)

    df = tushare.stock_basic(exchange="SZSE", cols=["ts_code", "name"])
    for idx, row in df.iterrows():
        symbol = row["ts_code"]  # 深圳股市的后缀是相同的
        symbol_obj = FinancialInstrumentSymbol(symbol=symbol,
                                               full_name=row['name'])
        upsert_document(symbol_obj, False)
Exemple #4
0
def sync_equity_financial_statement(mkt_code: str = "SSE"):
    """上市公司的财务数据等"""
    os.environ["local_cache_expire_hours"] = "24"

    ts_wrapper = TuShareProData(use_l3_cache=False)
    df_stks = ts_wrapper.stock_basic(exchange=mkt_code, cols=["ts_code", "name"])
    req_freq_controller = TushareReqSleepController(ts_wrapper)

    for id_num, row in df_stks.iterrows():
        print(f"\rsync_equity_financial_statement {id_num} : {row['ts_code']} - {row['name']} , total reqs {ts_wrapper.query_orig_source_count} ", end="")
        symbol = row["ts_code"]
        req_freq_controller.begin_internal_check()
        ts_wrapper.income_by_enddate(symbol=symbol, to_single_period_val=True)
        ts_wrapper.balancesheet_by_enddate(symbol=symbol)
        ts_wrapper.cashflow_by_enddate(symbol=symbol, to_single_period_val=True)
        req_freq_controller.end_internal_check()