-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Hi! I'm new to open source and would like to ask for guidance before submitting a PR.
I've encountered an issue where Indian stock tickers such as M&M.NS fail to parse because the & character is not allowed.
Reference: https://finance.yahoo.com/quote/M&M.NS/
Current behavior:
$ python -m beanprice.price -e 'INR:yahoo/M&M.NS'usage: bean-price [-h] [-e] [-v] [-d DATE] [--update] [--update-rate {daily,weekday,weekly}] [--update-compress UPDATE_COMPRESS] [-i] [-u] [-c] [-a]
[-s] [-w WORKERS] [-n] [--cache CACHE_FILENAME] [--no-cache] [--clear-cache]
sources [sources ...]
bean-price: error: Invalid source "INR:yahoo/M&M.NS". Supported format is "CCY:module/SYMBOL"
Proposed fix:
In beanprice/price.py line 167, add & to the allowed characters in the regex:
Before:
match = re.match(r"([a-zA-Z]+[a-zA-Z0-9\._]+)/(\^?)([a-zA-Z0-9:=_\-\.\(\)]+)$", source)After:
match = re.match(r"([a-zA-Z]+[a-zA-Z0-9\._]+)/(\^?)([a-zA-Z0-9:=_\-\.\(\)&]+)$", source)I tested this change locally, and it resolves the issue for M&M.NS.
This would require updating one test case in price_test.py (line 377), which currently expects yahoo/CNYUSD&X to be invalid.
Would the maintainers be open to accepting a PR with this change? I understand that & in ticker symbols is very uncommon, but it is required for certain international markets such as India.
Thank you!