| | |
| | | |
| | | # 获取交易所的代码 |
| | | @classmethod |
| | | def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True): |
| | | def get_exchanges_codes(cls, exchanges, skip_suspended=True, skip_st=True, fields=None): |
| | | if constant.JUEJIN_LOCAL_API: |
| | | account_id, s_id, token = cls.getJueJinAccountInfo() |
| | | gmapi.set_token(token) |
| | |
| | | skip_st=skip_st, |
| | | fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level,is_suspended,pre_close") |
| | | else: |
| | | if not fields: |
| | | fields = "symbol,sec_type,sec_id,sec_name,listed_date,sec_level," "is_suspended,pre_close" |
| | | return JueJinHttpApi.get_exchanges_codes(exchanges=exchanges, sec_types=[1], skip_suspended=skip_suspended, |
| | | skip_st=skip_st, |
| | | fields="symbol,sec_type,sec_id,sec_name,listed_date,sec_level," |
| | | "is_suspended,pre_close") |
| | | fields=fields) |
| | | |
| | | @classmethod |
| | | def get_history_instruments(cls, symbols, start_date, end_date, fields=None): |
| | |
| | | return JueJinApi.get_gp_latest_info(codes, fields) |
| | | |
| | | @classmethod |
| | | def get_history_tick_n(cls, code, count, fields=None): |
| | | def get_history_tick_n(cls, code, count, fields=None, juejin=False): |
| | | # return JueJinApi.get_history_tick_n(code, count, fields) |
| | | if constant.is_windows(): |
| | | if constant.is_windows() or juejin: |
| | | return JueJinApi.get_history_tick_n(code, count, fields) |
| | | else: |
| | | try: |
| | |
| | | if constant.is_windows(): |
| | | return JueJinApi.get_previous_trading_date(date) |
| | | else: |
| | | return hx_qc_value_util.get_previous_trading_date(date) |
| | | try: |
| | | return hx_qc_value_util.get_previous_trading_date(date) |
| | | except: |
| | | return JueJinApi.get_previous_trading_date(date) |
| | | |
| | | @classmethod |
| | | def get_previous_trading_date_cache(cls, date): |
| | |
| | | results[code] = code_name |
| | | return results |
| | | |
| | | @classmethod |
| | | def get_st_codes(cls): |
| | | """ |
| | | 获取st代码 |
| | | @return: |
| | | """ |
| | | results = JueJinApi.get_exchanges_codes("SHSE,SZSE", skip_st=False, fields="sec_id,sec_level") |
| | | codes = [x["sec_id"] for x in results if x["sec_level"] != 1] |
| | | return codes |
| | | |
| | | |
| | | def get_k_bar_dead_date(): |
| | | """ |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(HistoryKDatasUtils.get_previous_trading_date("2024-12-31")) |
| | | print(HistoryKDatasUtils.get_history_tick_n("000095", 10)) |
| | | |
| | | # now_day = tool.get_now_date_str() |
| | | # results = JueJinApi.get_history_instruments(JueJinApi.get_juejin_code_list_with_prefix(["600265"]), |
| | | # tool.date_sub(now_day, 30), tool.date_sub(now_day, 1)) |
| | | # results = results[-5:] |
| | | # normal = True |
| | | # for r in results: |
| | | # if r["sec_level"] != 1: |
| | | # normal = False |
| | | # break |
| | | # print(normal) |
| | | pass |