VermeirJellen / PoloniexR

R wrapper for the Poloniex Cryptocurrency Trading API (Package)
Other
19 stars 4 forks source link

Unable to connect to https://poloniex.com/tradingApi? (422) #4

Open aranmariaines opened 6 years ago

aranmariaines commented 6 years ago

Hi,

Thanks for posting the PoloniexR package! I have issues with the PoloniexTradingApi command. PoloniexPublicAPI works ok.

When I try to run ReturnBalances, ProcessTradingRequest, etc I get this error: Unable to connect to https://poloniex.com/tradingApi? (422)

My API Key and secret are ok and "Enable trading" option is turned on in Poloniex. I used them to get info from my balance with Python and worked ok.

Any idea of what is going on?

Thank you in advance!

NM.

luyongxu commented 6 years ago

I'm experiencing the same problem. Did you find out what was wrong?

VermeirJellen commented 6 years ago

Hey guys,

Sorry for the late reply.

You are getting back a "422: non processable entity" status code from the Poloniex servers.

Possible problem: Poloniex expects the request nonces from subsequent calls to be in ascending order. You are using Python and R calls interchangeably, and your request nonces are most likely not generated in the same manner across both languages. You explain that your Python calls are functional. This would mean that the nonces that are used/generated in your Python calls are always greater than the nonces of your R calls. This causes the R calls to be rejected by the Poloniex servers.

Solution:

The first option is probably the easiest because the R package generates the nonces in a transparant manner so that the users don't need to bother with it manually.

If you do decide to change your Python code , the increasing R nonce is generated using the following logic:

round(as.numeric(Sys.time()) * 1e4, 0)
luyongxu commented 6 years ago

Generating a new key secret pair solved the problem for me. Thank you for a great package.

aranmariaines commented 6 years ago

Hi! Sorry for the delay. I created a new key API Key and it worked ok! Thank you very much

iamraybao commented 6 years ago

I'm having this same issue, but only when I use the @commands$buy command. Sell orders seem to be working perfectly fine, as is other commands. I have no other applications using this key (which was freshly-generated).

Error in ProcessTradingRequest(poloTrade, command = poloTrade@commands$buy,  : 
  Unable to connect to https://poloniex.com/tradingApi (422)

Any ideas?

luyongxu commented 6 years ago

Does your buy order's amount have too much precision? Poloniex only accepts up to 8 decimal points of precision when specifying the amount. I had this problem and it took me a little while to figure out.

iamraybao commented 6 years ago

@luyongxu This did the trick. Thx!