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

BITBANK sell and buy order error occured OSError: [Errno 22] Invalid argument #2775

Closed
k31ww475 opened this issue May 7, 2018 · 22 comments
Closed
Assignees

Comments

@k31ww475
Copy link

k31ww475 commented May 7, 2018

Hi I can't sell and buy order using bitbank.

  • OS:win10
  • Programming Language version: python3.6
  • CCXT version:latest
  • Exchange:bitbank
  • Method:

the command line is follow
exchange.create_limit_sell_order('BTC/JPY', 0.001, 1000000)

error target source is follow

exchange.create_limit_buy_order ('BTC/JPY', amount, ask_price)
exchange.create_limit_sell_order ('BTC/JPY', amount, bid_price)
amount is 0.001
ask_price is 1000000
bid_price is 1000000

and I confirmed and successed accurate order on pgm ,when I bought and sold the order the exchage "BITFLYER" in same pgm.So it seems bitbank's interface problem.

The error occured like that
`OSError: [Errno 22] Invalid argument`

detail of error

Traceback (most recent call last):
  File "C:/pythonfiles//pr2.py", line 80, in <module>
    exchange.create_limit_sell_order(target_currency, amount, bid_price)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 1258, in create_limit_sell_order
    return self.create_order(symbol, 'limit', 'sell', *args)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 312, in create_order
    order = self.parse_order(response['data'], market)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 281, in parse_order
    'datetime': self.iso8601(timestamp),
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 669, in iso8601
    utc = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
OSError: [Errno 22] Invalid argument

Process finished with exit code 1
@kroitor
Copy link
Member

kroitor commented May 7, 2018

detail of error

We need the full verbose output without your keys. I don't really understand how you've missed it in that text that says that you should post verbose output and you didn't, you just posted the error callstack again (( You see, if it was enough, I wouldn't ask you about verbose output in #1252 in the first place. That means that the output you've posted isn't enough and there's no need to duplicate it, I need much more of it (another piece of it, above the error).

Once again, we need to see the full request and response, not just the error – we need all the verbose output, but without your keys.

exchange.verbose = True  # ←-----------  ADD THIS !

exchange.create_limit_buy_order ('BTC/JPY', amount, ask_price)
exchange.create_limit_sell_order ('BTC/JPY', amount, bid_price)

↑ Run it in like that in verbose mode, then post everything that is printed on screen, except your keys, here. Also mind that it will again create the order, so you might want to cancel it manually, while we are debugging this issue.

@kroitor kroitor self-assigned this May 7, 2018
@sakurai-youhei
Copy link

FYI: I found similar post here https://teratail.com/questions/125060, that seems like multi-posting...

@kroitor
Copy link
Member

kroitor commented May 7, 2018

@sakurai-youhei i guess the teratail website just copies all github content or displays it directly with github API, not related to this issue.

@sakurai-youhei
Copy link

@kroitor Unfortunately, someone looks to ask his/her own question at teratail as well as here, meaning teratail is not replica of github. teratail is a kind of domestic and standalone Q&A site like stackoverflow and that's why I reached this page when I had been trying to help his/her error.

@sakurai-youhei
Copy link

Anyway, you can of course ignore my writing noise here; My apologies for bothering you.

@kroitor
Copy link
Member

kroitor commented May 7, 2018

@sakurai-youhei got it, no worries, thx!

@k31ww475
Copy link
Author

k31ww475 commented May 7, 2018

Hi.Thanx for your early reply.
I tried to run add the pgm that you teach me "exchange.verbose = True"
But same error occured like that.

target source

exchange = eval('ccxt.' + ask_exchange + '()')
exchange.apiKey = exchanges[ask_exchange]["apiKey"]
exchange.secret = exchanges[ask_exchange]["secret"]

exchange.verbose = True  # ←-----------  ADDED
exchange.create_limit_buy_order (target_currency, amount, ask_price)←-----------  FAILURE

The error

  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/xxx/xxx.py", line 115, in <module>
    exchange.create_limit_buy_order (target_currency, amount, ask_price)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 1255, in create_limit_buy_order
    return self.create_order(symbol, 'limit', 'buy', *args)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 312, in create_order
    order = self.parse_order(response['data'], market)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 281, in parse_order
    'datetime': self.iso8601(timestamp),
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 669, in iso8601
    utc = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
OSError: [Errno 22] Invalid argument

and I attached the shot the point the pgm stopped.
001

