Administrator
4 天以前 48fb7a00951f91bdc707e5dd2d196e5bccb752c3
api/outside_api_command_callback.py
@@ -19,7 +19,7 @@
from code_attribute.code_data_util import ZYLTGBUtil
from code_attribute.code_l1_data_manager import L1DataManager
from code_attribute.gpcode_manager import CodePrePriceManager, CodesNameManager, WantBuyCodesManager, \
    HumanRemoveForbiddenManager
    HumanRemoveForbiddenManager, HumanForbiddenManager
from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager
from db.redis_manager_delegate import RedisUtils
from huaxin_client import l1_subscript_codes_manager
@@ -54,7 +54,8 @@
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
@@ -298,6 +299,7 @@
                        l2_trade_util.remove_from_forbidden_trade_codes(code)
                        # 加想买单要从黑名单移除
                        HumanRemoveForbiddenManager().add_code(code)
                        HumanForbiddenManager().remove_code(code)
                    name = gpcode_manager.get_code_name(code)
                    if not name:
                        results = HistoryKDatasUtils.get_gp_codes_names([code])
@@ -324,6 +326,7 @@
                    l2_trade_util.forbidden_trade(code, msg="手动加入 trade_server", force=True)
                    WantBuyCodesManager().remove_code(code)
                    HumanRemoveForbiddenManager().remove_code(code)
                    HumanForbiddenManager().add_code(code)
                    name = gpcode_manager.get_code_name(code)
                    if not name:
                        results = HistoryKDatasUtils.get_gp_codes_names([code])
@@ -332,6 +335,7 @@
                elif operate == outside_api_command_manager.OPERRATE_DELETE:
                    l2_trade_util.remove_from_forbidden_trade_codes(code)
                    HumanRemoveForbiddenManager().add_code(code)
                    HumanForbiddenManager().remove_code(code)
                elif operate == outside_api_command_manager.OPERRATE_GET:
                    codes = gpcode_manager.BlackListCodeManager().list_codes_cache()
                    datas = []
@@ -341,14 +345,14 @@
                    fresult = {"code": 0, "data": datas}
            elif code_list_type == outside_api_command_manager.CODE_LIST_WHITE:
                if operate == outside_api_command_manager.OPERRATE_SET:
                    gpcode_manager.WhiteListCodeManager().add_code(code)
                    gpcode_manager.WhiteListCodeManager().add_code(code, is_human=True)
                    name = gpcode_manager.get_code_name(code)
                    if not name:
                        results = HistoryKDatasUtils.get_gp_codes_names([code])
                        if results:
                            gpcode_manager.CodesNameManager.add_first_code_name(code, results[code])
                elif operate == outside_api_command_manager.OPERRATE_DELETE:
                    gpcode_manager.WhiteListCodeManager().remove_code(code)
                    gpcode_manager.WhiteListCodeManager().remove_code(code, is_human=True)
                elif operate == outside_api_command_manager.OPERRATE_GET:
                    codes = gpcode_manager.WhiteListCodeManager().list_codes_cache()
                    datas = []
@@ -1314,7 +1318,12 @@
                if latest_trading_date:
                    volumes_data = HistoryKDataManager().get_history_bars(code, latest_trading_date)
                    if volumes_data:
                        is_new_top =  code_nature_analyse.is_new_top(code, gpcode_manager.get_limit_up_price_by_preprice(code, volumes_data[-1]["close"]), 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)
                data = {
                    "blocks": {},
@@ -1384,7 +1393,8 @@
                                    "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,
@@ -1408,6 +1418,9 @@
                    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,
@@ -1466,8 +1479,26 @@
                                   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))
                self.send_response({"code": 0, "data": {}},
                                   client_id,
                                   request_id)
        except Exception as e:
            logging.exception(e)
            logger_debug.exception(e)