Scan only M15 and H1; keep D1 as confirmation, drop W1 entirely
Trades are intraday (M15/H1) only. D1 stays as a confirmation TF for both so higher-timeframe trend context still gates A/A+ grades. W1 is no longer used anywhere — removes one batch call. Scan now: 3 batch calls (M15, H1, D1) × 7 pairs = 21 credits, ~2 min. Was: 4 batch calls (M15, H1, D1, W1) = 28 credits, ~3 min. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,30 +43,30 @@ After every fetch the data goes through `_validate_and_clean`:
|
||||
|
||||
### Per scan or /signal command
|
||||
|
||||
The bot does **one shared prefetch** before spawning the 4 TF analyses.
|
||||
It collects all unique timeframes needed across all scans, then makes
|
||||
The bot does **one shared prefetch** before spawning TF analyses.
|
||||
It collects all unique timeframes needed across scans, then makes
|
||||
one batch API call per timeframe (all pairs in a single request).
|
||||
|
||||
Current SCAN_TIMEFRAMES: M15, H1, D1, W1
|
||||
Current SCAN_TIMEFRAMES: M15, H1 (only intraday trade signals)
|
||||
Confirmations:
|
||||
- M15 uses: H1, D1
|
||||
- H1 uses: M15, D1
|
||||
- D1 uses: H1, W1
|
||||
- W1 uses: D1
|
||||
|
||||
Unique timeframes: M15, H1, D1, W1 = **4 batch calls**
|
||||
D1 is kept as a confirmation for higher-timeframe trend context but
|
||||
no D1 trade signals are produced. W1 has been dropped entirely.
|
||||
|
||||
Unique timeframes: M15, H1, D1 = **3 batch calls**
|
||||
|
||||
Each call: 7 pairs × 1 credit = **7 credits per call**
|
||||
|
||||
Total per scan: **4 calls × 7 credits = 28 credits**
|
||||
Total per scan: **3 calls × 7 credits = 21 credits**
|
||||
|
||||
With the 8 credits/minute limit:
|
||||
- Call 1 (7 credits): fires immediately — 1 credit remaining
|
||||
- Call 2 (7 credits): must wait ~60s for window to clear
|
||||
- Call 3 (7 credits): waits another ~60s
|
||||
- Call 4 (7 credits): waits another ~60s
|
||||
|
||||
**Minimum scan time: ~3 minutes.**
|
||||
**Minimum scan time: ~2 minutes.**
|
||||
|
||||
After the shared prefetch, the 4 concurrent TF analyses read from
|
||||
the in-memory cache and make **zero additional API calls**.
|
||||
@@ -204,13 +204,12 @@ Telegram /scan or /signal
|
||||
▼
|
||||
_analyze_all_tfs(pairs)
|
||||
│
|
||||
├── prefetch_batch(pairs, [M15, H1, D1, W1])
|
||||
├── prefetch_batch(pairs, [M15, H1, D1])
|
||||
│ ├── Batch call 1: all pairs @ M15 (7 credits, wait if needed)
|
||||
│ ├── Batch call 2: all pairs @ H1 (7 credits, wait if needed)
|
||||
│ ├── Batch call 3: all pairs @ D1 (7 credits, wait if needed)
|
||||
│ └── Batch call 4: all pairs @ W1 (7 credits, wait if needed)
|
||||
│ └── Batch call 3: all pairs @ D1 (7 credits, wait if needed)
|
||||
│
|
||||
└── 4 threads (one per TF), all reading from warm cache
|
||||
└── 2 threads (M15 + H1), all reading from warm cache
|
||||
│
|
||||
└── per thread: SignalAggregator.analyze_all_pairs()
|
||||
│
|
||||
|
||||
+3
-4
@@ -40,20 +40,19 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# ── Config ──────────────────────────────────────────────────────────
|
||||
|
||||
SCAN_TIMEFRAMES = ["M15", "H1", "D1", "W1"]
|
||||
SCAN_TIMEFRAMES = ["M15", "H1"]
|
||||
|
||||
_TF_MAP = {
|
||||
"M5": Timeframe.M5, "M15": Timeframe.M15,
|
||||
"M30": Timeframe.M30, "H1": Timeframe.H1,
|
||||
"H4": Timeframe.H4, "D1": Timeframe.D1,
|
||||
"W1": Timeframe.W1,
|
||||
}
|
||||
|
||||
# D1 kept as confirmation for higher-timeframe trend context.
|
||||
# W1 dropped — only the D1 scan used it, and we no longer scan D1.
|
||||
_TF_CONFIRMATIONS = {
|
||||
"M15": [Timeframe.H1, Timeframe.D1],
|
||||
"H1": [Timeframe.M15, Timeframe.D1],
|
||||
"D1": [Timeframe.H1, Timeframe.W1],
|
||||
"W1": [Timeframe.D1],
|
||||
}
|
||||
|
||||
_GRADE_RANK = {"A+": 0, "A": 1, "B": 2, "C": 3, "D": 4, "F": 5}
|
||||
|
||||
Reference in New Issue
Block a user