| | |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "get_place_order_settings": |
| | | # 获取买入下单设置 |
| | | data = { |
| | | "radical_buy": {"price": (constant.MIN_CODE_RADICAL_BUY_PRICE, constant.MAX_CODE_RADICAL_BUY_PRICE), |
| | | "zyltgb": (constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI, |
| | | constant.MAX_CODE_RADICAL_BUY_ZYLTGB_AS_YI)}} |
| | | self.send_response({"code": 0, "data": data, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | elif ctype == "set_place_order_settings": |
| | | radical_buy = data.get("radical_buy") |
| | | if radical_buy: |
| | | radical_buy = json.loads(radical_buy) |
| | | constant.MIN_CODE_RADICAL_BUY_PRICE = radical_buy["price"][0] |
| | | constant.MAX_CODE_RADICAL_BUY_PRICE = radical_buy["price"][1] |
| | | constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI = radical_buy["zyltgb"][0] |
| | | constant.MAX_CODE_RADICAL_BUY_ZYLTGB_AS_YI = radical_buy["zyltgb"][1] |
| | | self.send_response({"code": 0, "data": {}, "msg": f""}, |
| | | client_id, |
| | | request_id) |
| | | |
| | | |
| | | |
| | | except Exception as e: |
| | | logging.exception(e) |
| | |
| | | |
| | | # 扫入价格区间 |
| | | MAX_CODE_RADICAL_BUY_PRICE = 40 |
| | | MIN_CODE_RADICAL_BUY_PRICE = 2 |
| | | MIN_CODE_RADICAL_BUY_PRICE = 3 |
| | | # 扫入的自由流通市值区间 |
| | | MAX_CODE_RADICAL_BUY_ZYLTGB_AS_YI = 80 |
| | | MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI = 5 |
| | | |
| | | |
| | | # L2数据是否载入完成 |
| | |
| | | % (nRequestID, pInputOrderActionField.OrderSysID, |
| | | pRspInfoField.ErrorID, |
| | | pRspInfoField.ErrorMsg)) |
| | | except: |
| | | async_log_util.info(logger_local_huaxin_trade_debug, "OnErrRtnOrderAction: 撤单出错") |
| | | except Exception as e: |
| | | async_log_util.info(logger_local_huaxin_trade_debug, f"OnErrRtnOrderAction: 撤单出错-{str(e)}") |
| | | |
| | | def OnRspInquiryJZFund(self, pRspInquiryJZFundField: "CTORATstpRspInquiryJZFundField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | |
| | | # 预埋单 |
| | | def __test_pre_place_order(): |
| | | logger_debug.info("进入预埋单测试") |
| | | price = 18.16 |
| | | code = "002626" |
| | | price = round(3.55*1.1, 2) |
| | | code = "600581" |
| | | shadow_price = tool.get_shadow_price(price) |
| | | if not constant.TRADE_ENABLE: |
| | | return |
| | | try: |
| | | result = huaxin_trade_api.order(1, code, 100, price, blocking=False, |
| | | result = huaxin_trade_api.order(1, code, 100, price, blocking=True, |
| | | shadow_price=shadow_price) |
| | | async_log_util.info(logger_trade, f"{code}下单结束") |
| | | async_log_util.info(logger_trade, f"{code}下单结束:{result}") |
| | | except Exception as e: |
| | | pass |
| | | |
| | |
| | | # 做一些初始化的操作 |
| | | def __init(): |
| | | def run_pending(): |
| | | schedule.every().day.at("15:10:00").do(zyltgb_util.update_all_zylt_volumes) |
| | | schedule.every().day.at("01:00:01").do(__test_pre_place_order) |
| | | schedule.every().day.at("08:00:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("08:30:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("09:00:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("09:00:01").do(huaxin_trade_data_update.add_money_list) |
| | | schedule.every().day.at("09:15:20").do(huaxin_trade_data_update.add_money_list) |
| | | while True: |
| | | schedule.run_pending() |
| | | time.sleep(1) |
| | |
| | | |
| | | # 持仓刷新 |
| | | huaxin_trade_data_update.add_position_list() |
| | | schedule.every().day.at("15:10:00").do(zyltgb_util.update_all_zylt_volumes) |
| | | schedule.every().day.at("01:00:01").do(__test_pre_place_order) |
| | | schedule.every().day.at("08:00:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("08:30:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("09:00:01").do(history_k_data_manager.update_history_k_bars) |
| | | schedule.every().day.at("09:00:01").do(huaxin_trade_data_update.add_money_list) |
| | | schedule.every().day.at("09:15:20").do(huaxin_trade_data_update.add_money_list) |
| | | |
| | | threading.Thread(target=run_pending, daemon=True).start() |
| | | l2_data_util.load_l2_data_all(True) |
| | | L2TradeSingleDataManager.set_callback(MyL2TradeSingleCallback()) |
| | |
| | | |
| | | @classmethod |
| | | def set_history_limit_up_datas(cls, history_limit_up_datas_): |
| | | if history_limit_up_datas_ is None: |
| | | return |
| | | cls.history_limit_up_datas = history_limit_up_datas_ |
| | | for d in cls.history_limit_up_datas: |
| | | blocks = {d[2]} |
| | |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb: |
| | | zyltgb_as_yi = round(zyltgb / 100000000, 2) |
| | | if zyltgb_as_yi > 80: |
| | | if zyltgb_as_yi > constant.MAX_CODE_RADICAL_BUY_ZYLTGB_AS_YI: |
| | | return False, "自由流通市值过大" |
| | | elif zyltgb_as_yi < constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI: |
| | | return False, "自由流通市值过小" |
| | | if gpcode_manager.BlackListCodeManager().is_in_cache(code): |
| | | if deal_codes is not None and code in deal_codes: |
| | | pass |
| | |
| | | @param volume_rate: |
| | | @return: |
| | | """ |
| | | money_y = code_volumn_manager.get_reference_volume_as_money_y(code) |
| | | money_y = min(money_y, 50) |
| | | money_y = max(money_y, 5) |
| | | # 计算大单参考数量 |
| | | threshold_count = int(round(0.4*money_y)) |
| | | current_big_order_deal_count = EveryLimitupBigDealOrderManager.get_big_buy_deal_order_count(code) |
| | | if volume_rate >= 0.5: |
| | | # 当换手量>50%时,则,不需要每次扫入时需要≥2笔大单,而是累计需要≥2笔大单即可 |
| | | deal_big_order_count = BigOrderDealManager().get_total_buy_count(code) |
| | | if deal_big_order_count >= 2: |
| | | return True, f"量比-{volume_rate}, 总大单成交数量({deal_big_order_count})>=2" |
| | | if deal_big_order_count >= threshold_count: |
| | | return True, f"量比-{volume_rate}, 总大单成交数量({deal_big_order_count})>={threshold_count}" |
| | | else: |
| | | return False, f"量比-{volume_rate}, 总大单成交数量({deal_big_order_count})<2" |
| | | return False, f"量比-{volume_rate}, 总大单成交数量({deal_big_order_count})<{threshold_count}" |
| | | else: |
| | | if current_big_order_deal_count >= 2: |
| | | return True, f"量比-{volume_rate}, 本次大单成交数量({current_big_order_deal_count})>=2" |
| | | if current_big_order_deal_count >= threshold_count: |
| | | return True, f"量比-{volume_rate}, 本次大单成交数量({current_big_order_deal_count})>={threshold_count}" |
| | | else: |
| | | return False, f"量比-{volume_rate}, 本次大单成交数量({current_big_order_deal_count})<2" |
| | | return False, f"量比-{volume_rate}, 本次大单成交数量({current_big_order_deal_count})<{threshold_count}" |