| | |
| | | # 获取买点与卖点 |
| | | if "buy_list" not in r: |
| | | buys = huaxin_trade_record_manager.DealRecordManager().list_buy_by_code_cache(cb_code) |
| | | r["buy_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for |
| | | x in |
| | | buys] |
| | | # 根据orderSystemId聚合 |
| | | temp_dict = {} |
| | | for b in buys: |
| | | orderSysID = b["orderSysID"] |
| | | if orderSysID not in temp_dict: |
| | | temp_dict[orderSysID] = [] |
| | | temp_dict[orderSysID].append(b) |
| | | r["buy_list"] = [] |
| | | for k in temp_dict: |
| | | volume = sum([x["volume"] for x in temp_dict[k]]) |
| | | x = temp_dict[k][0] |
| | | r["buy_list"].append({"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": volume}) |
| | | r["createTime"] = int(buys[-1]["tradeTime"].replace(":", "")) |
| | | |
| | | if "sell_list" not in r: |
| | | sells = huaxin_trade_record_manager.DealRecordManager().list_sell_by_code_cache(cb_code) |
| | | r["sell_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for |
| | | x |
| | | in |
| | | sells] |
| | | temp_dict = {} |
| | | for s in sells: |
| | | orderSysID = s["orderSysID"] |
| | | if orderSysID not in temp_dict: |
| | | temp_dict[orderSysID] = [] |
| | | temp_dict[orderSysID].append(s) |
| | | r["sell_list"] = [] |
| | | for k in temp_dict: |
| | | volume = sum([x["volume"] for x in temp_dict[k]]) |
| | | x = temp_dict[k][0] |
| | | r["sell_list"].append({"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": volume}) |
| | | send_response({"code": 0, "data": results}, client_id, request_id) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | |
| | | volume = int(__get_buy_money() / float(limit_up_price)) |
| | | volume = (volume // 10) * 10 |
| | | buy_price = round(min(float(market_info.price * 1.02), float(limit_up_price)), 3) |
| | | async_log_util.info(logger_trade, f"准备下单:{cb_code}-{buy_price}") |
| | | async_log_util.info(logger_trade, f"准备下单:{cb_code}-{buy_price}-{buy_info}") |
| | | # 买入20股 |
| | | result = huaxin_trade_api.order(1, cb_code, volume, buy_price, blocking=True) |
| | | CodeTradeStateManager().set_trade_state(cb_code, strategy_type, |
| | |
| | | rate = (info["TradePrice"] - pre_close_price) / pre_close_price |
| | | if rate < 0.07: |
| | | return False, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, "涨幅小于7%" |
| | | |
| | | if rate >= 0.09: |
| | | if code.find("30") == 0 and rate >= 0.19: |
| | | return True, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, f"2S内上升{int(rised_price * 100)}档 涨幅({rate})>19%" |
| | | if code.find("30") != 0 and rate >= 0.09: |
| | | return True, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, f"2S内上升{int(rised_price * 100)}档 涨幅({rate})>9%" |
| | | |
| | | # (板块, 前排开1数量, 高位板数量, 创业板数量, 身位) |
| | | block_infos = CodePlateKeyBuyManager.statistic_block_infos(code, |
| | | KPLLimitUpDataRecordManager.latest_origin_datas) |
| | | |
| | | if rate >= 0.08: |
| | | for b in block_infos: |
| | | codes = b[1] | b[2] | b[3] |
| | | if len(codes) >= 1: |
| | | return True, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, f"2S内上升{int(rised_price * 100)}档,板块信息:{b}" |
| | | |
| | | if rate >= 0.07: |
| | | for b in block_infos: |
| | | codes = b[1] | b[2] | b[3] |
| | | if len(codes) >= 2: |
| | | return True, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, f"2S内上升{int(rised_price * 100)}档,板块信息:{b}" |
| | | return False, STRATEGY_TYPE_RISE_HIGH_WITH_BLOCKS, f"不满足买入条件" |
| | | |
| | | def can_buy_for_stategy_2(): |
| | | if code.find("30") == 0: |
| | | if code.find("30") == 0 and False: |
| | | # 30开始的9.8以上的算涨停 |
| | | markekt = self.__latest_market_info_dict.get(info["SecurityID"]) |
| | | if markekt and markekt[2] >= 0.098 and self.__latest_trade_price_dict.get(code): |
| | |
| | | # 加入涨停代码列表 |
| | | self.__limit_up_record_codes.add(code) |
| | | return False, STRATEGY_TYPE_LIMIT_UP, "不满足买入条件" |
| | | return [can_buy_for_stategy_1(),can_buy_for_stategy_2(), can_buy_for_stategy_3()] |
| | | |
| | | return [can_buy_for_stategy_1(), can_buy_for_stategy_2(), can_buy_for_stategy_3()] |
| | | |
| | | def __get_rised_price(self, code, transaction_info, time_space=2000): |
| | | """ |