| | |
| | | import constant |
| | | from db import redis_manager_delegate as redis_manager, mysql_data_delegate as mysql_data |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module import log_export |
| | | from log_module import log_export, async_log_util |
| | | from log_module.log import hx_logger_l2_transaction, logger_debug, logger_request_api |
| | | from strategy import data_cache |
| | | from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager |
| | | from strategy.kpl_data_manager import KPLStockOfMarketsPlateLogManager, KPLMarketStockHeatLogManager |
| | | from strategy.trade_setting import TradeSetting |
| | | from trade import huaxin_trade_api, huaxin_trade_data_update |
| | | from trade.huaxin_trade_record_manager import DelegateRecordManager, DealRecordManager, MoneyManager, PositionManager |
| | |
| | | finally: |
| | | if use_time_list and use_time_list[-1][1] > 10: |
| | | logger_debug.warning(f"环境获取时间大于10s({request_id}):{use_time_list}") |
| | | |
| | | elif url.path == "/load_kpl_stock_of_markets_plate": |
| | | # 获取板块强度数据 |
| | | elif url.path == "/load_get_kpl_market_sift_plate": |
| | | # 加载数据 |
| | | KPLStockOfMarketsPlateLogManager().load_data() |
| | | response_data = json.dumps({"code": 0, "msg": "暂无内容"}) |
| | | elif url.path == "/get_kpl_stock_of_markets_plate": |
| | | elif url.path == "/get_kpl_market_sift_plate": |
| | | # 获取开盘啦流入板块详细信息 |
| | | print("==========get_kpl_market_sift_plate==========") |
| | | try: |
| | | time_str = params_dict.get("time") |
| | | if not time_str: |
| | | time_str = tool.get_now_time_str() |
| | | fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas() |
| | | response_data = json.dumps({"code": 1, "msg": "暂无内容"}) |
| | | for i in range(len(fdatas) - 1, -1, -1): |
| | | if fdatas[i][0] <= time_str: |
| | | response_data = json.dumps({"code": 0, "data": fdatas[i]}) |
| | | break |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | response_data = json.dumps({"code": 1, "msg": str(e)}) |
| | | |
| | | # 获取个股强度数据 |
| | | elif url.path == "/load_kpl_market_stock_heat": |
| | | # 加载数据 |
| | | KPLMarketStockHeatLogManager().load_data() |
| | | response_data = json.dumps({"code": 0, "msg": "暂无内容"}) |
| | | elif url.path == "/get_kpl_market_stock_heat": |
| | | # 获取开盘啦流入板块详细信息 |
| | | print("==========get_kpl_stock_of_markets_plate==========") |
| | | try: |
| | | time_str = params_dict.get("time") |
| | | if not time_str: |
| | | time_str = tool.get_now_time_str() |
| | | fdatas = KPLStockOfMarketsPlateLogManager().get_filter_log_datas() |
| | | fdatas = KPLMarketStockHeatLogManager().get_filter_log_datas() |
| | | response_data = json.dumps({"code": 1, "msg": "暂无内容"}) |
| | | for i in range(len(fdatas) - 1, -1, -1): |
| | | if fdatas[i][0] <= time_str: |
| | |
| | | raise Exception("没有获取到L1数据") |
| | | pre_price = data[1] |
| | | current_price = data[2] if data[2] else data[5][0][0] |
| | | # 获取最新成交价格 |
| | | latest_deal_price = data_cache.latest_deal_price_dict.get(code) |
| | | if latest_deal_price: |
| | | current_price = round(float(latest_deal_price), 2) |
| | | async_log_util.info(logger_debug, f"根据成交价卖出:{code}-{latest_deal_price}") |
| | | |
| | | price = tool.get_buy_min_price(current_price) |
| | | price = max(price, tool.get_limit_down_price(code, pre_price)) |
| | | else: |
| | |
| | | # 成交大单传递 |
| | | datas = self.rfile.read(int(self.headers['content-length'])) |
| | | _str = str(datas, encoding="gbk") |
| | | datas = json.loads(_str) |
| | | for d in datas: |
| | | if d[1] != 0: |
| | | continue |
| | | code, data = d[0], d[2] |
| | | if code not in data_cache.big_order_deal_dict: |
| | | data_cache.big_order_deal_dict[code] = [] |
| | | data_cache.big_order_deal_dict[code].append(d) |
| | | # 获取买大单数量 |
| | | len(data_cache.big_order_deal_dict.get(code, [])) |
| | | hx_logger_l2_transaction.info(_str) |
| | | # 记录日志 |
| | | result_str = json.dumps({"code": 0}) |