Ccxt: LiveCoin can't create a limit order

Created on 7 Oct 2017  ·  36Comments  ·  Source: ccxt/ccxt

import ccxt
exchange1 = ccxt.livecoin ({
"apiKey": "blablabla",
"secret": "blablalba",
"verbose": True,
})

poloniex.load_products ()

print (exchange1.create_limit_sell_order ('LTC/BTC', 0.0114,0.0114))

C:\Python35\python.exe C:/Users/1/PycharmProjects/untitled1/165.py
https://api.livecoin.net/exchange/ticker GET https://api.livecoin.net/exchange/ticker
Request: {'User-Agent': 'ccxt/1.9.49 (+https://github.com/kroitor/ccxt) Python/3.6.2', 'Accept-Encoding': 'gzip, deflate'} None
Traceback (most recent call last):
File "C:/Users/1/PycharmProjects/untitled1/165.py", line 8, in
print (exchange1.create_limit_sell_order ('LTC/BTC', 0.0114,0.0114))
File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 918, in create_limit_sell_order
return self.create_order(symbol, 'limit', 'sell', *args)
File "C:\Python35\lib\site-packages\ccxt\exchanges.py", line 13846, in create_order
self.load_markets()
File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 686, in load_markets
markets = self.fetch_markets()
File "C:\Python35\lib\site-packages\ccxt\exchanges.py", line 13731, in fetch_markets
markets = self.publicGetExchangeTicker()
File "C:\Python35\lib\site-packages\ccxt\exchanges.py", line 13888, in request
response = self.fetch2(path, api, method, params, headers, body)
File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 228, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 281, in fetch
print(method, url, "\nResponse:", response.info().headers, decoded_text)
AttributeError: 'HTTPMessage' object has no attribute 'headers'

Process finished with exit code 1

All 36 comments

Hi! Thx for reporting this, I'll take a look into it asap.

Ok, I fixed the error reporting in Python3, but LiveCoin looks like it's on maintenance now...

ccxt.errors.ExchangeNotAvailable: livecoin POST https://api.livecoin.net/exchange/selllimit 503 
Service Temporarily Unavailable  (possible reasons: invalid API keys, bad or old nonce, exchange is down or offline, on maintenance, DDoS protection, rate-limiting, 
{"success":false,"errorCode":503,"errorMessage":"Service is under maintenance"})
  1. Can you please update to version 1.9.54+ and retry the same code to check if the output is clear now?
  2. Also, can you try to place the order with livecoin website and compare it to the output of ccxt?
  3. Can you fetch the balance from livecoin with ccxt?

Need to verify the above to leave no room for an error, and to make sure their private API is working.

We will stand by for a report from you. Thx!

Wow, thank you for fast answer! But i cant test now. LiveCoin in maintenance now.

Log now:

C:\Python35\python.exe C:/Users/1/PycharmProjects/untitled1/165.py
https://api.livecoin.net/exchange/ticker GET https://api.livecoin.net/exchange/ticker 
Request: {'User-Agent': 'ccxt/1.9.54 (+https://github.com/kroitor/ccxt) Python/3.6.2', 'Accept-Encoding': 'gzip, deflate'} None
GET https://api.livecoin.net/exchange/ticker 
Response: Server: nginx
Date: Sat, 07 Oct 2017 11:27:04 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
X-Powered-By: Undertow/1
X-Frame-Options: SAMEORIGIN
Content-Encoding: gzip
Strict-Transport-Security: max-age=31536000
......
{"cur":"VIB","symbol":"VIB/BTC","last":0.00005400,"high":0.10000001,"low":0.00003300,"volume":5186599.36872169,"vwap":0.00006703,"max_bid":0.10000001,"min_ask":0.00001121,"best_bid":0.00005400,"best_ask":0.00005550}]
https://api.livecoin.net/exchange/buylimit POST https://api.livecoin.net/exchange/buylimit 
Request: {'Api-Key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxh', 'Sign': '9CA6218CBFE280F5xxxxxxxxxxxxxxxxxx86D239DB', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'ccxt/1.9.54 (+https://github.com/kroitor/ccxt) Python/3.6.2', 'Accept-Encoding': 'gzip, deflate'} currencyPair=LTC%2FBTC&price=0.0109&quantity=0.01
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 259, in fetch
    response = opener.open(request, timeout=int(self.timeout / 1000))
  File "C:\Python35\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "C:\Python35\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python35\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "C:\Python35\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Python35\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Temporarily Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/1/PycharmProjects/untitled1/165.py", line 9, in <module>
    print (exchange1.create_limit_buy_order ('LTC/BTC', 0.01,0.0109))
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 915, in create_limit_buy_order
    return self.create_order(symbol, 'limit', 'buy', *args)
  File "C:\Python35\lib\site-packages\ccxt\exchanges.py", line 13864, in create_order
    response = getattr(self, method)(self.extend(order, params))
  File "C:\Python35\lib\site-packages\ccxt\exchanges.py", line 13898, in request
    response = self.fetch2(path, api, method, params, headers, body)
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 228, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 266, in fetch
    self.handle_rest_errors(e, e.code, text, url, method)
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 314, in handle_rest_errors
    self.raise_error(error, url, method, exception if exception else str(http_status_code), details)
  File "C:\Python35\lib\site-packages\ccxt\exchange.py", line 213, in raise_error
    details,
