goldmansachs / gs-quant

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

RiskMeasure - how to check for equality : RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate returns False #124

Open AlexanderJHall opened 4 years ago

AlexanderJHall commented 4 years ago

Describe the bug RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate Returns False. Arguably this should return True.

What is the correct way to check for RiskMeasure equality?

For example: RiskMeasure.from_dict(IRFwdRate.as_dict()).measure_type == IRFwdRate.measure_type returns True, but this feels a little clunky.

I ask as I'd like to write code like: if risk_measure in (IRFwdRate, IRSpotRate, etc, etc):

where risk_measure has been created by RiskMeasure.from_dict(some_measure.as_dict()).

To Reproduce from gs_quant.risk import IRFwdRate from gs_quant.target.risk import RiskMeasure RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate

Returns False.

Expected behavior RiskMeasure.from_dict(IRFwdRate.as_dict()) == IRFwdRate to return True.

OR please explain how I should compare RiskMeasure types

AlexanderJHall commented 4 years ago

@AnastasiyaB Any thoughts on this? RiskMeasure.from_dict(IRFwdRate.as_dict()) != IRFwdRate feels a bit icky...