cppkiteconnect icon indicating copy to clipboard operation
cppkiteconnect copied to clipboard

Issue in isValid() function

Open kushsharma2910 opened this issue 3 years ago • 5 comments

This happened when I was trying to send a limit order in live market where isValid() returned false for DEFAULTDOUBLE as defined in the project.

For reproducing the issue checkout https://github.com/kushsharma2910/tmp-cppkiteconnect-bug-check/tree/nullValsComp.

It seems that use of comparison operator == returns false value. Instead using std::isnan() function of the cmath library gives the correct output.

Could you please take a look? Maybe I am missing something here.

I am using c++11 on ubuntu 20.

kushsharma2910 avatar Apr 24 '22 08:04 kushsharma2910

Hey. thank you for reporting this. I'll take a look and update here.

Unfortunately, IIRC, std::isnan() gives compilation errors on Windows. I'll have to find some other way.

bhumitattarde avatar Apr 24 '22 19:04 bhumitattarde

#44 should work as long as the compiler doesn't optimize the comparison. I realize this is fragile but right now, it seems to be the best way to move forward without dropping Windows support or doing a big (and breaking) change.

bhumitattarde avatar Apr 24 '22 20:04 bhumitattarde

Just to understand, according to the usage, we want to return true if default value was passed. for eg.

if (!isValid(price)) { bodyParams.emplace_back("price", std::to_string(price)); }

but now, I think, the condition would flip. I am missing something?

kushsharma2910 avatar Apr 25 '22 02:04 kushsharma2910

You seem to be correct. I'll check this.

bhumitattarde avatar Apr 25 '22 03:04 bhumitattarde

This will be fixed in v2.

bhumitattarde avatar May 18 '22 12:05 bhumitattarde

isValid is phased out in v2.

bhumitattarde avatar Jan 17 '23 12:01 bhumitattarde