ccxt.errors.ExchangeNotAvailable: livecoin POST https://api.livecoin.net/exchange/buylimit 503 Service Temporarily Unavailable  (possible reasons: invalid API keys, bad or old nonce, exchange is down or offline, on maintenance, DDoS protection, rate-limiting, {"success":false,"errorCode":503,"errorMessage":"Service is under maintenance"})

Process finished with exit code 1

Ok, let's wait and retry later then? ) Livecoin is on maintenance too often... I'll stand by for more info from you. Thx!

(Can you check if you're able to open the same order with their website?)

Yes, i can now open this order manually.

And can fetch any info about pair and other market data.

@mazertwo ok, then I'll have to investigate further into this. Thx for your involvement, I'll get back to you asap!

Can YoBit block me for made orders via API if i change security parameters? 48 hours?

@mazertwo yes, if you hit their rateLimit, described here:

https://github.com/ccxt-dev/ccxt/wiki/Manual#rate-limit
https://github.com/ccxt-dev/ccxt/wiki/Manual#overriding-the-nonce

Though, I don't think it's 48 hours. If they blocked you, try a proxy: https://github.com/ccxt-dev/ccxt/wiki/Install#proxy to see if this is bound to your API key or to your IP address. Also, you can retry in an hour to see if that changed, they may be blocking some countries during periods of high load, then unblocking them again.

Here's a few examples on how to do periodic requests (aka long-polling) without hitting the rate limit:
https://github.com/ccxt-dev/ccxt/blob/master/examples/py/tickers.py
https://github.com/ccxt-dev/ccxt/blob/master/examples/py/fetch-ohlcv-sequentially.py
https://github.com/ccxt-dev/ccxt/blob/master/examples/py/async-generator-ticker-poller.py

You should stay below rate limit to avoid ban.

I can get any data from Livecoin via API, but cant made orders via API.

@mazertwo does fetch_balance work?

Yes

@mazertwo then give me some more time on this, plz. I'll be back.

terminator

- -2

@mazertwo did you have a chance to try their API with any other software previously? Looks like a common problem, though, I'm still investigating...

screen shot 2017-10-07 at 19 19 35

No, just via ccxt. Strange problem.

@mazertwo ok, here's their Python 2.7 example from their website, can you try it? I'll do the same. Edit the price, volume and keys below:

import httplib
import urllib
import json
import hashlib
import hmac
from collections import OrderedDict

server = "api.livecoin.net"
method = "/exchange/buylimit"
api_key = "gJx7Wa7qXkPtmTAaK3ADCtr6m5rCYYMy"
secret_key = "8eLps29wsXszNyEhOl9w8dxsOsM2lTzg"

data = OrderedDict(sorted([('currencyPair', 'BTC/USD'),('price', '100'),('quantity', '0.01')]))

encoded_data = urllib.urlencode(data)

sign = hmac.new(secret_key, msg=encoded_data, digestmod=hashlib.sha256).hexdigest().upper()

headers = {"Api-key": api_key, "Sign": sign, "Content-type": "application/x-www-form-urlencoded"}

conn = httplib.HTTPSConnection(server)
conn.request("POST", method, encoded_data, headers)

response = conn.getresponse()
data = json.load(response)
conn.close()

print data

The above script replies 503 to me... And you?

Me too...

@mazertwo so, it seems like a permanent Livecoin issue with their API, not the library? Can you open a ticket with their support? If their own example fails, then they have a problem with their API... I sent my request to them, but got no reply for now. Would be great if you double the effort, so, maybe, together we can wake them up...

@mazertwo one thing to clarify: when trying, you did replace the credentials in the script above for your own keypair, right?

Sure, i put my keypair. LiveCoin support is so sloooow. 1-2 weeks for answer.

My native language is russian. Sorry for my bad english.

@mazertwo По-русски мы тоже понимаем, не стесняйся :)

@mazertwo yeah, but, I'm afraid, only Livecoin guys themselves can resolve this issue for us...
No problem with your English at all, it's all clear! Thx for your answers btw! Really helpful! I suggest, let's open a ticket and wait... Even if they reply in 2 weeks, it's better than nothing. Can you skip Livecoin and go on with your other tasks within ccxt for now? If you don't mind, I would close this issue until they reply, and then I'll get back to you, or maybe you will have better luck and notify us all quicker. How's that for you?

I have same error with 'ETH/BTC' and other pairs in LiveCoin exchange. Not only with 'LTC/BTC'.

xpl, рад приветствовать вас и всю команду!

(but we prefer English for everyone else's convenience)

@mazertwo

I have same error with 'ETH/BTC' and other pairs in LiveCoin exchange. Not only with 'LTC/BTC'.

Yeah, looks like a broken endpoint on their side... So, what do you think on my suggestion above?

I connect with support via ticket.

Ok, I'm closing this for now, let's wait for their reply, if I get one, I'll update you here. Feel free to reopen it anytime, if you have any other questions! Thx again!

Good news, @mazertwo! The cause of the problem was finally found and fixed in 1.9.273+. So, Livecoin limit orders should work normally now. Plz, let us know if you still have problems with it after upgrading. Thx!

One more minor fix added in 1.9.273. So, this issue should be resolved completely now.

Now, that's all. I hope it will be useful and my help was useful to you @kroitor )

@DeeDab it was, indeed! Thx a lot for your involvement!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scoshil picture scoshil  ·  39Comments

janeCMD picture janeCMD  ·  35Comments

hexeraction picture hexeraction  ·  40Comments

stonemonk picture stonemonk  ·  34Comments

barthr picture barthr  ·  37Comments