target code
utc = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))

Request: POST https://api.bitbank.cc/v1/user/spot/order {'Content-Type': 'application/json', 'ACCESS-KEY': 'hogehoge', 'ACCESS-NONCE': 'hogehoge', 'ACCESS-SIGNATURE': 'hogehogehoge', 'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} {"pair":"btc_jpy","amount":"0.001","price":"1014365.00000000","side":"buy","type":"limit"}

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1664, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1658, in main
Response: POST https://api.bitbank.cc/v1/user/spot/order 200 {'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '274', 'Connection': 'keep-alive', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, token', 'Access-Control-Allow-Methods': 'POST, GET', 'Content-Security-Policy': "default-src 'none';frame-ancestors 'self';base-uri 'none';form-action 'none'", 'Date': 'Mon, 07 May 2018 08:04:16 GMT', 'ETag': 'W/"112-/hogehoge"', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Server': 'nginx', 'Strict-Transport-Security': 'max-age=31536000;includeSubDomains;preload', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 hogehoge.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'hogehoge'} {"success":1,"data":{"order_id":hogehoge,"pair":"btc_jpy","side":"buy","type":"limit","start_amount":"0.00100000","remaining_amount":"0.00100000","executed_amount":"0.00000000","price":"1014365.0000","average_price":"0.0000","ordered_at":hogehoge,"status":"UNFILLED"}}
    globals = debugger.run(setup['file'], None, None, is_module)

@k31ww475
Copy link
Author

k31ww475 commented May 7, 2018

Once again, we need to see the full request and response, not just the error – we need all the verbose output, but without your keys.

OK.I wrote the request and response detail.

@k31ww475 k31ww475 changed the title BITBANK sell and buy order BITBANK sell and buy order error occured OSError: [Errno 22] Invalid argument May 7, 2018
@k31ww475
Copy link
Author

k31ww475 commented May 7, 2018

Also I could ordered in ""bitflyer"" using follow pgm.It was success.
But ""bitbank's"" result was failure.

bitflyer:SUCCESS
bitbank:NG

the target source orders of market and limit

limit_ordered_info = exchange_api.create_order(symbol=target_currency, type='limit', side='BUY', amount=amount, price=500000)
print(json.dumps(limit_ordered_info, indent=True))

market_ordered_info = exchange_api.create_market_buy_order(symbol=target_currency, amount=amount)
print(json.dumps(market_ordered_info, indent=True))

@k31ww475
Copy link
Author

k31ww475 commented May 7, 2018

Dear Mr.kroitor

Once again, we need to see the full request and response, not just the error – we need all the verbose output, but without your keys.

I attached the error follow.Of course I wrote the command like that
exchange_api.verbose = True

C:\Users\XXX\AppData\Local\Programs\Python\Python36\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port XXXXX --file C:/XXX/pr2.py
pydev debugger: process XXXXX is connecting

Connected to pydev debugger (build 181.4668.75)

Request: POST https://api.bitbank.cc/v1/user/spot/order {'Content-Type': 'application/json', 'ACCESS-KEY': 'XXX', 'ACCESS-NONCE': 'XXX', 'ACCESS-SIGNATURE': 'XXX', 'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} {"pair":"btc_jpy","amount":"0.001","price":"500000.00000000","side":"BUY","type":"limit"}
Traceback (most recent call last):

File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1664, in
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev\pydevd.py", line 1068, in run
Response: POST https://api.bitbank.cc/v1/user/spot/order 200 {'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '35', 'Connection': 'keep-alive', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, token', 'Access-Control-Allow-Methods': 'POST, GET', 'Content-Security-Policy': "default-src 'none';frame-ancestors 'self';base-uri 'none';form-action 'none'", 'Date': 'Mon, 07 May 2018 10:07:17 GMT', 'ETag': 'W/"XXX"', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Server': 'nginx', 'Strict-Transport-Security': 'max-age=XXX;includeSubDomains;preload', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 XXX.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'XXX'} {"success":0,"data":{"code":40021}}
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/XXX/pr2.py", line 103, in
limit_ordered_info = exchange_api.create_order(symbol=target_currency, type='limit', side='BUY', amount=amount, price=500000)
File "C:\Users\XXX\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 310, in create_order
response = self.privatePostUserSpotOrder(self.extend(request, params))
File "C:\Users\XXX\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 496, in request
raise ErrorClass(message)
ccxt.base.errors.InvalidOrder: The trading classification is invalid

