{"id":13509441,"url":"https://github.com/nobrick/bitmex","last_synced_at":"2026-02-19T13:42:39.755Z","repository":{"id":150720040,"uuid":"80704864","full_name":"nobrick/bitmex","owner":"nobrick","description":"BitMEX client library for Elixir.","archived":false,"fork":false,"pushed_at":"2019-02-17T14:54:16.000Z","size":58,"stargazers_count":9,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T13:34:02.074Z","etag":null,"topics":["bitmex","rest","trading","websocket"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nobrick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-02T08:00:49.000Z","updated_at":"2023-09-05T12:38:02.000Z","dependencies_parsed_at":"2023-04-12T10:01:10.200Z","dependency_job_id":null,"html_url":"https://github.com/nobrick/bitmex","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobrick%2Fbitmex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobrick%2Fbitmex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobrick%2Fbitmex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nobrick%2Fbitmex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nobrick","download_url":"https://codeload.github.com/nobrick/bitmex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246324035,"owners_count":20759067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","rest","trading","websocket"],"created_at":"2024-08-01T02:01:07.795Z","updated_at":"2026-02-19T13:42:34.731Z","avatar_url":"https://github.com/nobrick.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"# BitMEX\n\n[![CircleCI](https://circleci.com/gh/nobrick/bitmex.svg?style=shield)](https://circleci.com/gh/nobrick/bitmex)\n\nBitMEX client library for Elixir.\n\n## Documentation\nSee the [online documentation](https://hexdocs.pm/bitmex/) for more information.\n\n## Installation\nAdd :bitmex to your list of dependencies in mix.exs:\n\n```elixir\ndef deps do\n  [{:bitmex, \"~\u003e 0.2\"}]\nend\n```\n\nAdd your app's `api_key` and `api_secret` to `config/config.exs`:\n```\nconfig :bitmex, api_key: \"\"\nconfig :bitmex, api_secret: \"\"\nconfig :bitmex, test_mode: false\n```\n\nSet `test_mode` to true if you want to simulate your app using BitMEX Testnet instead of the production version.\n\n## REST API\n\nYou may call methods in modules `Bitmex.Rest.*` (eg. `Bitmex.Rest.OrderBook`) to access the REST API.\n\nView the [Hex Documentation](https://hexdocs.pm/bitmex/) and [BitMEX API Explorer](https://www.bitmex.com/api/explorer/) for a full list of endpoints and return types.\n\n### Usage Examples\n\n#### Position\nGet the current position:\n```elixir\nBitmex.Rest.Position.get()\n```\n\n#### Orders\nGet all your open orders:\n```elixir\nBitmex.REST.Order.get_open()\n```\n\nCreate a order:\n```elixir\nparams_bi = %{\"symbol\" =\u003e \"XBTUSD\", \"side\" =\u003e \"Buy\", \"orderQty\" =\u003e 15,\n              \"ordType\" =\u003e \"Market\"}\nBitmex.Rest.Order.create(params_bi)\n```\n\nCreate a bulk order:\n```elixir\np1 = %{\"symbol\" =\u003e \"XBTUSD\", \"side\" =\u003e \"Buy\", \"orderQty\" =\u003e 15,\n       \"price\" =\u003e 4000.1, \"ordType\" =\u003e \"Limit\"}\nBitmex.Rest.Order.create_bulk(%{orders: [p1, p1]})\n```\n\n### Rate Limit\nYou may query the rate limit counter using `Bitmex.Rest.RateLimiter.remaining()`. It automatically logs the rate limit info responded from your last REST API request.\n\n## WebSocket API\n\nTo enable WebSocket subscriptions, use `Bitmex.WS` module and override the `handle_response` function:\n\n```elixir\ndefmodule Caravan.WS.MessageHandler do\n  use Bitmex.WS\n  def handle_response(resp), do: Caravan.WS.process(resp)\nend\n\ndefmodule Caravan.WS do\n  require Logger\n  import Task.Supervisor, only: [start_child: 2]\n\n  # API\n\n  def start_link(opts \\\\ []) do\n    Agent.start_link(fn -\u003e [] end, opts)\n  end\n\n  def process(resp) do\n    Agent.cast(__MODULE__, fn _ -\u003e\n      start_child(TemporaryTaskSup, fn -\u003e handle_response(resp) end)\n      []\n    end)\n  end\n\n  # Your callbacks\n\n  @doc \"\"\"\n  Handles order book data.\n  \"\"\"\n  def handle_response(%{\"table\" =\u003e \"orderBook10\", \"action\" =\u003e action,\n                        \"data\" =\u003e datums}) do\n    # ...\n  end\n\n  @doc \"\"\"\n  Handles position data.\n  \"\"\"\n  def handle_response(%{\"table\" =\u003e \"position\", \"action\" =\u003e action,\n                        \"data\" =\u003e datums}) do\n    # ...\n  end\n\n  @doc \"\"\"\n  Handles margin data.\n  \"\"\"\n  def handle_response(%{\"table\" =\u003e \"margin\", \"action\" =\u003e _action,\n                        \"data\" =\u003e [_datum]}) do\n    # ...\n  end\n\n  @doc \"\"\"\n  Handles order data.\n  \"\"\"\n  def handle_response(%{\"table\" =\u003e \"order\", \"action\" =\u003e action,\n                        \"data\" =\u003e datums}) do\n    # ...\n  end\n\n  @doc \"\"\"\n  Handles table subscriptions.\n  \"\"\"\n  def handle_response(%{\"request\" =\u003e %{\"op\" =\u003e \"subscribe\"},\n                      \"subscribe\" =\u003e table, \"success\" =\u003e true}) do\n    Logger.info \"Subscribed #{table}\"\n    # ...\n  end\n\n  @doc \"\"\"\n  Handles unexpected data.\n  \"\"\"\n  def handle_response(resp) do\n    Logger.warn inspect(resp, limit: 500)\n    # ...\n  end\nend\n```\n\n## License\n\n[The MIT License](https://github.com/nobrick/bitmex/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobrick%2Fbitmex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnobrick%2Fbitmex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnobrick%2Fbitmex/lists"}