| | |
| | | import schedule |
| | | |
| | | import constant |
| | | import env_info |
| | | from code_atrribute import gpcode_manager, history_k_data_util |
| | | from code_atrribute.gpcode_manager import CodesNameManager |
| | | from code_atrribute.history_k_data_util import HistoryKDatasUtils |
| | |
| | | if d["prePosition"] <= 0 and d["todayBSPos"] <= 0: |
| | | continue |
| | | # 获取现价 |
| | | fdata = {"code": code_, "code_name": code_name, "total": d["prePosition"]+d["todayBSPos"], |
| | | fdata = {"code": code_, "code_name": code_name, "total": d["prePosition"] + d["todayBSPos"], |
| | | "available": d["availablePosition"], "cost_price": d["historyPosPrice"], "volume_rate": 0} |
| | | |
| | | current_volume, pre_volume = PositionCodeDataManager.get_l1_current_volume( |
| | |
| | | elif operate == outside_api_command_manager.OPERRATE_GET: |
| | | sell_mode = AutoCancelSellModeManager().get_mode_cache(code) |
| | | self.send_response({"code": 0, "data": {"mode": sell_mode}}, client_id, request_id) |
| | | except Exception as e: |
| | | self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) |
| | | elif ctype == "get_sell_env": |
| | | try: |
| | | if env_info.l2_market_codes_info: |
| | | latest_time = max([v for k, v in env_info.l2_market_codes_info.items()]) |
| | | codes_count = len( |
| | | [k for k, v in env_info.l2_market_codes_info.items() if |
| | | v > tool.trade_time_sub(latest_time, 6)]) |
| | | else: |
| | | latest_time = '' |
| | | codes_count = 0 |
| | | fdata = {} |
| | | fdata["l2_market_info"] = (latest_time, codes_count) |
| | | self.send_response({"code": 0, "data": fdata}, client_id, request_id) |
| | | except Exception as e: |
| | | self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) |
| | | |
| | |
| | | buy1 = d["buy"][0] |
| | | time_int = d.get("dataTimeStamp") |
| | | time_str = l2_huaxin_util.convert_time(time_int) |
| | | async_log_util.info(logger_debug, f"获取到L1数据:({code},{time_str}, {buy1})") |
| | | # 更新环境变量 |
| | | if code not in env_info.l2_market_codes_info: |
| | | env_info.l2_market_codes_info[code] = {} |
| | | env_info.l2_market_codes_info[code] = time_str |
| | | L1DataProcessor.excute_sell_rule(code, buy1[1], buy1[0], "L2") |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | |
| | | |
| | | def OnRealTimeBuy1Info(self, code, buy1_info): |
| | | # buy1_info: [买1时间,买1价格, 原始买1量, 实时买1量] |