How to buy with Poloniex API?


Hi I have a question about buy method. Recently I received successful message from Poloniex I run once buy order method with option immediateOrCancel. I get two trades instead of the expected one.

{'orderNumber': '269159954730', 'amountUnfilled': '0.00000000', 'resultingTrades': [{'total': '0.00323034', 'tradeID': '16775174', 'amount': '0.10364748', 'rate': '0.03116670', 'date': '2018-04-22 10:59:11', 'type': 'buy'}, {'total': '0.05271018', 'tradeID': '16775175', 'amount': '1.68942915', 'rate': '0.03120000', 'date': '2018-04-22 10:59:11', 'type': 'buy'}]}

Could someone help me with that or say why it's happend?


Posted 2018-04-23T12:54:48.760

Reputation: 21

Question was closed 2018-05-23T06:34:42.163



What was your purchase amount set at? 0.03120000??

It would appear that you tried to buy at 0.03120000

however as there was a sell order already placed at 0.03116670 you filled that order first, then completed your buy with the rest of the amount at the 0.03120000


Posted 2018-04-23T12:54:48.760

Reputation: 457

11,77 but it bought 1,79 amount of currency. So your answer helped me a lot, thanks. In the order book didn't be offer to complete exactly that amount. I bought aproximetely amount. – mrberner – 2018-04-24T08:57:21.467

Another question is that which price should be chosen as opening price? if my offer would have 3 resultingTrades, I can each amount add together and have control over it. But I have three diffrent rates. – mrberner – 2018-04-24T10:24:14.153

Your opening price is set by you when u make the buy order at that amount. If someone posts a lower offer you will fill these orders first, but this will not be seen as an opening price. I believe you only have control over the amount u specify to buy at (ie your opening price) – Fuzzybear – 2018-04-24T10:42:08.413

hmm, I set opening price through passing it to function from this wrapper here There is buy(amount, rate, orderType) Of course I can control amount, and opening price from resultingTrades, but there will be different rates depend on how much trade will fill my entire amount. Rate from response on successful trade is necessary to achieve provided strategy. But you said that I only have control over amount, true because not always my rate and amount will be available in order book.

– mrberner – 2018-04-24T11:26:10.980