This commit is contained in:
lz_db
2025-12-05 13:25:26 +08:00
parent efbcb63cec
commit 64c993319a
8 changed files with 205 additions and 17 deletions

View File

@@ -361,9 +361,10 @@ class RedisClient:
for account_info in account_list:
k_id = int(account_info['k_id'])
st_id = account_info.get('st_id', 0)
add_time = account_info.get('add_time', 0)
# 从Redis获取账户信息数据
account_data = await self._get_account_info_from_redis(k_id, st_id, exchange_id)
account_data = await self._get_account_info_from_redis(k_id, st_id, exchange_id, add_time)
account_data_list.extend(account_data)
logger.debug(f"交易所 {exchange_id}: 收集到 {len(account_data_list)} 条账户信息")
@@ -373,7 +374,7 @@ class RedisClient:
return account_data_list
async def _get_account_info_from_redis(self, k_id: int, st_id: int, exchange_id: str) -> List[Dict]:
async def _get_account_info_from_redis(self, k_id: int, st_id: int, exchange_id: str, add_time: int) -> List[Dict]:
"""从Redis获取账户信息数据批量优化版本"""
try:
redis_key = f"{exchange_id}:balance:{k_id}"
@@ -383,7 +384,7 @@ class RedisClient:
return []
# 按天统计数据
recent_days = SYNC_CONFIG['recent_days']
recent_days = SYNC_CONFIG['recent_days_account']
today = datetime.now()
date_stats = {}
@@ -394,14 +395,18 @@ class RedisClient:
fund_data = json.loads(fund_json)
date_str = fund_data.get('lz_time', '')
lz_type = fund_data.get('lz_type', '')
add_time_str = helpers.convert_timestamp(add_time,format_str='%Y-%m-%d')
if date_str < add_time_str:
continue
if not date_str or lz_type not in ['lz_balance', 'deposit', 'withdrawal']:
continue
# 只处理最近N天的数据
date_obj = datetime.strptime(date_str, '%Y-%m-%d')
if (today - date_obj).days > recent_days:
continue
if recent_days != 0:
if (today - date_obj).days > recent_days:
continue
if date_str not in date_stats:
date_stats[date_str] = {
@@ -554,7 +559,7 @@ class RedisClient:
"""从Redis获取最近N天的订单数据"""
try:
redis_key = f"{exchange_id}:orders:{k_id}"
recent_days = SYNC_CONFIG['recent_days']
recent_days = SYNC_CONFIG['recent_days_order']
# 计算最近N天的日期
today = datetime.now()
recent_dates = []