feat(oi): improve csv loading with caching
Add price caching to prevent repeated file reads and improve performance. Implement multi-path search for CSV files with fallback options. Add comprehensive logging for CSV load success/failure states. Update dashboard to display CSV loading status. Simplify scraper CSV output format and automate file transfer to terminal MQL5 Files directory.
This commit is contained in:
@@ -9,6 +9,7 @@ Requires: pip install -r requirements.txt
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
from datetime import datetime
|
||||
from playwright.sync_api import sync_playwright
|
||||
from dotenv import load_dotenv
|
||||
import pandas as pd
|
||||
@@ -290,9 +291,8 @@ def export_to_csv(df, future_price=0.0):
|
||||
output_path = CSV_OUTPUT_PATH
|
||||
|
||||
with open(output_path, "w") as f:
|
||||
df.to_csv(f, index=False)
|
||||
f.write("\n[Price]\n")
|
||||
f.write(f"FuturePrice,{future_price}\n")
|
||||
f.write("date,future_price\n")
|
||||
f.write(f"{datetime.now().strftime('%Y-%m-%d')},{future_price}\n")
|
||||
|
||||
logger.info(f"Exported OI data and price to {output_path}")
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ call venv\Scripts\activate.bat
|
||||
REM Run Python scraper
|
||||
python main.py
|
||||
|
||||
MOVE "oi_data.csv" "C:\Users\limitrack\AppData\Roaming\MetaQuotes\Terminal\53785E099C927DB68A545C249CDBCE06\MQL5\Files\"
|
||||
|
||||
|
||||
echo.
|
||||
echo Scraper completed. Check oi_data.csv for results.
|
||||
timeout /t 5
|
||||
|
||||
Reference in New Issue
Block a user