添加新币对和优化拉取

This commit is contained in:
jackyu66git
2025-11-13 01:50:12 +08:00
parent ac845ccfd0
commit 602e37f695
8 changed files with 391 additions and 102 deletions
+12
View File
@@ -3,6 +3,7 @@ import threading
from typing import List, Optional
import pandas as pd
import pyarrow.dataset as ds
_lock = threading.Lock()
@@ -55,3 +56,14 @@ def get_last_timestamp(base_dir: str, symbol: str, timeframe: str) -> Optional[i
return int(df["timestamp"].iloc[-1])
def read_candle_exact(base_dir: str, symbol: str, timeframe: str, timestamp: int) -> pd.DataFrame:
p = _path(base_dir, symbol, timeframe)
if not os.path.exists(p):
return pd.DataFrame(columns=["timestamp", "open", "high", "low", "close", "volume"])
dataset = ds.dataset(p, format="parquet")
table = dataset.to_table(filter=ds.field("timestamp") == int(timestamp))
if table.num_rows == 0:
return pd.DataFrame(columns=["timestamp", "open", "high", "low", "close", "volume"])
return table.to_pandas()