def post(self): """ 发单 """ info = request.values.to_dict() try: local_symbol = info["local_symbol"] direction = info["direction"] offset = info["offset"] type = info["type"] price = info["price"] volume = info["volume"] exchange = info["exchange"] except KeyError: return false_response(msg='参数含空') req = helper.generate_order_req_by_str(symbol=local_symbol, exchange=exchange, direction=direction, offset=offset, volume=int(volume), price=float(price), type=type) try: req_id = bee_current_app.send_order(req) sleep(0.2) order = bee_current_app.recorder.get_order(req_id) if order.status.value == "拒单": return false_response(msg=bee_current_app.recorder.get_new_error()['data']['ErrorMsg']) return true_response(msg="成功下单") except Exception: return false_response(msg="下单失败")
def post(self): """ 发单 """ info = request.values.to_dict() local_symbol = info.get("local_symbol") direction = info.get("direction") offset = info.get("offset") type = info.get("type") price = info.get("price") volume = info.get("volume") exchange = info.get("exchange") if local_symbol and direction and offset and type and price and volume and exchange: req = helper.generate_order_req_by_str(symbol=local_symbol, exchange=exchange, direction=direction, offset=offset, volume=int(volume), price=float(price), type=type) try: req_id = bee_current_app.send_order(req) sleep(0.2) order = bee_current_app.recorder.get_order(req_id) if order.status.value == "拒单": return false_response(msg=bee_current_app.recorder. get_new_error()['data']['ErrorMsg']) return true_response(msg="成功下单") except Exception as e: return false_response(msg="下单失败") return false_response(msg='参数含空')
def post(self): """ 发单 """ info = request.values local_symbol = info.get("local_symbol") direction = info.get("direction"), offset = info.get("offset") type = info.get("type"), price = info.get("price") volume = info.get("volume") req = helper.generate_order_req_by_str(symbol=local_symbol, exchange=current_app.recorder.get_contract( local_symbol=local_symbol).exchange.value, direction=direction, offset=offset, volume=volume, price=price, type=type ) try: current_app.send_order(req) return true_response(message="成功下单") except Exception: return false_response(message="下单失败")