| | |
| | | from trade.buy_radical import radical_buy_data_manager, new_block_processor |
| | | from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager |
| | | from trade.buy_radical.radical_buy_data_manager import RadicalBuyBlockManager, RadicalBuyDataManager |
| | | from trade.order_statistic import DealAndDelegateWithBuyModeDataManager |
| | | from utils import tool, import_util |
| | | from trade import trade_manager, l2_trade_util, trade_constant |
| | | from trade.trade_data_manager import CodeActualPriceProcessor, RadicalBuyDealCodesManager |
| | |
| | | latest_add_codes = set() |
| | | |
| | | |
| | | def compute_code_order(code, top_in_blocks=None, yesterday_limit_up_codes=None, today_history_limit_up_codes=None, top_out_blocks=None): |
| | | def compute_code_order(code, top_in_blocks=None, yesterday_limit_up_codes=None, today_history_limit_up_codes=None, |
| | | top_out_blocks=None): |
| | | """ |
| | | 计算代码的排序 |
| | | @param code: |
| | |
| | | return -1 |
| | | # 黑名单 |
| | | trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(code) |
| | | |
| | | # 处于委托状态的必须订阅 |
| | | if trade_state == trade_constant.TRADE_STATE_BUY_DELEGATED or trade_state == trade_constant.TRADE_STATE_BUY_PLACE_ORDER: |
| | | return 0 |
| | | if l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | # 没有成交 |
| | | if trade_state == trade_constant.TRADE_STATE_BUY_SUCCESS: |
| | |
| | | return 998 |
| | | else: |
| | | return -1 |
| | | |
| | | deal_codes = RadicalBuyDealCodesManager().get_deal_codes() |
| | | result = RadicalBuyDataManager().is_code_can_buy(code, deal_codes) |
| | | if not result[0]: |
| | | if len(result) > 2 and result[2]: |
| | | # 可以拉黑 |
| | | if new_block_processor.is_can_forbidden(code): |
| | | l2_trade_util.forbidden_trade(code, msg = result[1]) |
| | | l2_trade_util.forbidden_trade(code, msg=result[1]) |
| | | return -1 |
| | | |
| | | # 想买单 |
| | |
| | | # 判断今日辨识度 |
| | | try: |
| | | for b in blocks: |
| | | if radical_buy_data_manager.RadicalBuyBlockManager.is_today_block_special_codes(code, b, yesterday_limit_up_codes): |
| | | if radical_buy_data_manager.RadicalBuyBlockManager.is_today_block_special_codes(code, b, |
| | | yesterday_limit_up_codes): |
| | | if b in top_in_blocks: |
| | | index = top_in_blocks.index(b) |
| | | return index + 1 |
| | |
| | | # 创业板的涨幅需要打折 |
| | | rate = rate / 2 |
| | | if order_index >= 0: |
| | | if order_index < 1000 and rate >= 3: |
| | | if order_index < 1000 and rate >= 5: |
| | | # 涨幅大于3%的才能订阅 |
| | | _code_list.append((rate, code, order_index)) |
| | | else: |
| | |
| | | _delete_list = [] |
| | | for item in new_code_list: |
| | | trade_state = trade_manager.CodesTradeStateManager().get_trade_state_cache(item[1]) |
| | | if l2_trade_util.is_in_forbidden_trade_codes(item[1]) and trade_state != trade_constant.TRADE_STATE_BUY_SUCCESS: |
| | | if l2_trade_util.is_in_forbidden_trade_codes( |
| | | item[1]) and trade_state != trade_constant.TRADE_STATE_BUY_SUCCESS: |
| | | # 拉黑的尚未成交的代码 |
| | | _delete_list.append(item) |
| | | elif item[0] < 0: |
| | |
| | | for d in _delete_list: |
| | | del_code_list.append(d[1]) |
| | | |
| | | if del_code_list: |
| | | async_log_util.info(logger_l2_codes_subscript, |
| | | f"({request_id})需要删除订阅的代码:{del_code_list}") |
| | | |
| | | if constant.L2_SOURCE_TYPE == constant.L2_SOURCE_TYPE_HUAXIN: |
| | | # 华鑫L2,获取加入代码的涨停价 |
| | | |
| | |
| | | dif2 = add_code_set - latest_add_codes |
| | | if dif2: |
| | | # 新增加的订阅需要拉取之前的大单 |
| | | for c in dif2: |
| | | __pre_big_order_deal_thread_pool.submit(radical_buy_data_manager.pull_pre_deal_big_orders, c) |
| | | __pre_big_order_deal_thread_pool.submit(radical_buy_data_manager.pull_pre_deal_big_orders_by_codes, dif2) |
| | | if True: |
| | | async_log_util.info(logger_l2_codes_subscript, |
| | | f"({request_id})预处理新增订阅代码:{dif2}") |
| | |
| | | tool.get_buy_volume(limit_up_price), list(special_volumes))) |
| | | huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.push(add_datas, request_id) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | logger_debug.exception(e) |
| | | else: |
| | | pass |
| | | |