This commit is contained in:
aaron 2026-02-08 14:11:35 +08:00
parent 9eacb2243c
commit 2d50d9a990
4 changed files with 22 additions and 14 deletions

View File

@ -198,30 +198,29 @@ async def get_statistics_by_symbol():
async def get_monitor_status(): async def get_monitor_status():
"""获取价格监控状态和实时价格""" """获取价格监控状态和实时价格"""
try: try:
monitor = get_price_monitor_service() from app.config import get_settings
paper_trading = get_paper_trading_service()
# 获取活跃订单的交易对 monitor = get_price_monitor_service()
active_orders = paper_trading.get_active_orders() settings = get_settings()
symbols_needed = set(order.get('symbol') for order in active_orders if order.get('symbol'))
# 始终显示配置的交易对价格
configured_symbols = settings.crypto_symbols.split(',')
# 获取价格 - 优先使用监控服务的缓存价格 # 获取价格 - 优先使用监控服务的缓存价格
latest_prices = dict(monitor.latest_prices) latest_prices = dict(monitor.latest_prices)
# 如果监控服务没有价格数据,直接从 Binance 获取 # 获取所有配置的交易对价格
for symbol in symbols_needed: for symbol in configured_symbols:
symbol = symbol.strip()
if symbol not in latest_prices or latest_prices[symbol] is None: if symbol not in latest_prices or latest_prices[symbol] is None:
price = binance_service.get_current_price(symbol) price = binance_service.get_current_price(symbol)
if price: if price:
latest_prices[symbol] = price latest_prices[symbol] = price
# 注意:止盈止损检查由后台任务 (main.py price_monitor_loop) 处理
# 这里只返回价格数据供前端显示
return { return {
"success": True, "success": True,
"running": True, # 后台任务始终运行 "running": True,
"subscribed_symbols": list(symbols_needed), "subscribed_symbols": configured_symbols,
"latest_prices": latest_prices "latest_prices": latest_prices
} }
except Exception as e: except Exception as e:

View File

@ -103,7 +103,7 @@ class Settings(BaseSettings):
telegram_enabled: bool = True # 是否启用 Telegram 通知 telegram_enabled: bool = True # 是否启用 Telegram 通知
# 加密货币交易智能体配置 # 加密货币交易智能体配置
crypto_symbols: str = "BTCUSDT,ETHUSDT,BNBUSDT,SOLUSDT" # 监控的交易对,逗号分隔 crypto_symbols: str = "BTCUSDT,ETHUSDT" # 监控的交易对,逗号分隔
crypto_analysis_interval: int = 60 # 分析间隔(秒) crypto_analysis_interval: int = 60 # 分析间隔(秒)
crypto_llm_threshold: float = 0.7 # 触发 LLM 分析的置信度阈值 crypto_llm_threshold: float = 0.7 # 触发 LLM 分析的置信度阈值

View File

@ -352,7 +352,7 @@ class CryptoAgent:
return False return False
confidence = signal.get('confidence', 0) confidence = signal.get('confidence', 0)
if confidence < 50: if confidence < 70:
return False return False
# 检查冷却时间30分钟内不重复发送相同方向的信号 # 检查冷却时间30分钟内不重复发送相同方向的信号

View File

@ -6,6 +6,15 @@
<title>模拟交易 - Tradus</title> <title>模拟交易 - Tradus</title>
<link rel="stylesheet" href="/static/css/style.css"> <link rel="stylesheet" href="/static/css/style.css">
<style> <style>
/* 覆盖全局 #app 样式 */
#app {
height: auto;
display: block;
align-items: initial;
justify-content: initial;
padding: 0;
}
.trading-page { .trading-page {
min-height: 100vh; min-height: 100vh;
background: var(--bg-primary); background: var(--bg-primary);