Process finished with exit code 1

Thanks in advance.

@kroitor
Copy link
Member

kroitor commented May 7, 2018

@k31ww475 ok, now I see it, thx! Will debug it and will get back to you on this issue soon.

@kroitor
Copy link
Member

kroitor commented May 7, 2018

@k31ww475 does fetch_balance work for you?

import ccxt
exchange = ccxt.bitbank({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
})
print(exchange.fetch_balance())

?

@k31ww475
Copy link
Author

k31ww475 commented May 8, 2018

@kroitor
Yes.It works.

@k31ww475
Copy link
Author

k31ww475 commented May 8, 2018

Target source

    market_ordered_info = exchange.create_market_buy_order(
                         symbol=target_currency,
                         amount=target_amount,
                         )

The error is follow
bitbank createOrder requires a price argument for both market and limit orders

@kroitor
Copy link
Member

kroitor commented May 8, 2018

bitbank createOrder requires a price argument for both market and limit orders

It says that you have to provide a price for whatever order you're making, but you're not providing a price in your request to create a market buy order – you're submitting just the symbol and the amount.

@k31ww475
Copy link
Author

k31ww475 commented May 8, 2018

Exactly.and I set the price in this code like that but the different error still occured.

market_ordered_info = exchange.create_market_buy_order(
                         symbol=target_currency,
                         amount=target_amount,
                         price=1000000 >>>>>>>>>> added the line,
                         )

ERROR

 price=1000000,
TypeError: create_market_buy_order() got an unexpected keyword argument 'price'

12121

@kroitor
Copy link
Member

kroitor commented May 8, 2018

@k31ww475 ok, will debug it further and will get back to you shortly.

@k31ww475
Copy link
Author

k31ww475 commented May 8, 2018

@kroitor Thanx lots.

@k31ww475
Copy link
Author

k31ww475 commented May 14, 2018

@kroitor
Hi.I seached the bug,when we ordered(buy and sell) in bitbank using ccxt.
After we ordered in bitbank using ccxt,I confirmed these order(sell and buy) successed on website bitbank.
But the error occured like below and PROCESS that pgm had ran will be shut down ,that's why it's seems to bug of ccxt.

ERROR

 File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 312, in create_order
    order = self.parse_order(response['data'], market)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\bitbank.py", line 281, in parse_order
    'datetime': self.iso8601(timestamp),
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 669, in iso8601
    utc = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
OSError: [Errno 22] Invalid argument

TARGET CODE

    if bid_exchange == "bitbank":
        limit_ordered_info_sold = exchange[2].create_order(
            symbol="BTC/JPY"
            type='limit',
            side='sell',
            amount=0.001,
            price=1500000

Thanks in advance

@k31ww475
Copy link
Author

k31ww475 commented May 14, 2018

@kroitor

OSError: [Errno 22] Invalid argument

Also it's some kind of pass/directory setting problem.
And I already confirmed accurate result the other exchange in my wrote program except for bitbank.

    if bid_exchange == "bitbank":
        limit_ordered_info_sold = exchange[2].create_order(
            symbol="BTC/JPY"
            type='limit',
            side='sell',
            amount=0.001,
            price=1500000

kroitor added a commit that referenced this issue May 20, 2018
@k31ww475
Copy link
Author

k31ww475 commented May 20, 2018

I changed the target code by python.but it ""different"" error occured.

error

raise ExchangeError(self.id + ' ' + self.json(response))
ccxt.base.errors.ExchangeError: bitbank {"success":0,"data":{"code":60005}}

@kroitor
Copy link
Member

kroitor commented May 20, 2018

I changed the target code by python.but it ""different"" error occured.

Can you please post your code and verbose output again ? We need to see how you changed the code.

For the code: please, make it a complete shortest possible program to reproduce the issue. Don't swallow the lines, we need the entire code that doesn't want to work (10-20 lines), including the instantiation from the beginning to the end, but without your keys. If your code is too big – make it a short example snippet and make sure it works up to the point of error. Do not post one-liners, please.

For the output: we need to see the verbose output of both the request and the response.

Whenever you have ANY error or ANY problem, please post your code+verbose output for that error, otherwise it will be very hard to help you and we will ask for the data anyway. So, if you don't want to waste your time and you want to get your problem solved quickly, then follow the rules from here precisely: https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue

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