sammchardy / python-kucoin

Kucoin REST and Websocket API python implementation
https://python-kucoin.readthedocs.io/en/latest/
MIT License
352 stars 148 forks source link

Getting weird results when trying to create buy orders? #7

Closed ghost closed 6 years ago

ghost commented 6 years ago

Trying to create a very simple buy on Kucoin

 order = kucoin.create_buy_order("NEO-BTC", 0.00930911, 0.5)
 print(order)

This would not place the order, and I would get.

{'coinType': 'BTC', 'expect': 0.00465456, 'actual': 0.00146454}

as a response.

Originally I thought the issue had to do with precision size, and I tried accounting for that in both my rate and my amount, which did not work.

However, if I try placing an order on a coin which I can buy a full value of (Don't have funds for a full NEO ATM)

        order = kucoin.create_buy_order("PBL-BTC", 0.00018314, 1)

Everything works great, order is placed.

However, if I were to buy less or more than 1 coin, such as 1.1 or .99, my order becomes "None", and no other output is available. Other times it will spit out the error like the one I provided above.

Any ideas?

ghost commented 6 years ago

This seems to probably be an issue in my end. I'm not sure.

I also tried withdrawing,

 withdraw = kucoin.create_withdrawal('ENJ', str(110), address)

and I recieve an error like

{'coinType': 'ENJ', 'expect': 110.0, 'actual': 0.0}

I'm unsure what to do at this point. Time for some classic sleepdebugging.

sammchardy commented 6 years ago

Hi @RyanDelap running through your examples now.

One thing to note, make sure your quantity and price values are strings, rather than floats.

lacot5 commented 6 years ago

I get None with any buy order with an amount below 1 (0.1, 0.9, 0.99). Anything above 1 is ok. This happens using str and float as well EDIT: I was hitting minimal amount, sorry for the post

sammchardy commented 6 years ago

@RyanDelap this message indicates that you're trying to buy 0.5 NEO at 0.00930911 BTC, which would cost 0.00465456 BTC, however it's saying you actually only have 0.00146454 BTC in your account.

The library wasn't handling this type of error response properly, so I've released v0.1.4 which handles this properly.

ghost commented 6 years ago

@sammchardy Thank you for the response and update!

Through some trial an error I determined another issue I was having was the precision not being accurate. I'm updating this just incase anyone has this issue in the future.