s4w3d0ff / python-poloniex

Poloniex API wrapper for Python 2.7 & 3
https://poloniex.com/support/api
GNU General Public License v2.0
568 stars 166 forks source link

Parsing the Buy/Sell #168

Closed who8mypnuts closed 7 years ago

who8mypnuts commented 7 years ago

When I run a function such as return24hVolume and save to a variable, it's very easy to pull out data.

Something like

vol24 = conn.return24hVolume()
print(vol24['USDT_XRP']['XRP']

works perfectly find and as expected.

Yet, when I run the buy function I cannot pull out the data I need. I constantly get key errors or an indice of int can't be str and so on.

I try something like this: newAmount = rst['resultingTrades']['total'] I've also tried wrapping this in float, but neither way works.

What am I doing wrong/missing? Any help is much appreciated as this is very frustrating.

s4w3d0ff commented 7 years ago

The buy/sell/moveOrder api functions will return different data depending on the type of order ('fillOrKill', etc). Sometimes you will get a 'resultingTrades' field, sometimes not if no trades occured and the order was just posted.

I think the order number is always returned (if the order was posted or traded), you best bet would probably to capture the order number and then check returnOrderTrades and/or returnOpenOrders to get more info on the order.

who8mypnuts commented 7 years ago

Interesting take. Thank you for the suggestion. I'll give it a go tomorrow. I have been using a fillOrKill order on this particular one and it's been driving me crazy because the data is there and I can't access it for anything! I can print it out but I can't get to the individual bits.

Thank you again! I'll let you know the result.