| | |
| | | send_response({"code": 0, "data": {"orderRef": order_ref}}, client_id, request_id) |
| | | else: |
| | | raise e |
| | | finally: |
| | | huaxin_trade_data_update.add_position_list() |
| | | huaxin_trade_data_update.add_money_list() |
| | | huaxin_trade_data_update.add_deal_list() |
| | | |
| | | else: |
| | | if not price: |
| | | limit_down_price = target_codes_manager.get_limit_down_price(code) |
| | |
| | | result = huaxin_trade_api.order(direction, code, volume, price, |
| | | sinfo=sinfo, |
| | | blocking=True, request_id=request_id) |
| | | huaxin_trade_data_update.add_position_list() |
| | | huaxin_trade_data_update.add_money_list() |
| | | huaxin_trade_data_update.add_deal_list() |
| | | send_response({"code": 0, "data": result}, client_id, request_id) |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | |
| | | result = huaxin_trade_api.order(1, cb_code, 20, round(float(limit_up_price), 3), blocking=True) |
| | | __deal_codes.add(code) |
| | | async_log_util.info(logger_trade, f"可转债下单结果:{result}") |
| | | huaxin_trade_data_update.add_position_list() |
| | | huaxin_trade_data_update.add_money_list() |
| | | huaxin_trade_data_update.add_deal_list() |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | time.sleep(1) |
| | |
| | | |
| | | # 撤卖单 |
| | | import threading |
| | | import time |
| | | |
| | | from log_module import async_log_util |
| | |
| | | |
| | | |
| | | def __cancel_sell_order(code, order_ref): |
| | | time.sleep(2) |
| | | try: |
| | | result = huaxin_trade_api.cancel_order(2, code, None, orderRef=order_ref) |
| | | except Exception as e: |
| | |
| | | |
| | | # 开始撤单 |
| | | def start_sell(code, volume, price_type, limit_up_price, limit_down_price, current_price, blocking=False, |
| | | request_id=None,order_ref=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("价格获取出错") |
| | |
| | | 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) |
| | | return result |
| | | # 2S不成交就撤单 |
| | | threading.Thread(target=lambda: __cancel_sell_order(code, order_ref), daemon=True).start() |
| | | return result |