| | |
| | | import constant |
| | | import inited_data |
| | | import outside_api_command_manager |
| | | from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer, LCancelRateManager |
| | | from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer, LCancelRateManager, \ |
| | | CancelRateHumanSettingManager |
| | | from code_attribute import gpcode_manager, code_volumn_manager, zyltgb_util, code_nature_analyse |
| | | from code_attribute.code_data_util import ZYLTGBUtil |
| | | from code_attribute.code_l1_data_manager import L1DataManager |
| | |
| | | from trade.huaxin import huaxin_trade_api, huaxin_trade_data_update, \ |
| | | huaxin_trade_record_manager, huaxin_trade_order_processor, huaxin_sell_util |
| | | from trade.huaxin.huaxin_trade_record_manager import PositionManager, DealRecordManager, DelegateRecordManager |
| | | from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager, BeforeSubDealBigOrderManager |
| | | from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager, BeforeSubDealBigOrderManager, \ |
| | | TotalDealBigOrderThresholdMoneyManager |
| | | from trade.sell import sell_manager |
| | | from trade.sell.sell_rule_manager import TradeRuleManager, SellRule |
| | | from trade.trade_data_manager import RadicalBuyDealCodesManager |
| | |
| | | elif code_list_type == outside_api_command_manager.CODE_LIST_GREEN: |
| | | if operate == outside_api_command_manager.OPERRATE_SET: |
| | | gpcode_manager.GreenListCodeManager().add_code(code) |
| | | trade_record_log_util.add_green(code, "人为加绿") |
| | | |
| | | gpcode_manager.WantBuyCodesManager().add_code(code) |
| | | # 加白 |
| | | gpcode_manager.WhiteListCodeManager().add_code(code, is_human=True) |
| | | trade_record_log_util.add_white_buy(code, "加绿加白") |
| | | |
| | | name = gpcode_manager.get_code_name(code) |
| | | if not name: |
| | | results = HistoryKDatasUtils.get_gp_codes_names([code]) |
| | |
| | | gpcode_manager.CodesNameManager.add_first_code_name(code, results[code]) |
| | | elif operate == outside_api_command_manager.OPERRATE_DELETE: |
| | | gpcode_manager.GreenListCodeManager().remove_code(code) |
| | | gpcode_manager.WantBuyCodesManager().remove_code(code) |
| | | gpcode_manager.WhiteListCodeManager().remove_code(code) |
| | | elif operate == outside_api_command_manager.OPERRATE_GET: |
| | | codes = gpcode_manager.GreenListCodeManager().list_codes_cache() |
| | | datas = [] |
| | |
| | | except: |
| | | pass |
| | | # L撤比例 |
| | | l_down_cancel_rate, must_buy = LCancelRateManager.get_cancel_rate(code, |
| | | buy_mode=OrderBeginPosInfo.MODE_RADICAL) |
| | | l_down_cancel_rate, must_buy, cancel_rate_info = LCancelRateManager.get_cancel_rate(code, |
| | | buy_mode=OrderBeginPosInfo.MODE_RADICAL) |
| | | |
| | | # 在挂的距离成交进度位金额/(远近期参考量-单当日实时成交量)*100% |
| | | expire_rate = "未知" |
| | |
| | | expire_rate = "100%" |
| | | else: |
| | | expire_rate = f"{100 - round(100 * total_left_num * 100 / (referer_volume - today_volumn), 2)}%" |
| | | except: |
| | | pass |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | |
| | | fdata = {"id": orderSysID, "code_info": (code, code_name), "total_num": total_nums, |
| | | "finish_num": deal_or_cancel_num, |
| | |
| | | "block": '', |
| | | "trade_queue": [], |
| | | "l_down_cancel_rate": l_down_cancel_rate, |
| | | "l_down_cancel_rate_info": cancel_rate_info, |
| | | "expire_rate": expire_rate |
| | | } |
| | | limit_up_data = kpl_data_manager.KPLLimitUpDataRecordManager.record_code_dict.get(code) |
| | |
| | | if volumes_data: |
| | | is_new_top = code_nature_analyse.is_new_top(code, |
| | | gpcode_manager.get_limit_up_price_by_preprice(code, |
| | | volumes_data[0]["close"]), |
| | | volumes_data[ |
| | | 0][ |
| | | "close"]), |
| | | volumes_data) |
| | | |
| | | data = { |
| | |
| | | "top_block_count_by_market_strong": constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG, |
| | | "special_codes_max_block_in_rank": constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL, |
| | | "ignore_block_in_money_market_strong": constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG, |
| | | "buy_first_limit_up": 1 if constant.CAN_BUY_FIRST_LIMIT_UP else 0 |
| | | "buy_first_limit_up": 1 if constant.CAN_BUY_FIRST_LIMIT_UP else 0, |
| | | "can_auto_add_white": 1 if constant.CAN_AUTO_ADD_WHITE else 0 |
| | | }} |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | |
| | | if radical_buy.get('buy_first_limit_up') is not None: |
| | | constant.CAN_BUY_FIRST_LIMIT_UP = True if radical_buy.get( |
| | | 'buy_first_limit_up') else False |
| | | if radical_buy.get('can_auto_add_white') is not None: |
| | | constant.CAN_AUTO_ADD_WHITE = True if radical_buy.get( |
| | | 'can_auto_add_white') else False |
| | | |
| | | self.send_response({"code": 0, "data": {}, "msg": f""}, |
| | | client_id, |
| | |
| | | client_id, |
| | | request_id) |
| | | |
| | | elif ctype == "test_cancel_order": |
| | | # 获取相同板块的涨停代码数量 |
| | | code = data.get("code") |
| | | trade_manager.start_cancel_buy(code, force=True) |
| | | self.send_response({"code": 0, "data": {}}, |
| | | client_id, |
| | | request_id) |
| | | |
| | | elif ctype == "set_total_deal_big_order_threshold_money": |
| | | code = data.get("code") |
| | | money = data.get("money") |
| | | if not code or not money: |
| | | self.send_response({"code": 1, "data": {}, "msg": "code/money为空"}, |
| | | client_id, |
| | | request_id) |
| | | return |
| | | TotalDealBigOrderThresholdMoneyManager().set_money(code, int(money), trade_manager.CodesTradeStateManager().get_trade_state_cache(code)) |
| | | |
| | | # 如果是加红状态,且大单不够就需要移红 |
| | | if gpcode_manager.MustBuyCodesManager().is_in_cache(code): |
| | | deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code, gpcode_manager.get_limit_up_price_as_num(code)) |
| | | if deal_big_order_info[0] > 0: |
| | | gpcode_manager.MustBuyCodesManager().remove_code(code) |
| | | trade_record_log_util.add_common_msg(code, "移红", f"大单阈值修改({money})") |
| | | self.send_response({"code": 0, "data": {}}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "set_l_down_rate": |
| | | # 设置L后撤单比例 |
| | | code = data.get("code") |
| | | rate = data.get("rate") |
| | | if rate < 0 or rate > 1: |
| | | self.send_response({"code": 1, "msg": "比例范围不在0-1之间"}, |
| | | client_id, |
| | | request_id) |
| | | return |
| | | rate = round(rate, 2) |
| | | CancelRateHumanSettingManager().set_l_down(code, rate) |
| | | self.send_response({"code": 0, "data": {}}, |
| | | client_id, |
| | | request_id) |
| | | |
| | | except Exception as e: |
| | | logging.exception(e) |