|
|
@@ -124,8 +124,6 @@ def move_completed_process_to_history(process_id_to_move: str) -> bool:
|
|
|
|
|
|
# 策略構建器
|
|
|
def strategy_builder(process_item):
|
|
|
- profit = Decimal(process_item['profit'])
|
|
|
- profitLimit = Decimal(process_item['profitLimit'])
|
|
|
strategy = process_item['strategy']
|
|
|
|
|
|
global core_data
|
|
|
@@ -313,12 +311,6 @@ def handle_submit_process():
|
|
|
if field not in data:
|
|
|
return jsonify({"error": f"缺少字段: {field}, keys: {data.keys()}"}), 400
|
|
|
|
|
|
- try:
|
|
|
- profit = Decimal(str(data['profit'])) # 利润
|
|
|
- profit_limit = Decimal(str(data['profitLimit'])) # 利润阈值
|
|
|
- except (decimal.InvalidOperation, ValueError) as e:
|
|
|
- return jsonify({"error": f"请求体中包含无效的小数/整数值: {e}"}), 400
|
|
|
-
|
|
|
symbol = data['symbol'] # 交易对符号
|
|
|
|
|
|
# 检查此交易对此区块是否处理过
|
|
|
@@ -329,7 +321,6 @@ def handle_submit_process():
|
|
|
if current_block - last_trade_block < MIN_BLOCKS_BETWEEN_ARB:
|
|
|
return jsonify({"message": f"已跳过: {symbol} 最近已处理 (区块 {last_trade_block}). 当前区块 {current_block}."}), 200
|
|
|
|
|
|
- if profit >= profit_limit:
|
|
|
process_id = str(uuid.uuid4()) # 生成唯一流程ID
|
|
|
process_item = copy.deepcopy(data)
|
|
|
process_item['id'] = process_id
|
|
|
@@ -338,21 +329,19 @@ def handle_submit_process():
|
|
|
process_item['currentState'] = "PENDING_START"
|
|
|
|
|
|
# 初始状态更新
|
|
|
- add_state_flow_entry(process_item, "RECEIVED", f"流程已接收。利润 {profit} >= 利润阈值 {profit_limit}。开始套利。", "success")
|
|
|
+ add_state_flow_entry(process_item, "RECEIVED", f"流程已接收。开始套利。", "success")
|
|
|
|
|
|
- with list_lock:
|
|
|
- processing_list.append(process_item)
|
|
|
+ with list_lock:
|
|
|
+ processing_list.append(process_item)
|
|
|
|
|
|
- last_process_info[symbol] = current_block
|
|
|
- logger.info(f"已更新 {symbol} 的最后处理信息至区块 {current_block}")
|
|
|
+ last_process_info[symbol] = current_block
|
|
|
+ logger.info(f"已更新 {symbol} 的最后处理信息至区块 {current_block}")
|
|
|
|
|
|
- # 在新线程中开始套利过程
|
|
|
- arb_thread = threading.Thread(target=arbitrage_process_flow, args=(process_item,), daemon=True)
|
|
|
- arb_thread.start()
|
|
|
+ # 在新线程中开始套利过程
|
|
|
+ arb_thread = threading.Thread(target=arbitrage_process_flow, args=(process_item,), daemon=True)
|
|
|
+ arb_thread.start()
|
|
|
|
|
|
- return jsonify({"message": "套利过程已启动", "process_id": process_id}), 201
|
|
|
- else:
|
|
|
- return jsonify({"message": f"利润 {profit} 小于利润阈值 {profit_limit}。不处理。"}), 200
|
|
|
+ return jsonify({"message": "套利过程已启动", "process_id": process_id}), 201
|
|
|
|
|
|
@app.route('/processing', methods=['GET'])
|
|
|
def get_processing_list():
|