| | |
| | | try: |
| | | fdata = {} |
| | | try: |
| | | date = HistoryKDatasUtils.get_previous_trading_date(tool.get_now_date_str()) |
| | | date = HistoryKDatasUtils.get_trading_dates(tool.date_sub(tool.get_now_date_str(), 10) ,tool.get_now_date_str()) |
| | | if date: |
| | | fdata["juejin"] = 1 |
| | | except Exception as e: |
| | |
| | | # 获取今日K线的更新数量 |
| | | try: |
| | | dates = HistoryKDatasUtils.get_latest_trading_date_cache(5) |
| | | logger_debug.info(f"获取到的交易日:{dates}") |
| | | latest_trading_date = None |
| | | if dates: |
| | | latest_trading_date = dates[0] |
| | |
| | | raise Exception("没有获取到上一个交易日的日期") |
| | | codes = HistoryKDataManager().get_history_bars_codes(latest_trading_date) |
| | | count = len(codes) |
| | | logger_debug.info(f"K线代码数量:{count}") |
| | | fdata["today_history_k_bar_count"] = count |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | |
| | | import threading |
| | | import time |
| | | |
| | | import constant |
| | | import qcvalueaddproapi |
| | | from log_module.log import logger_system, logger_debug |
| | | from log_module.log import logger_system |
| | | from utils import tool |
| | | |
| | | global g_userid, g_passwd, g_address, g_port, g_seqnum |
| | |
| | | while True: |
| | | try: |
| | | val = request_queue.get() |
| | | logger_debug.info(f"读取华鑫增值服务请求:{val}") |
| | | type_ = val['type'] |
| | | request_id = val['request_id'] |
| | | data = val.get('data') |
| | |
| | | results = thespi.queryBars(code, start_date, end_date) |
| | | __set_response_data(request_id, results) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | pass |
| | | |
| | | |
| | | def run(request_queue: multiprocessing.Queue, response_queue: multiprocessing.Queue): |
| | |
| | | g_port = 25556 |
| | | g_userid = "388000013942" |
| | | g_passwd = "110808" |
| | | |
| | | # 内网 |
| | | g_address = "192.168.84.61" |
| | | g_port = 25557 |
| | | if not constant.is_windows(): |
| | | # 内网 |
| | | g_address = "192.168.84.61" |
| | | g_port = 25557 |
| | | |
| | | #IP(192.168.84.61)、端口(25557 |
| | | |
| | |
| | | for code in codes_: |
| | | try: |
| | | datas = init_data_util.get_volumns_by_code(code, 150) |
| | | logger_debug.info(f"获取到的K线:{datas}") |
| | | if datas: |
| | | HistoryKDataManager().save_history_bars(code, datas[0]['bob'].strftime("%Y-%m-%d"), datas) |
| | | except Exception as e: |
| | |
| | | if file.find(day) >= 0: |
| | | codes.add(file.split("_")[1][:6]) |
| | | return codes |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(HistoryKDataManager().get_history_bars_codes("2024-12-31")) |
| | |
| | | @param end_date: |
| | | @return: |
| | | """ |
| | | logger_debug.info("get_history_k_bars开始") |
| | | load_latest_trade_calendar() |
| | | _count = -1 |
| | | start_date = None |
| | |
| | | start_date = __trade_calendar_list[i] |
| | | if _count >= count: |
| | | break |
| | | logger_debug.info(f"get_history_k_bars 获取到开始日期:{start_date}") |
| | | request_id = __base_request("get_history_k_bars", {"start_date": start_date, "end_date": end_date, "code": code}) |
| | | return __read_response(request_id) |
| | | |