File size: 266 Bytes
2aaf2a2
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import yfinance as yf


def get_usd_sgd_rate():
    try:
        fx = yf.download('USDSGD=X', period='5d', interval='1d')
        if not fx.empty:
            return float(fx['Close'][-1])
    except Exception:
        pass
    return 1.0  # fallback to 1 if failed