| | |
| | | from third_data.kpl_limit_up_data_manager import CodeLimitUpSequenceManager |
| | | from third_data.kpl_util import KPLDataType |
| | | from third_data.third_blocks_manager import CodeThirdBlocksManager, SOURCE_TYPE_KPL, BlockMapManager |
| | | from trade import trade_manager, l2_trade_util, trade_data_manager, trade_constant |
| | | from trade import trade_manager, l2_trade_util, trade_data_manager, trade_constant, trade_record_log_util |
| | | import l2_data_util as l2_data_util_old |
| | | from trade.buy_money_count_setting import BuyMoneyAndCountSetting, RadicalBuyBlockCodeCountManager |
| | | from trade.buy_radical import block_special_codes_manager, radical_buy_data_manager |
| | |
| | | elif code_list_type == outside_api_command_manager.CODE_LIST_MUST_BUY: |
| | | if operate == outside_api_command_manager.OPERRATE_SET: |
| | | gpcode_manager.MustBuyCodesManager().add_code(code) |
| | | trade_record_log_util.add_must_buy(code, "手动拉红") |
| | | name = gpcode_manager.get_code_name(code) |
| | | if not name: |
| | | results = HistoryKDatasUtils.get_gp_codes_names([code]) |
| | |
| | | break |
| | | if watch_indexes: |
| | | ##判断监听的数据中是否有大单## |
| | | # 之前的大单为100w,现在改为正常大单 |
| | | has_big_num = False |
| | | BIG_ORDER_NUM_THRESHOLD = l2_data_util.get_big_money_val(gpcode_manager.get_limit_up_price_as_num(code), tool.is_ge_code(code)) |
| | | BIG_ORDER_NUM_THRESHOLD = int(round(BIG_ORDER_NUM_THRESHOLD/(gpcode_manager.get_limit_up_price_as_num(code)*100))) |
| | | for i in watch_indexes: |
| | | # 是否有大单 |
| | | data = total_datas[i] |
| | | val = data['val'] |
| | | if float(val['price']) * val['num'] > 100 * 100: |
| | | if val['num'] > BIG_ORDER_NUM_THRESHOLD: |
| | | has_big_num = True |
| | | break |
| | | if not has_big_num: |
| | |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 小金额过滤 |
| | | if float(val['price']) * val['num'] < 100 * 100: |
| | | if val['num'] < BIG_ORDER_NUM_THRESHOLD: |
| | | continue |
| | | cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, |
| | | i, |
| | |
| | | elif type == trade_record_log_util.TYPE_CANCEL: |
| | | load_cancel_watch_index(latest_cancel_watch_index_dict) |
| | | records_new_data.append((time_, "撤单", f"原因:{data['msg']}", [])) |
| | | elif type == trade_record_log_util.TYPE_ACTION: |
| | | records_new_data.append((time_, data['type'], f"{data['msg']}", [])) |
| | | load_cancel_watch_index(latest_cancel_watch_index_dict) |
| | | records_new_data.sort(key=lambda x: x[0]) |
| | | if records_new_data: |
| | |
| | | from third_data.kpl_data_constant import LimitUpDataConstant, LimitUpCodesBlockRecordManager |
| | | from third_data.kpl_data_manager import CodeHighLevel |
| | | from third_data.third_blocks_manager import BlockMapManager |
| | | from trade import trade_record_log_util |
| | | from trade.buy_money_count_setting import RadicalBuyBlockCodeCountManager |
| | | from trade.buy_radical.block_special_codes_manager import BlockSpecialCodesManager |
| | | from trade.trade_data_manager import RadicalBuyDealCodesManager |
| | |
| | | # 计算卖单阈值 |
| | | if total_deal_sell_money_info_list: |
| | | max_sell_money = max([x[0] for x in total_deal_sell_money_info_list]) |
| | | average_sell_money = sum([x[0] for x in total_deal_sell_money_info_list])//len(total_deal_sell_money_info_list) |
| | | average_sell_money = sum([x[0] for x in total_deal_sell_money_info_list]) // len( |
| | | total_deal_sell_money_info_list) |
| | | threshold_sell_money = int( |
| | | round(max(self.__get_base_big_order_threshold(code), |
| | | min((max_sell_money // 2 + average_sell_money) // 2, average_sell_money)))) |
| | |
| | | @param code: |
| | | @return: |
| | | """ |
| | | if gpcode_manager.MustBuyCodesManager().is_in_cache(code): |
| | | return |
| | | gpcode_manager.MustBuyCodesManager().add_code(code) |
| | | |
| | | # 如果加绿了就直接拉白 |
| | | if gpcode_manager.GreenListCodeManager().is_in_cache(code): |
| | | if gpcode_manager.WhiteListCodeManager().is_in_cache(code): |
| | | return |
| | | gpcode_manager.WhiteListCodeManager().add_code(code) |
| | | trade_record_log_util.add_white_buy(code, "已加绿且大单足够") |
| | | else: |
| | | if gpcode_manager.MustBuyCodesManager().is_in_cache(code): |
| | | return |
| | | gpcode_manager.MustBuyCodesManager().add_code(code) |
| | | trade_record_log_util.add_must_buy(code, "大单足够") |
| | | |
| | | |
| | | class RadicalBuyBlockManager: |
| | |
| | | """ |
| | | THRESHOLD_MONEY = BeforeSubDealBigOrderManager().get_big_order_threshold(code) |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT = round( |
| | | code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume(code, limit_up_price) * limit_up_price / 1e8, 2) * 1.2 |
| | | code_volumn_manager.CodeVolumeManager().get_radical_buy_refer_volume(code, |
| | | limit_up_price) * limit_up_price / 1e8, |
| | | 2) * 1.2 |
| | | if tool.is_ge_code(code): |
| | | TOTAL_BIG_DEAL_MONEY_THRESHOLD_COUNT *= 3.3 |
| | | |
| | |
| | | TYPE_FORBIDDEN_BUY = "forbidden_buy" # 禁止买入 |
| | | TYPE_CANT_PLACE_ORDER = "can_not_place_order" # 不能下单 |
| | | TYPE_CANCEL = "cancel" # 撤单 |
| | | TYPE_ACTION = "action" # 针对代码的操作 |
| | | |
| | | |
| | | class PlaceOrderInfo(object): |
| | |
| | | __add_log(TYPE_CANCEL, code, {"msg": msg, "real_place_order_index": real_place_order_index}) |
| | | |
| | | |
| | | # 加红信息 |
| | | def add_must_buy(code, msg=""): |
| | | __add_log(TYPE_ACTION, code, {"type": "加红", "msg": msg}) |
| | | |
| | | |
| | | # 加绿 |
| | | def add_green(code, msg=""): |
| | | __add_log(TYPE_ACTION, code, {"type": "加绿", "msg": msg}) |
| | | |
| | | |
| | | # 加白 |
| | | def add_white_buy(code, msg=""): |
| | | __add_log(TYPE_ACTION, code, {"type": "加白", "msg": msg}) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | pass |
| | |
| | | from l2.l2_data_util import local_today_datas, L2DataUtil |
| | | from l2.l2_sell_manager import L2MarketSellManager |
| | | from log_module.log import logger_l2_error |
| | | from trade import trade_record_log_util |
| | | from trade.buy_radical.radical_buy_data_manager import RadicalBuyDataManager |
| | | from trade.trade_data_manager import PlaceOrderCountManager |
| | | from trade.trade_queue_manager import THSBuy1VolumnManager |
| | |
| | | # 如果是绿名单,下单之后就加红 |
| | | if GreenListCodeManager().is_in_cache(code): |
| | | MustBuyCodesManager().add_code(code) |
| | | trade_record_log_util.add_must_buy(code, "如果是绿名单,下单之后就加红") |
| | | |
| | | # 如果是扫入下单,下单之后就加红 |
| | | if order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL: |