luno / luno-python

Python SDK for the Luno API
MIT License
63 stars 35 forks source link

Invalid value error #47

Open MrBlindMouse opened 2 years ago

MrBlindMouse commented 2 years ago

Hi Guys, While trying to post a market order using the following, cl.post_market_order(min_name, 'BUY', base_account_id=buy_id, counter_volume=float(truncate(buy_val,buy_scale)), counter_account_id=btc_id) I get the error: ('ErrInvalidValue', 'Invalid value provided for counter_volume')

I'm buying on the pair 'ADAXBT'

The value is above the indicated min value and truncated to the indicated precision as per: https://api.luno.com/api/exchange/1/markets

I have no idea what could be wrong.

Help please!!!

Kind Regards MrBlindMouse

MrBlindMouse commented 2 years ago

Hi, I need some help here!

After some testing a bit it looks like this only happens with the ADAXBT trading pair when 'BUY'ing with the post_market_order() function as stated above.

I've tried with the 'SOLXBT' and 'XRPXBT' pairs as well and they seem to worked fine.

sanari1 commented 1 year ago

Hi MrBlindMouse

just out of curiosity what is the value of float(truncate(buy_val,buy_scale) if you had to print it out? is it above the minimum volume amount?

MrBlindMouse commented 1 year ago

Hi Sanari, Thanx for responding. The float value in that case was 0.0000897. I do not have the ADAXBT price from then but if I had to uses the current price the total volume would be 4.7.

The minimum volume for the ADAXBT trading pair is 1.0

sanari1 commented 1 year ago

Are you trying to buy ADA or XBT? I'm a novice but will try and help

MrBlindMouse commented 1 year ago

It's a buy function, so XBT

MrBlindMouse commented 1 year ago

Sorry, misstyped. Buying ADA, with XBT as the counter volume

sanari1 commented 1 year ago

Have you tried rounding down the volume from say 4.701 to 4.70 as an example

Thats the issue I had https://github.com/luno/luno-python/issues/35

MrBlindMouse commented 1 year ago

Yes, that is what the truncate function does. ADA needs to be trunced to 1 decimal and XBT to 8? I believe but the docs does not say what the counter_value needs to be scaled to

sanari1 commented 1 year ago

would it not be min_price : 0.000001 and the number can't be higher than max_price : 0.01 so 0.00000x?

MrBlindMouse commented 1 year ago

I thought so as well, but I now believe those are the limits for the actual price, ie 1 ADA sells for 0.0000188 XBT at the moment. So when the market crashes or explodes then trading is forced close.

And even if they are really the counter_volume limits, the value I used falls within that range

sanari1 commented 1 year ago

are you sure truncate function is rounding down and not up ie 0.018 becomes 0.02 when it needs to become 0.01

MrBlindMouse commented 1 year ago

Yes, thats what truncate does. It cuts the decimal instead of rounding up or down. Python will sometimes give strange results when trying to round.

sanari1 commented 1 year ago

I will try when I get home this evening buying and see if I have any issues

sanari1 commented 1 year ago

Having the same issue on my side... suspect something hasn't been implemented yet.

echarrod commented 2 months ago

Hi both 👋 Sincere apologies that no-one from Luno got back to you on this one. I know it's been a while, but are you still experiencing the same issue?