| | |
| | | |
| | | @classmethod |
| | | def start_buy(cls, code, last_data, last_data_index, is_first_code): |
| | | if not cls.__TradeStateManager.is_can_buy_cache(): |
| | | return False, True, f"今日已禁止交易", True |
| | | |
| | | if l2_trade_util.is_in_forbidden_trade_codes(code): |
| | | return False, True, f"代码禁止交易", True |
| | | |
| | | if cls.__PauseBuyCodesManager.is_in_cache(code): |
| | | return False, True, f"该代码被暂停交易", True |
| | | now_time_int = int(tool.get_now_time_str().replace(":", "")) |
| | | if now_time_int >= 145700: |
| | | return False, True, f"14:57后不能交易", True |
| | | cls.__buy(code, 0, last_data, last_data_index, is_first_code) |
| | | |
| | | @classmethod |
| | |
| | | from trade.huaxin import huaxin_trade_api as trade_api, huaxin_trade_api, huaxin_trade_data_update, \ |
| | | huaxin_trade_record_manager, huaxin_sell_util |
| | | from api.outside_api_command_callback import OutsideApiCommandCallback |
| | | from trade.order_statistic import DealAndDelegateWithBuyModeDataManager |
| | | from trade.radical_buy_data_manager import RedicalBuyDataManager |
| | | from trade.sell.sell_rule_manager import TradeRuleManager |
| | | from trade.trade_data_manager import RadicalBuyDealCodesManager |
| | |
| | | async_log_util.info(logger_l2_radical_buy, f"该代码已经成交:{code}") |
| | | return |
| | | |
| | | can_buy_result = RedicalBuyDataManager.can_buy(code) |
| | | can_buy_result = RedicalBuyDataManager.can_buy(code, DealAndDelegateWithBuyModeDataManager().get_deal_codes()) |
| | | if can_buy_result[0]: |
| | | # 获取激进买的板块 |
| | | result_cache = self.__radical_buy_by_blocks_result_cache.get(code) |
| | |
| | | from settings.trade_setting import MarketSituationManager |
| | | from third_data.kpl_data_constant import LimitUpDataConstant |
| | | from third_data.third_blocks_manager import BlockMapManager, CodeThirdBlocksManager |
| | | from trade.order_statistic import DealAndDelegateWithBuyModeDataManager |
| | | from trade.radical_buy_data_manager import RedicalBuyDataManager |
| | | from utils import global_util, tool, buy_condition_util |
| | | from log_module import log, async_log_util |
| | |
| | | return False, f"开1数量:{count},非开1首板身位不匹配:历史-{history_index + 1} 实时-{current_index + 1}" |
| | | if history_index == 1: |
| | | # 当前代码为老2,要判断老大是否可买 |
| | | if RedicalBuyDataManager.can_buy(history_before_codes_info[0][0])[0]: |
| | | if RedicalBuyDataManager.can_buy(history_before_codes_info[0][0], DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]: |
| | | return False, f"开1数量:{count},前排代码可买:{history_before_codes_info[0]}" |
| | | return True, f"开1数量:{count},前排代码不可买:{history_before_codes_info[0]}" |
| | | return True, f"开1数量:{count},历史-{history_index + 1} 实时-{current_index + 1}" |
| | |
| | | # 首板老2,判断前面的老大是否是属于不能买的范畴 |
| | | pre_code = history_before_codes_info[0][0] |
| | | # pre_code不能买,才能买 |
| | | if RedicalBuyDataManager.can_buy(pre_code)[0]: |
| | | if RedicalBuyDataManager.can_buy(pre_code, DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]: |
| | | return False, f"前排代码可买:{pre_code}" |
| | | # 距离前一个是否在10分钟内 |
| | | if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'), |
| | |
| | | """ |
| | | return self.__deal_mode_list_dict.get(mode) |
| | | |
| | | def get_deal_codes(self): |
| | | """ |
| | | 获取成交的代码 |
| | | @return: |
| | | """ |
| | | return self.__deal_codes |
| | | |
| | | def set_delegates_info(self, delegates): |
| | | """ |
| | | 设置委托信息 |
| | |
| | | |
| | | class RedicalBuyDataManager(): |
| | | @classmethod |
| | | def can_buy(cls, code): |
| | | def can_buy(cls, code, deal_codes=None): |
| | | """ |
| | | 是否可以买 |
| | | @param code: 代码 |
| | |
| | | if price < constant.MIN_CODE_PRICE or price > constant.MAX_CODE_PRICE: |
| | | return False, "价格不满足需求" |
| | | if gpcode_manager.BlackListCodeManager().is_in_cache(code): |
| | | return False, "已拉黑" |
| | | if deal_codes is not None and code in deal_codes: |
| | | pass |
| | | else: |
| | | # 拉黑且不是已经买入性质的拉黑 |
| | | return False, "已拉黑" |
| | | return True, "" |