添加新币对和优化拉取
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user