| | |
| | | # return False |
| | | rate = (float(limit_up_price) - min_price) / min_price |
| | | # print(rate) |
| | | if rate >= 0.28: |
| | | if rate >= 0.319: |
| | | return True |
| | | return False |
| | | |
| | |
| | | |
| | | # 开始撤单 |
| | | def start_sell(code, volume, price_type, limit_up_price, limit_down_price, current_price, blocking=False, |
| | | request_id=None): |
| | | request_id=None,order_ref=None): |
| | | price = sell_util.get_sell_price(price_type, limit_up_price, limit_down_price, current_price) |
| | | if not price: |
| | | raise Exception("价格获取出错") |
| | | async_log_util.info(logger_trade, f"API卖: 单价-{price}") |
| | | if not order_ref: |
| | | order_ref = huaxin_util.create_order_ref() |
| | | result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref, |
| | | blocking=blocking, request_id=request_id) |
| | |
| | | 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) |
| | | 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) |
| | | 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) |
| | |
| | | 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": |