BitMEX / sample-market-maker

Sample BitMEX Market Making Bot
Apache License 2.0
1.7k stars 758 forks source link

ERROR - bitmex - Unhandled Error: 403 Client Error: Forbidden for url: https://testnet.bitmex.com/api/v1/order/bulk #218

Open adelorenzo opened 4 years ago

adelorenzo commented 4 years ago

Hello,

I ran the code and got the following error message:

2020-06-18 11:58:13,851 - INFO - market_maker - BitMEX Market Maker Version: v1.1

2020-06-18 11:58:13,854 - INFO - ws_thread - Connecting to wss://testnet.bitmex.com/realtime?subscribe=quote:XBTUSD,trade:XBTUSD,instrument,order:XBTUSD,execution:XBTUSD,margin,position
2020-06-18 11:58:13,854 - INFO - ws_thread - Authenticating with API Key.
2020-06-18 11:58:13,857 - INFO - ws_thread - Started thread
2020-06-18 11:58:14,862 - INFO - ws_thread - Connected to WS. Waiting for data images, this may take a moment...
2020-06-18 11:58:17,664 - INFO - ws_thread - Got all market data. Starting.
2020-06-18 11:58:17,665 - INFO - market_maker - Using symbol XBTUSD.
2020-06-18 11:58:17,665 - INFO - market_maker - Order Manager initializing, connecting to BitMEX. Live run: executing real trades.
2020-06-18 11:58:17,665 - INFO - market_maker - Resetting current position. Canceling all existing orders.
2020-06-18 11:58:17,665 - INFO - bitmex - sending req to https://testnet.bitmex.com/api/v1/order: {"filter": "{\"ordStatus.isTerminated\": false, \"symbol\": \"XBTUSD\"}", "count": 500}
2020-06-18 11:58:19,507 - INFO - market_maker - XBTUSD Ticker: Buy: 9389.5, Sell: 9390.0
2020-06-18 11:58:19,507 - INFO - market_maker - Start Positions: Buy: 9343.0, Sell: 9436.4, Mid: 9390.0
2020-06-18 11:58:19,508 - INFO - market_maker - Current XBT Balance: 0.096507
2020-06-18 11:58:19,508 - INFO - market_maker - Current Contract Position: 0
2020-06-18 11:58:19,509 - INFO - market_maker - Contracts Traded This Run: 0
2020-06-18 11:58:19,509 - INFO - market_maker - Total Contract Delta: 0.0000 XBT
2020-06-18 11:58:19,510 - INFO - market_maker - Creating 12 orders:
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 100 @ 9436.5
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 200 @ 9483.5
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 300 @ 9531.0
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 400 @ 9578.5
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 500 @ 9626.5
2020-06-18 11:58:19,511 - INFO - market_maker - Sell 600 @ 9674.5
2020-06-18 11:58:19,511 - INFO - market_maker -  Buy 100 @ 9343.0
2020-06-18 11:58:19,512 - INFO - market_maker -  Buy 200 @ 9296.5
2020-06-18 11:58:19,512 - INFO - market_maker -  Buy 300 @ 9250.5
2020-06-18 11:58:19,512 - INFO - market_maker -  Buy 400 @ 9204.5
2020-06-18 11:58:19,512 - INFO - market_maker -  Buy 500 @ 9158.5
2020-06-18 11:58:19,512 - INFO - market_maker -  Buy 600 @ 9113.0
2020-06-18 11:58:19,514 - INFO - bitmex - sending req to https://testnet.bitmex.com/api/v1/order/bulk: {"orders": [{"price": 9113.0, "orderQty": 600, "side": "Buy", "clOrdID": "mm_bitmex_JiIB4lv3Soy6/nldx6IIvA", "symbol": "XBTUSD"}, {"price": 9158.5, "orderQty": 500, "side": "Buy", "clOrdID": "mm_bitmex_gK9nJDMiQf2dNVR2/XTqtA", "symbol": "XBTUSD"}, {"price": 9204.5, "orderQty": 400, "side": "Buy", "clOrdID": "mm_bitmex_4dgkhB2FQ3GKFZxNlRs89A", "symbol": "XBTUSD"}, {"price": 9250.5, "orderQty": 300, "side": "Buy", "clOrdID": "mm_bitmex_YLnQROUKSuycx5qibgH0bw", "symbol": "XBTUSD"}, {"price": 9296.5, "orderQty": 200, "side": "Buy", "clOrdID": "mm_bitmex_U/kU55hLQPOYrQ0c/8LH4w", "symbol": "XBTUSD"}, {"price": 9343.0, "orderQty": 100, "side": "Buy", "clOrdID": "mm_bitmex_3KSXhQTfS8+9YOYm4jkVcg", "symbol": "XBTUSD"}, {"price": 9674.5, "orderQty": 600, "side": "Sell", "clOrdID": "mm_bitmex_yQwzoL+6SJaU+GkuFzZUWQ", "symbol": "XBTUSD"}, {"price": 9626.5, "orderQty": 500, "side": "Sell", "clOrdID": "mm_bitmex_39BeHhpqRJ6ja46Ke+CdvQ", "symbol": "XBTUSD"}, {"price": 9578.5, "orderQty": 400, "side": "Sell", "clOrdID": "mm_bitmex_9Ox1s8oOSKGCvKL2AqGUgA", "symbol": "XBTUSD"}, {"price": 9531.0, "orderQty": 300, "side": "Sell", "clOrdID": "mm_bitmex_WafIWqBRRSGt6i2lAlFQ6Q", "symbol": "XBTUSD"}, {"price": 9483.5, "orderQty": 200, "side": "Sell", "clOrdID": "mm_bitmex_Kb6i8asySxW7sRluIQXx8w", "symbol": "XBTUSD"}, {"price": 9436.5, "orderQty": 100, "side": "Sell", "clOrdID": "mm_bitmex_BZBdfebxTU+r6RyPdjcYlw", "symbol": "XBTUSD"}]}
2020-06-18 11:58:19,733 - ERROR - bitmex - Unhandled Error: 403 Client Error: Forbidden for url: https://testnet.bitmex.com/api/v1/order/bulk: {"error":{"message":"Access Denied","name":"HTTPError"}}
2020-06-18 11:58:19,733 - ERROR - bitmex - Endpoint was: POST order/bulk: {"orders": [{"price": 9113.0, "orderQty": 600, "side": "Buy", "clOrdID": "mm_bitmex_JiIB4lv3Soy6/nldx6IIvA", "symbol": "XBTUSD"}, {"price": 9158.5, "orderQty": 500, "side": "Buy", "clOrdID": "mm_bitmex_gK9nJDMiQf2dNVR2/XTqtA", "symbol": "XBTUSD"}, {"price": 9204.5, "orderQty": 400, "side": "Buy", "clOrdID": "mm_bitmex_4dgkhB2FQ3GKFZxNlRs89A", "symbol": "XBTUSD"}, {"price": 9250.5, "orderQty": 300, "side": "Buy", "clOrdID": "mm_bitmex_YLnQROUKSuycx5qibgH0bw", "symbol": "XBTUSD"}, {"price": 9296.5, "orderQty": 200, "side": "Buy", "clOrdID": "mm_bitmex_U/kU55hLQPOYrQ0c/8LH4w", "symbol": "XBTUSD"}, {"price": 9343.0, "orderQty": 100, "side": "Buy", "clOrdID": "mm_bitmex_3KSXhQTfS8+9YOYm4jkVcg", "symbol": "XBTUSD"}, {"price": 9674.5, "orderQty": 600, "side": "Sell", "clOrdID": "mm_bitmex_yQwzoL+6SJaU+GkuFzZUWQ", "symbol": "XBTUSD"}, {"price": 9626.5, "orderQty": 500, "side": "Sell", "clOrdID": "mm_bitmex_39BeHhpqRJ6ja46Ke+CdvQ", "symbol": "XBTUSD"}, {"price": 9578.5, "orderQty": 400, "side": "Sell", "clOrdID": "mm_bitmex_9Ox1s8oOSKGCvKL2AqGUgA", "symbol": "XBTUSD"}, {"price": 9531.0, "orderQty": 300, "side": "Sell", "clOrdID": "mm_bitmex_WafIWqBRRSGt6i2lAlFQ6Q", "symbol": "XBTUSD"}, {"price": 9483.5, "orderQty": 200, "side": "Sell", "clOrdID": "mm_bitmex_Kb6i8asySxW7sRluIQXx8w", "symbol": "XBTUSD"}, {"price": 9436.5, "orderQty": 100, "side": "Sell", "clOrdID": "mm_bitmex_BZBdfebxTU+r6RyPdjcYlw", "symbol": "XBTUSD"}]}
2020-06-18 11:58:19,734 - INFO - market_maker - Shutting down. All open orders will be cancelled.
2020-06-18 11:58:19,734 - INFO - market_maker - Resetting current position. Canceling all existing orders.
2020-06-18 11:58:19,734 - INFO - bitmex - sending req to https://testnet.bitmex.com/api/v1/order: {"filter": "{\"ordStatus.isTerminated\": false, \"symbol\": \"XBTUSD\"}", "count": 500}
2020-06-18 11:58:21,134 - INFO - ws_thread - Websocket Closed

It only works with DRY_RUN=True. My API keys allow Order/Cancel. Please advise.

Thank you!

dni commented 4 years ago

same :) any infos?

dni commented 4 years ago

ok i found the problem, you need to set "Order" Key Permission on your API KEY, i didn't had that and its needed.

mwithi commented 3 years ago

ok i found the problem, you need to set "Order" Key Permission on your API KEY, i didn't had that and its needed.

worked for me, I was using a "Order Cancel" API KEY, I misunderstood their usage, which is described here.