goldmansachs / gs-quant

Python toolkit for quantitative finance
https://developer.gs.com/discover/products/gs-quant/
Apache License 2.0
6.21k stars 784 forks source link

[BUG] gs_quant python entity Country not working #273

Open LeoWu64 opened 11 months ago

LeoWu64 commented 11 months ago

Describe the bug country entity only work with lower-case non-space country name

To Reproduce

from gs_quant.entities.entity import Country, Subdivision
from gs_quant.markets.securities import Asset, AssetIdentifier

for cty in ['taiwan', 'Taiwan', 'china', 'united states', 'United Kingdom']:
    print( cty, ': ', Country.get(cty, Country.Identifier.NAME) )

Expected behavior all countries should be found

Screenshots image

Systems setup:

Additional context Add any other context about the problem here.

jtranquilli commented 9 months ago

I would like to be assigned to this issue

jtranquilli commented 9 months ago

I'll be submitting a pull request that solves this issue in a minute. The 'Country' class, found in in 'entity.py', inherits its 'get' method from the 'Entity' class. I was able to solve this issue with seemingly no averse effects by adding in 'id_value = id_value.lower()' on line 114 of 'entity.py', thereby converting all potentially malicious inputs to be lowercase, as the functionalities of the Country class expect them to be.