sammchardy / python-kucoin

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

No Margin trade support? #77

Open psychoMLM opened 3 years ago

psychoMLM commented 3 years ago

I searched documentation and there is no mentions on margin trades.

kehrli commented 3 years ago

You can make margin trades by copying his procedure, calling his _post method and changing the endpoint.
Example: Copy his create_market_order procedure in full. At the bottom he calls: return self._post('orders', True, data=data) change your procedure to read return ._post('margin/order', True, data=data)

Notice that the only difference is the endpoint. They work the same. I've been working with margin orders successfully with this method.

psychoMLM commented 3 years ago

How would i state level of margin like a 4x margin?

kehrli commented 3 years ago

Actually, I didn't confront borrowing or repaying via the api. I borrowed and repaid through the KuCoin web interface. I just used python-kucoin to buy and sell with funds already in the margin account. I think there is a way to buy, with "auto-borrow", but you would have to do the calculations for 4x margin yourself.

In general, it's pretty easy to make calls to kucoin's api by copying the procedures you'll find in python-kucoin, and tailoring them to what you need.