Fix XAU/USD display name, pip value, and invalid symbol validation

- config.py: add XAU/USD and XAG/USD to SYMBOL_DISPLAY; add PIP_VALUES
  map for commodities (gold pip = $0.01, not $0.0001)
- data_provider.py: use PIP_VALUES in get_pair_info so gold trade setup
  shows correct pip counts instead of 269,000 pips for a $27 SL
- main.py: validate symbols in symbol_from_name — rejects non-alpha
  inputs like '15M' with a helpful hint to use --timeframe instead

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Harwinder
2026-05-04 15:59:34 -04:00
parent a15fc6db91
commit 94b93cf1e7
3 changed files with 29 additions and 9 deletions
+15 -6
View File
@@ -380,11 +380,16 @@ Examples:
def symbol_from_name(name: str) -> str:
"""Convert pair name like 'EURUSD' to Yahoo symbol 'EURUSD=X'."""
name = name.upper().replace("/", "").replace("_", "")
if not name.endswith("=X"):
name += "=X"
return name
"""
Convert pair name like 'EURUSD' or 'XAUUSD' to internal symbol 'EURUSD=X'.
Returns None for clearly invalid inputs (e.g. timeframe strings like '15M').
"""
clean = name.upper().replace("/", "").replace("_", "").replace("=X", "")
if not clean.isalpha() or len(clean) < 5:
print(f" Warning: '{name}' is not a valid pair symbol — skipping.")
print(f" Hint: timeframes go in --timeframe (e.g. --timeframe M15), not --pairs.")
return None
return clean + "=X"
def run_analysis(args) -> List[SignalReport]:
@@ -413,7 +418,11 @@ def run_analysis(args) -> List[SignalReport]:
# Configure pairs
if args.pairs:
config.watch_pairs = [symbol_from_name(p) for p in args.pairs]
symbols = [symbol_from_name(p) for p in args.pairs]
config.watch_pairs = [s for s in symbols if s is not None]
if not config.watch_pairs:
print(" Error: No valid pair symbols provided. Exiting.")
sys.exit(1)
elif args.all:
config.watch_pairs = MAJOR_PAIRS + CROSS_PAIRS
else: