now downloads historical eix dat
All checks were successful
Deployment / deploy-docker (push) Successful in 14s

This commit is contained in:
Melchior Reimers
2026-01-25 16:44:43 +01:00
parent b4b9e6e48b
commit b9062c5dac
3 changed files with 76 additions and 8 deletions

View File

@@ -45,8 +45,14 @@ def run_task(historical=False):
eix = EIXExchange()
ls = LSExchange()
# Pass last_ts to fetcher to allow smart filtering
# daemon.py runs daily, so we want to fetch everything since DB state
# BUT we need to be careful: eix.py's fetch_latest_trades needs 'since_date' argument
# We can't pass it here directly in the tuple easily because last_ts is calculated inside the loop.
# We will modify the loop below to handle args dynamically
exchanges_to_process = [
(eix, {'limit': None if historical else 1}),
(eix, {'limit': None if historical else 5}), # Default limit 5 for safety if no historical
(ls, {'include_yesterday': historical})
]
@@ -58,7 +64,16 @@ def run_task(historical=False):
last_ts = get_last_trade_timestamp(db_url, exchange.name)
logger.info(f"Fetching data from {exchange.name} (Filtering trades older than {last_ts})...")
trades = exchange.fetch_latest_trades(**args)
# Special handling for EIX to support smart filtering
call_args = args.copy()
if exchange.name == "EIX" and not historical:
call_args['since_date'] = last_ts.replace(tzinfo=datetime.timezone.utc)
# Remove limit if we are filtering by date to ensure we get everything
if 'limit' in call_args:
call_args.pop('limit')
trades = exchange.fetch_latest_trades(**call_args)
# Deduplizierung: Nur Trades nehmen, die neuer sind als der letzte in der DB
new_trades = [
@@ -97,7 +112,10 @@ def main():
logger.info("Database is empty or table doesn't exist. Triggering initial historical fetch...")
run_task(historical=True)
else:
logger.info("Found existing data in database. Waiting for scheduled run at 23:00.")
logger.info("Found existing data in database. Triggering catch-up sync...")
# Run a normal task to fetch any missing data since the last run
run_task(historical=False)
logger.info("Catch-up sync completed. Waiting for scheduled run at 23:00.")
while True:
now = datetime.datetime.now()