|
@@ -171,11 +171,20 @@ class TradingDashboard:
|
|
|
found_db = True
|
|
found_db = True
|
|
|
break
|
|
break
|
|
|
if not found_db:
|
|
if not found_db:
|
|
|
- if db_path is None:
|
|
|
|
|
|
|
+ # 如果找不到对应日期的数据库,使用最新的可用数据库
|
|
|
|
|
+ available_dbs = self.get_available_databases()
|
|
|
|
|
+ if available_dbs:
|
|
|
|
|
+ db_path = available_dbs[0]['path']
|
|
|
|
|
+ elif db_path is None:
|
|
|
db_path = self.db_path
|
|
db_path = self.db_path
|
|
|
elif db_path is None:
|
|
elif db_path is None:
|
|
|
- db_path = self.db_path
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # 如果没有指定db_path,使用最新的可用数据库
|
|
|
|
|
+ available_dbs = self.get_available_databases()
|
|
|
|
|
+ if available_dbs:
|
|
|
|
|
+ db_path = available_dbs[0]['path']
|
|
|
|
|
+ else:
|
|
|
|
|
+ db_path = self.db_path
|
|
|
|
|
+
|
|
|
if not os.path.exists(db_path):
|
|
if not os.path.exists(db_path):
|
|
|
return []
|
|
return []
|
|
|
|
|
|
|
@@ -230,8 +239,13 @@ class TradingDashboard:
|
|
|
def get_thumbnail_data(self, hours: float = 24, symbol: str = '', db_path: str = None) -> List[Dict[str, Any]]:
|
|
def get_thumbnail_data(self, hours: float = 24, symbol: str = '', db_path: str = None) -> List[Dict[str, Any]]:
|
|
|
"""获取缩略图数据 - 只返回币安价格,每秒最多一条数据"""
|
|
"""获取缩略图数据 - 只返回币安价格,每秒最多一条数据"""
|
|
|
if db_path is None:
|
|
if db_path is None:
|
|
|
- db_path = self.db_path
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # 使用最新的可用数据库
|
|
|
|
|
+ available_dbs = self.get_available_databases()
|
|
|
|
|
+ if available_dbs:
|
|
|
|
|
+ db_path = available_dbs[0]['path']
|
|
|
|
|
+ else:
|
|
|
|
|
+ db_path = self.db_path
|
|
|
|
|
+
|
|
|
if not os.path.exists(db_path):
|
|
if not os.path.exists(db_path):
|
|
|
return []
|
|
return []
|
|
|
|
|
|
|
@@ -278,8 +292,13 @@ class TradingDashboard:
|
|
|
def get_trading_events(self, hours: float = 24, symbol: str = '', db_path: str = None) -> List[Dict[str, Any]]:
|
|
def get_trading_events(self, hours: float = 24, symbol: str = '', db_path: str = None) -> List[Dict[str, Any]]:
|
|
|
"""获取交易事件"""
|
|
"""获取交易事件"""
|
|
|
if db_path is None:
|
|
if db_path is None:
|
|
|
- db_path = self.db_path
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # 使用最新的可用数据库
|
|
|
|
|
+ available_dbs = self.get_available_databases()
|
|
|
|
|
+ if available_dbs:
|
|
|
|
|
+ db_path = available_dbs[0]['path']
|
|
|
|
|
+ else:
|
|
|
|
|
+ db_path = self.db_path
|
|
|
|
|
+
|
|
|
if not os.path.exists(db_path):
|
|
if not os.path.exists(db_path):
|
|
|
return []
|
|
return []
|
|
|
|
|
|
|
@@ -341,8 +360,13 @@ class TradingDashboard:
|
|
|
def get_statistics(self, hours: float = 24, symbol: str = '', db_path: str = None) -> Dict[str, Any]:
|
|
def get_statistics(self, hours: float = 24, symbol: str = '', db_path: str = None) -> Dict[str, Any]:
|
|
|
"""获取统计数据"""
|
|
"""获取统计数据"""
|
|
|
if db_path is None:
|
|
if db_path is None:
|
|
|
- db_path = self.db_path
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # 使用最新的可用数据库
|
|
|
|
|
+ available_dbs = self.get_available_databases()
|
|
|
|
|
+ if available_dbs:
|
|
|
|
|
+ db_path = available_dbs[0]['path']
|
|
|
|
|
+ else:
|
|
|
|
|
+ db_path = self.db_path
|
|
|
|
|
+
|
|
|
if not os.path.exists(db_path):
|
|
if not os.path.exists(db_path):
|
|
|
return {}
|
|
return {}
|
|
|
|
|
|