Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendchildorderでエラーがでてしまいます… #9

Open
sho-yamane opened this issue Dec 5, 2017 · 2 comments
Open

sendchildorderでエラーがでてしまいます… #9

sho-yamane opened this issue Dec 5, 2017 · 2 comments

Comments

@sho-yamane
Copy link

便利なライブラリーのご提供ありがとうございます。

ごくたまになのですが注文sendchildorderをすると以下のようなエラーを吐いてしまいます。

もしよろしければご確認よろしくお願いいたします。

Traceback (most recent call last):
  File "index.py", line 144, in <module>
    bfbot.main()
  File "index.py", line 132, in main
    self.buyBtc()
  File "index.py", line 77, in buyBtc
    time_in_force = "GTC"
  File "/Users/XXXXXX/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pybitflyer/pybitflyer.py", line 481, in sendchildorder
    return self.request(endpoint, "POST", params=params)
  File "/Users/XXXXXX/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pybitflyer/pybitflyer.py", line 60, in request
    content = json.loads(response.content.decode("utf-8"))
  File "/Users/XXXXXX/.pyenv/versions/3.6.0/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/Users/XXXXXX/.pyenv/versions/3.6.0/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/XXXXXX/.pyenv/versions/3.6.0/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@lhsfcboy
Copy link

lhsfcboy commented Feb 9, 2018

bitFlyer did not guarantee that your request will be accepted, even everything is fine.
In your case, I guess its because bitFlyer didnt respond anything to your new order.

It is not a problem of this lib, although it would be nicer to catch these exception inside this lib.
However, it will be a problem of design,
that how much should you expect from this lib.

I think this lib should be used as a pure wrapper of native API,
you should handle above exception in your code.
But again, it will be nicer if we have that response.content in return.

You must check any operation that is out of your control.
You send order and bitFlyer accept it, in this process, you dont know how bitFlyer will respond,
you can only EXPECT their response.
Hence, you must check it.

@nagadomi
Copy link
Contributor

That is an error response from Cloudflare(CDN of API server). When bitflyer's API server is down, API returns that response.
If you want to detect the timeout error more quickly, specify the timeout option.

api = pybitflyer.API(timeout=30)

requests.exceptions.ConnectTimeout or requests.exceptions.ReadTimeout will be raise if there is no response from API server for 30 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants