New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
markets "contractSize" wrong data type #11123
Comments
@xmatthias it may seem like it is the wrong data type but we actually store it as a string on purpose since we need to do stringMaths using contractSize inside of
that's cause you are using floating point maths
I'll update the docs |
@frosty00 the linked commit has 2 issues in my opinion. If you update the datatype, you should also update the sample data -> It's however also wrong in another sense. The documentation section is about the "position structure" -> the position return value - which seems to be a number: ... It makes however the value of I've also been unable to find any instance where contractSize was actually used for string calculations (string calculations to me means The only instances i did find were with |
I think that we should convert |
That's exactly my point here: #11128 (comment) Alternatively (to avoid potentially repeat converting) - maybe keep it in |
Technically we have deprecated floats everywhere already, in other words there is no such things as a float type in ccxt, just |
@frosty00 I must've missed that anouncement - can you point me to it? also, the famous |
That actually looks like a (still open) enhancement request - not an announcement.
As neither of the 2 is true at this point as far as i can see - so i'm sorry, but it's just a wish in my eyes. You can't realistically expect users to take "announcements" from some discussion buried in the 20th comment in a 4 year old issue. |
the support for it isn't complete, basically there is a reason why we have let the numbers in ccxt be customizable. So it's not as simple as "just setting it to a float" cause then the next person will come in and say "why is contractSize a float I want a decimal.Decimal" or whatever type. So that's why the type of our numbers are now |
There's nothing to announce since it isn't complete and the change is backwards compatible |
works for me - but https://docs.ccxt.com/en/latest/manual.html#exchange-structure (nor other documentation pages) even mention this possibility (let me know if you'd like me to raise this as a separate issue to have it as "todo").
Again - works for me, but then I understand the concern about string math internally - but i think there's quite simple workarounds to this, which have been pointed out above.
You mentioned it's deprecated above - which has to be either documented/anounced (so people know about it) - or a personal wish from your side. |
Yeah I think probably we'll need to have a variable called |
Totally agree with @xmatthias and @samgermain on this issue. @frosty00 I think, the correct way to address this is to have both a float and a string in each market and each position. I suggest to revert contractSize to safeNumber (defaulting to a float). We can also add contractSizeString alongside if it's really necessary, but i don't think it is. The values of contractSize are mostly integers and floats up to 8 decimals, which is why we can safely convert those values in place for internal string-based maths and in most cases we don't even have to expose the string-math in the userland. |
the type of contractSize seems to be a string throughout the exchanges I've tested - which seems and feels wrong to me.
Based on the documentation i'd expect it to be a float, which would align the "position structure" with the response of the market response.
I also don't think any value other than a float will be a possible/allowed value for contractSize - as we'd expect to multiply (or divide) by that number to go from amount to what the exchange expects and viceversa.
Having this as string makes all calculations necessary for futures quite odd, as we'll have to do explicitly convert contract-size to number (e.g.
amount * float(market['contractSize'])
).The text was updated successfully, but these errors were encountered: