pythainav
pythainav copied to clipboard
case insensitive
🚀 Feature Request
case insensitive in key name
🔈 Motivation
got the error when doing nav.get() with the lowercase of the fund name. Could we convert it to the required case? It will make library more robust.
>>> nav.get('scbnk225d')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xxx/git/tmp/temp/venv-tmp/lib/python3.10/site-packages/pythainav/api.py", line 45, in get
nav = _source.get(fund_name, date)
File "/home/xxx/git/tmp/temp/venv-tmp/lib/python3.10/site-packages/pythainav/sources.py", line 56, in get
url.args["fund"] = name2fund[fund]["id"]
KeyError: 'scbnk225d'
>>> nav.get('SCBNK225D')
Nav(value=13.1079, updated=datetime.datetime(2022, 12, 28, 0, 0), tags={'latest'}, fund='SCBNK225D')