| | |
| | | limit_down_price = gpcode_manager.get_limit_down_price(code) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | huaxin_sell_util.start_sell(code, r.sell_volume, r.sell_price_type, limit_up_price, |
| | | limit_down_price, |
| | | buy1_price) |
| | | limit_down_price, |
| | | buy1_price) |
| | | SellRuleManager().excute_sell(r.id_) |
| | | except: |
| | | pass |
| | |
| | | class OutsideApiCommandCallback(outside_api_command_manager.ActionCallback): |
| | | __cancel_sell_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=8) |
| | | __DealRecordManager = DealRecordManager() |
| | | __code_sell_way_dict={} |
| | | __code_sell_way_dict = {} |
| | | |
| | | @classmethod |
| | | def __send_response(cls, data_bytes): |
| | |
| | | current_price = TradeServerProcessor.get_l1_current_price(code) |
| | | limit_down_price = gpcode_manager.get_limit_down_price(code) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | result = huaxin_sell_util.start_sell(code, volume, price_type, limit_up_price, limit_down_price, |
| | | current_price, blocking=True, request_id=request_id) |
| | | async_log_util.info(logger_trade, f"API卖结果: {result}") |
| | | self.send_response(result, client_id, request_id) |
| | | order_ref = huaxin_util.create_order_ref() |
| | | try: |
| | | result = huaxin_sell_util.start_sell(code, volume, price_type, limit_up_price, limit_down_price, |
| | | current_price, blocking=True, request_id=request_id, |
| | | order_ref=order_ref) |
| | | async_log_util.info(logger_trade, f"API卖结果: {result}") |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |
| | | if str(e).find("超时") >= 0: |
| | | self.send_response({"code": 0, "data": {"orderRef": order_ref}}, client_id, request_id) |
| | | else: |
| | | raise e |
| | | else: |
| | | result = huaxin_trade_api.order(direction, code, volume, price, price_type=price_type, sinfo=sinfo, |
| | | blocking=True, request_id=request_id) |
| | |
| | | dealing_info = HuaXinTransactionDataManager.get_dealing_order_info(code) |
| | | if dealing_info: |
| | | if str(total_datas[trade_index]["val"]["orderNo"]) == str(dealing_info[0]): |
| | | total_left_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1]//100) |
| | | total_left_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1] // 100) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | buy1_money = Buy1PriceManager().get_latest_buy1_money(code) |
| | | if buy1_money is None: |
| | |
| | | elif ctype == "get_positions": |
| | | # 获取所有持仓信息 |
| | | positions = PositionManager.latest_positions |
| | | fdatas=[] |
| | | fdatas = [] |
| | | if positions: |
| | | for d in positions: |
| | | code_ = d["securityID"] |
| | |
| | | results[code_])).start() |
| | | if d["prePosition"] <= 0: |
| | | continue |
| | | fdatas.append({"code":code_,"code_name":code_name,"total":d["prePosition"],"available": d["availablePosition"]}) |
| | | fdatas.append({"code": code_, "code_name": code_name, "total": d["prePosition"], |
| | | "available": d["availablePosition"]}) |
| | | result = {"code": 0, "data": fdatas} |
| | | self.send_response(result, client_id, request_id) |
| | | elif ctype == "set_code_sell_way": |