-
Notifications
You must be signed in to change notification settings - Fork 193
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
What am I doing wrong here, I have followed all steps correctly #15
Comments
hey, not sure entirely, I'll look at it again when I get the chance but this line: requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order are you able to place an order on Bitmex through the API without the bot? What does your action function look like? (omitting key and info) |
import ccxt def parse_webhook(webhook_data):
def calc_price(given_price):
def send_order(data):
|
I am running on EC2 Amazon AWS |
EDIT: Fixed my Market order stuff. Just had to remove calc_price(data['price'] from actions.py Same problem here, all setup so far, doing a "limit" order works fine on bitmex testnet - no issues can give buy/sell oders just fine. But as soon i want to use "market" orders, im getting this:
Testing with: |
ualenvs/trading-hnTPjx37/bin/activate
(trading) ubuntu@ip-172-31-34-546:~/tradingview/trading$ python webhook-bot.py
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
127.0.0.1 - - [08/Mar/2020 17:22:51] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [08/Mar/2020 17:22:51] "GET /favicon.ico HTTP/1.1" 404 -
[Alert Received]
POST Received: {'type': 'market', 'side': 'sell', 'amount': '10', 'symbol': 'BTC/USD', 'price': 'None', 'key': '292f4a2921fa2153eb13862c051448f5b4e8fffeedee33ww'}
Sending: BTC/USD market sell 10 None
[2020-03-08 17:30:04,045] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 539, in fetch
response.raise_for_status()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "webhook-bot.py", line 35, in webhook
send_order(data)
File "/home/ubuntu/tradingview/trading/actions.py", line 49, in send_order
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1079, in create_order
response = self.privatePostOrder(self.extend(request, params))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 435, in inner
return entry(_self, **inner_kwargs)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 458, in request
return self.fetch2(path, api, method, params, headers, body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 454, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 551, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1154, in handle_errors
raise BadRequest(feedback)
ccxt.base.errors.BadRequest: bitmex {"error":{"message":"'price' must be a number.","name":"HTTPError"}}
127.0.0.1 - - [08/Mar/2020 17:30:04] "POST /webhook HTTP/1.1" 500 -
[Alert Received]
POST Received: {'type': 'market', 'side': 'sell', 'amount': '10', 'symbol': 'BTC/USD', 'price': 'None', 'key': '292f4a2921fa2153eb13862c051448f5b4e87caf04ba0287999f68bc'}
Sending: BTC/USD market sell 10 None
[2020-03-08 17:30:11,478] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 539, in fetch
response.raise_for_status()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "webhook-bot.py", line 35, in webhook
send_order(data)
File "/home/ubuntu/tradingview/trading/actions.py", line 49, in send_order
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1079, in create_order
response = self.privatePostOrder(self.extend(request, params))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 435, in inner
return entry(_self, **inner_kwargs)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 458, in request
return self.fetch2(path, api, method, params, headers, body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 454, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 551, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1154, in handle_errors
raise BadRequest(feedback)
ccxt.base.errors.BadRequest: bitmex {"error":{"message":"'price' must be a number.","name":"HTTPError"}}
127.0.0.1 - - [08/Mar/2020 17:30:11] "POST /webhook HTTP/1.1" 500 -
[Alert Received]
POST Received: {'type': 'market', 'side': 'sell', 'amount': '10', 'symbol': 'BTC/USD', 'price': 'None', 'key': '292f4a2921fa2153eb13862c051448f5b4e87caf04ba0287999f68bc'}
Sending: BTC/USD market sell 10 None
[2020-03-08 17:30:18,889] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 539, in fetch
response.raise_for_status()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "webhook-bot.py", line 35, in webhook
send_order(data)
File "/home/ubuntu/tradingview/trading/actions.py", line 49, in send_order
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1079, in create_order
response = self.privatePostOrder(self.extend(request, params))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 435, in inner
return entry(_self, **inner_kwargs)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 458, in request
return self.fetch2(path, api, method, params, headers, body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 454, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 551, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1154, in handle_errors
raise BadRequest(feedback)
ccxt.base.errors.BadRequest: bitmex {"error":{"message":"'price' must be a number.","name":"HTTPError"}}
127.0.0.1 - - [08/Mar/2020 17:30:18] "POST /webhook HTTP/1.1" 500 -
[Alert Received]
POST Received: {'type': 'market', 'side': 'sell', 'amount': '10', 'symbol': 'BTC/USD', 'price': 'None', 'key': '292f4a2921fa2153eb13862c051448f5b4e87caf04ba0287999f68bc'}
Sending: BTC/USD market sell 10 None
[2020-03-08 17:30:26,319] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 539, in fetch
response.raise_for_status()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "webhook-bot.py", line 35, in webhook
send_order(data)
File "/home/ubuntu/tradingview/trading/actions.py", line 49, in send_order
order = exchange.create_order(data['symbol'], data['type'], data['side'], data['amount'], calc_price(data['price']))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1079, in create_order
response = self.privatePostOrder(self.extend(request, params))
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 435, in inner
return entry(_self, **inner_kwargs)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 458, in request
return self.fetch2(path, api, method, params, headers, body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 454, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/base/exchange.py", line 551, in fetch
self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File "/home/ubuntu/.local/share/virtualenvs/trading-hnTPjx37/lib/python3.7/site-packages/ccxt/bitmex.py", line 1154, in handle_errors
raise BadRequest(feedback)
ccxt.base.errors.BadRequest: bitmex {"error":{"message":"'price' must be a number.","name":"HTTPError"}}
127.0.0.1 - - [08/Mar/2020 17:30:26] "POST /webhook HTTP/1.1" 500 -
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account Enock (Plan: Free)
Version 2.3.35
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://60fb567d.ngrok.io -> http://localhost:5000
Forwarding https://60fb567d.ngrok.io -> http://localhost:5000
Connections ttl opn rt1 rt5 p50 p90
10 0 0.01 0.01 2.03 2.08
HTTP Requests
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
POST /webhook 500 INTERNAL SERVER ERROR
The text was updated successfully, but these errors were encountered: