-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsymbol_selector.py
More file actions
30 lines (21 loc) · 990 Bytes
/
symbol_selector.py
File metadata and controls
30 lines (21 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## File: symbol_selector.py
import pandas as pd
import os
from config_setup import POSITIVE_CSV, NEGATIVE_CSV, SELECTED_CSV
def select_latest_symbols():
# Load both positive and negative momentum files
pos = pd.read_csv(POSITIVE_CSV, parse_dates=["retrieval_time"])
neg = pd.read_csv(NEGATIVE_CSV, parse_dates=["retrieval_time"])
# Combine and sort by symbol and retrieval_time
combined = pd.concat([pos, neg], ignore_index=True)
# Filter only pure USDT pairs (exclude futures like BTCUSDT-09MAY25)
combined = combined[ combined["symbol"].str.upper().str.endswith("USDT") ]
# For each symbol, pick the row with max retrieval_time
latest = combined.sort_values("retrieval_time").groupby("symbol").tail(1)
# Ensure file does not exist as gzip or binary
if os.path.exists(SELECTED_CSV):
os.remove(SELECTED_CSV)
# Save clean CSV
latest.to_csv(SELECTED_CSV, index=False)
if __name__ == "__main__":
select_latest_symbols()