| | |
| | | code_name = d["securityName"] |
| | | if d["prePosition"] <= 0: |
| | | continue |
| | | fdatas.append({"code": code_, "code_name": code_name, "total": d["prePosition"], |
| | | "available": d["availablePosition"]}) |
| | | # 获取现价 |
| | | fdata = {"code": code_, "code_name": code_name, "total": d["prePosition"], |
| | | "available": d["availablePosition"], "cost_price": d["historyPosPrice"]} |
| | | current_price = L1DataProcessor.get_l1_current_price(code_) |
| | | if current_price: |
| | | fdata["cost_price"] = current_price |
| | | fdatas.append(fdata) |
| | | result = {"code": 0, "data": fdatas} |
| | | self.send_response(result, client_id, request_id) |
| | | elif ctype == "get_buy1_info": |
| | |
| | | if not current_price: |
| | | raise Exception("尚未获取到现价") |
| | | price = round(tool.get_buy_max_price(current_price), 3) |
| | | sinfo = f"b_{code}_{int(time.time()*1000)}" |
| | | sinfo = f"b_{code}_{int(time.time() * 1000)}" |
| | | # 需要立即卖的数据 |
| | | # 下单之后需要立即卖出 |
| | | cb_data_util.need_sell_sinfos.add(sinfo) |
| | | result = huaxin_trade_api.order(1, code, volume, price, blocking=True, order_ref=order_ref, sinfo = sinfo) |
| | | result = huaxin_trade_api.order(1, code, volume, price, blocking=True, order_ref=order_ref, sinfo=sinfo) |
| | | if result: |
| | | if result["code"] == 0: |
| | | sinfo = result["data"]["sinfo"] |
| | |
| | | if not current_price: |
| | | raise Exception("尚未获取到现价") |
| | | price = round(tool.get_buy_min_price(current_price) + 0.001, 3) |
| | | result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref, blocking=True) |
| | | result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref, blocking=True) |
| | | async_log_util.info(logger_trade, f"API可转债卖结果: {result},成交价信息:{deal_price_info}") |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |