{"id":39150975,"url":"https://github.com/darkerego/bmcli","last_synced_at":"2026-01-17T21:39:56.737Z","repository":{"id":37637622,"uuid":"265705641","full_name":"darkerego/bmcli","owner":"darkerego","description":"Python3 Powered Bitmex API Command Line Tool","archived":false,"fork":false,"pushed_at":"2025-09-11T05:40:41.000Z","size":11778,"stargazers_count":10,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-11T08:51:56.110Z","etag":null,"topics":["bitmex","bitmex-api","bitmex-python","bitmex-websocket","bitmexbot","crytpocurrency","exchanges","python3","trailing-stops"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darkerego.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-05-20T23:12:50.000Z","updated_at":"2025-09-11T05:40:39.000Z","dependencies_parsed_at":"2025-09-11T07:28:57.860Z","dependency_job_id":null,"html_url":"https://github.com/darkerego/bmcli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darkerego/bmcli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkerego%2Fbmcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkerego%2Fbmcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkerego%2Fbmcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkerego%2Fbmcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkerego","download_url":"https://codeload.github.com/darkerego/bmcli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkerego%2Fbmcli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28518659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitmex","bitmex-api","bitmex-python","bitmex-websocket","bitmexbot","crytpocurrency","exchanges","python3","trailing-stops"],"created_at":"2026-01-17T21:39:56.143Z","updated_at":"2026-01-17T21:39:56.722Z","avatar_url":"https://github.com/darkerego.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#BMCLI - Bitmex Api Tool\n\n~ Darkerego, 2019 - 2020\n\nETH: 0x2474AD6c3EBAFcb981b1E639263E90cC68a404Bb\n\n### BITMEX SUCKS. COME TO [GMX](https://app.gmx.io/#/trade/?ref=thankssbf)\n\n======\n\n## About:\n\n\u003cp\u003e\nBmcli is a python3 powered, command line API tool for interacting with the Bitmex \nexchange. It is intended to make manual trading easier and more profitable by \nautomating some of the things that traders do all of the time and offering some \nunique features such as \u003ci\u003eorder chasing\u003c/i\u003e and built in trailing stop functionality \nwhich does not use on Bitmex's trailing stop feature -- this is because bimex's stop's \nsometimes don't execute on time or properly due to 'system overload', or whatever.\n\u003c/p\u003e\n\n## Features:\n- *NEW* -- Intergrated [Sybrain](https://github.com/5ymph0en1x/SyBrain/blob/master/sybrain.py) by\n[5ymph0en1x](https://github.com/5ymph0en1x) as **Scalp Engine** (`--scalp --size 100`)\n- Create long/short limit/market/post/etc orders\n- Check account balance\n- Get current position\n- AutoStop - Watch for new positions and automatically set a stop loss, and trigger \na trailing stop when the price goes a user defined percentage upwards. \n- Trailing Stops - Custom python implementation of trailing stop functionality\n- Limit Order Chasing - Chase your order up or down the books, amending the price \nso that it is at the top of the orderbook to ensure not paying the market fee and \nentering a position. Optionally use `chase_failsafe` to revert to a market order \nif the `max chase` variable is exceeded. \n\n## Install Deps:\n\n\u003cpre\u003e\n$ pip3 install -r requirements.txt\n\u003c/pre\u003e\n\n## Usage:\n\n\u003cpre\u003e\n$ ./bmcli.py -h\nusage: Please see the README.md file on https://github.com/isdrupter/bmcli\n\noptional arguments:\n  -h, --help            show this help message and exit\n\nRest API Functions:\n  -b, --balance         Get Balance\n  -p, --position        Get Position\n  -P PNL, --pnl PNL     Get Un/Realized PNL of specified symbol \u003c--pnl XBTUSD\u003e\n\nGeneral Options:\n  -s SYMBOL, --symbol SYMBOL\n                        Symbol of instrument\n  -k, --keys            Use instrument dict from conf.py to determinewhich api\n                        keys to use\n\nFlags for creating orders.:\n  -o {limit,market,post,stop,stop_limit,limit_if_touched}, --order {limit,market,post,stop,stop_limit,limit_if_touched}\n                        Place an order\n  -q QUANTITY, --qty QUANTITY, -oq QUANTITY\n                        Quantity for orders placed. Use negative value to open\n                        a short position.\n  --price PRICE, -op PRICE\n                        Price for limit or post orders (if required.\n  --stop_px STOP_PX     Stop price for stop orders.\n  --peg PEGOFFSETVALUE, --pegoffsetvalue PEGOFFSETVALUE\n                        PegOffsetValue for LimitIfTouched orders.\n\nOrder Chasing:\n  -c CHASE, --chase CHASE\n                        Limit Order Chase this quantity \u003c--chase -100 -s\n                        ETHUSD\u003e\n  -F, --chase_failsafe  Revert to market if max chase exceeded.\n  -M MAX_CHASE, --max_chase MAX_CHASE\n                        Max limit chase in dollar value.\n\nAuto/Trailing Stop Options:\n  -t TRAILING_STOP, --trailing_stop TRAILING_STOP\n                        Place a trailing stop order with this offset. \u003c-t\n                        10.0\u003e\n  -a AUTOSTOP AUTOSTOP AUTOSTOP, --auto_stop AUTOSTOP AUTOSTOP AUTOSTOP\n                        Autostop Loss, Trailing Stop. Example -a 0.015 0.03 25\n                        (Stop loss at 15 percent +/- entry price, enable\n                        trailing stop at 30 percent +/- entry price, close\n                        position when price drops 25 dollars +/- trailing stop\n                        price.) See documentation for more details.\n  -l, --limit_order, --limit\n                        Use limit orders for trailing stops. Warning: not\n                        recommended except for experienced traders.\n  -C CHASE_TS, --chase_ts CHASE_TS\n                        Use limit order chasing with trailing stops. Specify\n                        max chase like \u003c-C 3.0\u003e\n\n\u003c/pre\u003e\n\n\u003cp\u003e\nFirst, edit `lib/conf.py` (updated: edit `bmexlib/config.json`) and add your api keys. Next, it is stronly recommended \nto activate the virtual env because I have modified the libraries to stop those \nstupid swagger client warnings:\n\u003c/p\u003e\n\u003cpre\u003e\n$ . venv/bin/activate\n\u003c/pre\u003e\n\n\u003cp\u003e\nEventually, this program will consist of a deamon that runs the ws and rest api, and an interface, maybe over RCP, MqTT, \nor whatever to send commands. Currently, you need multiple API keys to run multiple instances/operations with your account \nat once. I map each api key/secret pair to the instruments, or currencies -- i.e. I have one for XBT and one for ETH. See \nconfig.example.json.\n\u003c/p\u003e\n\n###### Check Balance:\n\n\u003cpre\u003e\n$ python3 ./bmcli.py -b\n[+] Balance: 1417332\n\u003c/pre\u003e\n\n### Sample Output\n\n###### Get Current position\n\n\u003cpre\u003e\n$ python3 ./bmcli.py -p -s ETHUSD\n[+] Position: 2000\n\u003c/pre\u003e\n\n###### Create Order\n\u003cpre\u003e\n./bmcli -o limit -q 100 -s XBTUSD\nINFO:lib.bitmex_api_lib:quote {'symbol': 'XBTUSD', 'id': 8799047500, 'side': 'Sell', 'size': 1539179, 'price': 9525.0}\nSending buy order for 100.0 at 9525.0 , order type: limit\n[*] ({'orderID': '9945cbf4-10af-9a14-1d28-419d25a7481b', 'clOrdID': '', 'clOrdLinkID': '', 'account': 'xxxxxx', 'symbol': 'XBTUSD', 'side': 'Buy', 'simpleOrderQty': None, 'orderQty': 100, 'price': 9525.0, 'displayQty': None, 'stopPx': None, 'pegOffsetValue': None, 'pegPriceType': '', 'currency': 'USD', 'settlCurrency': 'XBt', 'ordType': 'Limit', 'timeInForce': 'GoodTillCancel', 'execInst': '', 'contingencyType': '', 'exDestination': 'XBME', 'ordStatus': 'Filled', 'triggered': '', 'workingIndicator': False, 'ordRejReason': '', 'simpleLeavesQty': None, 'leavesQty': 0, 'simpleCumQty': None, 'cumQty': 100, 'avgPx': 9524.5, 'multiLegReportingType': 'SingleSecurity', 'text': 'bmx_api_tool', 'transactTime': datetime.datetime(2020, 5, 20, 23, 20, 33, 286000, tzinfo=tzutc()), 'timestamp': datetime.datetime(2020, 5, 20, 23, 20, 33, 286000, tzinfo=tzutc())}, \u003cbravado.requests_client.RequestsResponseAdapter object at 0x7f29c6868550\u003e)\n\n\u003c/pre\u003e\n\n###### Order Chase\n\n\u003cpre\u003e\n$ python3 ./bmcli.py -c -q 100 -M 1\nINFO:exchange_lib.bitmex_ws:Connecting to wss://www.bitmex.com/realtime?subscribe=execution:XBTUSD,instrument:XBTUSD,order:XBTUSD,position:XBTUSD,quote:XBTUSD,trade:XBTUSD,margin\nINFO:exchange_lib.bitmex_ws:Authenticating with API Key.\nINFO:exchange_lib.bitmex_ws:Connected to WS.\nINFO:exchange_lib.bitmex_ws:Got all market data. Starting.\nSending buy order for 100.0 at 9515 , order type: limit\nINFO:lib.bitmex_api_lib:Chasing buy order c2e7fee0-20af-3f5d-a7b9-c22d49de2c19, order_price: 9508.0, last_price: 9508.0, current price: 9508 max chase: 9511.0\n.... trunicated\nINFO:lib.bitmex_api_lib:Chasing buy order c2e7fee0-20af-3f5d-a7b9-c22d49de2c19, order_price: 9508.0, last_price: 9508.0, current price: 9508 max chase: 9511.0\nINFO:lib.bitmex_api_lib:Order Filled\n\n\u003c/pre\u003e\n\n[![asciicast](https://asciinema.org/a/Ctn7upSmaIuhhJOXEBxBZMYoi.svg)](https://asciinema.org/a/Ctn7upSmaIuhhJOXEBxBZMYoi)\n\n###### Trailing Stop\n\n\u003cpre\u003e\n$ python3 ./bmcli.py -t 10\n[+] Initializing Trailing Stop with offset: 10.0\nINFO:exchange_lib.bitmex_ws:Connecting to wss://www.bitmex.com/realtime?subscribe=execution:XBTUSD,instrument:XBTUSD,order:XBTUSD,position:XBTUSD,quote:XBTUSD,trade:XBTUSD,margin\nINFO:exchange_lib.bitmex_ws:Authenticating with API Key.\nINFO:exchange_lib.bitmex_ws:Connected to WS.\nINFO:exchange_lib.bitmex_ws:Got all market data. Starting.\nINFO:bmexlib.bitmex_api_lib:Trailing stop triggered\nINFO:bmexlib.bitmex_api_lib:Trailing Stop for long position of entry price: 9535.6155 triggered: offset price 9521.5 current price: [9531.5]\nINFO:bmexlib.bitmex_api_lib:New high observed: 9533.00000000 Updating stop loss to 9523.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9538.50000000 Updating stop loss to 9528.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9539.00000000 Updating stop loss to 9529.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9540.50000000 Updating stop loss to 9530.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9545.00000000 Updating stop loss to 9535.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9546.50000000 Updating stop loss to 9536.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9547.00000000 Updating stop loss to 9537.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9550.00000000 Updating stop loss to 9540.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9560.50000000 Updating stop loss to 9550.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9562.00000000 Updating stop loss to 9552.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9567.00000000 Updating stop loss to 9557.00000000\nSending sell order for -2100 at 9553.5 , order type: market\nINFO:bmexlib.bitmex_api_lib:Sell triggered | Price: 9553.50000000 | Stop loss: 9557.00000000\n\n\u003c/pre\u003e\n\u003cp\u003e\n\n[![asciicast](https://asciinema.org/a/RUySuh40ObfavX7qxw8yafRSP.svg)](https://asciinema.org/a/RUySuh40ObfavX7qxw8yafRSP)\u003c/p\u003e\n\n\n###### AutoStop\n\n\u003cpre\u003e\n$ python3 ./bmcli.py -a 0.001 0.005 10\n[i] AutoStop: Stop Loss 0.01, Enable Trailing Stop: 0.005, Trail Offset: 10.0\nINFO:exchange_lib.bitmex_ws:Connecting to wss://www.bitmex.com/realtime?subscribe=execution:XBTUSD,instrument:XBTUSD,order:XBTUSD,position:XBTUSD,quote:XBTUSD,trade:XBTUSD,margin\nINFO:exchange_lib.bitmex_ws:Authenticating with API Key.\nINFO:exchange_lib.bitmex_ws:Connected to WS.\nINFO:exchange_lib.bitmex_ws:Got all market data. Starting.\nINFO:bmexlib.bitmex_api_lib:Time: 2020-05-20 20:45:33, Position: 500, Entry Price: 9535.5, Current Price: 9537.5\nINFO:bmexlib.bitmex_api_lib:Stop Loss Price: 9492.3, Trailing Stop Enable: 9549.54 \nINFO:bmexlib.bitmex_api_lib:Trailing stop triggered\nINFO:bmexlib.bitmex_api_lib:Trailing Stop for long position of entry price: 9535.5 triggered: offset price 9521.5 current price: [9531.5]\nINFO:bmexlib.bitmex_api_lib:New high observed: 9533.00000000 Updating stop loss to 9523.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9538.50000000 Updating stop loss to 9528.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9539.00000000 Updating stop loss to 9529.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9540.50000000 Updating stop loss to 9530.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9545.00000000 Updating stop loss to 9535.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9546.50000000 Updating stop loss to 9536.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9547.00000000 Updating stop loss to 9537.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9550.00000000 Updating stop loss to 9540.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9560.50000000 Updating stop loss to 9550.50000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9562.00000000 Updating stop loss to 9552.00000000\nINFO:bmexlib.bitmex_api_lib:New high observed: 9567.00000000 Updating stop loss to 9557.00000000\nINFO:bmexlib.bitmex_api_lib:Trailing Stop Triggered for LONG position: Offset 10.0\nSending sell order for -2100 at 9553.5 , order type: market\nINFO:bmexlib.bitmex_api_lib:Sell triggered | Price: 9553.50000000 | Stop loss: 9557.00000000\n\n\n\u003c/pre\u003e\n\n[![asciicast](https://asciinema.org/a/bOtzGkjuHNKGo5kEnAWWoOimH.svg)](https://asciinema.org/a/bOtzGkjuHNKGo5kEnAWWoOimH)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkerego%2Fbmcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkerego%2Fbmcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkerego%2Fbmcli/lists"}