diff --git a/backend/app/models/paper_trading.py b/backend/app/models/paper_trading.py index c8cdf69..be07c9f 100644 --- a/backend/app/models/paper_trading.py +++ b/backend/app/models/paper_trading.py @@ -65,7 +65,7 @@ class PaperOrder(Base): signal_type = Column(String(20), default="swing") # swing / short_term confidence = Column(Float, default=0) # 置信度 (0-100) trend = Column(String(20), nullable=True) # 趋势方向 - entry_type = Column(SQLEnum(EntryType), default=EntryType.MARKET) # 入场类型 + entry_type = Column(SQLEnum(EntryType, values_callable=lambda x: [e.value for e in x]), default=EntryType.MARKET) # 入场类型 # 订单状态 status = Column(SQLEnum(OrderStatus), default=OrderStatus.PENDING, index=True) diff --git a/update.sh b/update.sh index 4243d97..b08deff 100755 --- a/update.sh +++ b/update.sh @@ -30,7 +30,11 @@ if [ -f "$DB_PATH" ]; then sqlite3 "$DB_PATH" "ALTER TABLE paper_orders ADD COLUMN entry_type VARCHAR(10) DEFAULT 'market';" echo " entry_type 列已添加" else - echo " entry_type 列已存在,跳过" + echo " entry_type 列已存在" + # 修复可能存在的大写值问题 + sqlite3 "$DB_PATH" "UPDATE paper_orders SET entry_type = 'market' WHERE entry_type = 'MARKET';" + sqlite3 "$DB_PATH" "UPDATE paper_orders SET entry_type = 'limit' WHERE entry_type = 'LIMIT';" + echo " entry_type 值已标准化" fi else echo " 数据库文件不存在,将在首次运行时创建"