gs-quant icon indicating copy to clipboard operation
gs-quant copied to clipboard

[BUG] gs_quant python entity Country not working

Open LeoWu64 opened this issue 2 years ago • 2 comments
trafficstars

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:

  • OS: Windows 10
  • Python version
  • GS-Quant version 1.0.3

Additional context Add any other context about the problem here.

LeoWu64 avatar Jul 19 '23 09:07 LeoWu64

I would like to be assigned to this issue

jtranquilli avatar Sep 25 '23 22:09 jtranquilli

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.

jtranquilli avatar Sep 26 '23 00:09 jtranquilli