ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - nobrick/bitmex: BitMEX client library for Elixir.
BitMEX client library for Elixir. Contribute to nobrick/bitmex development by creating an account on GitHub.
Visit Site

GitHub - nobrick/bitmex: BitMEX client library for Elixir.

GitHub - nobrick/bitmex: BitMEX client library for Elixir.

BitMEX

CircleCI

BitMEX client library for Elixir.

Documentation

See the online documentation for more information.

Installation

Add :bitmex to your list of dependencies in mix.exs:

def deps do
  [{:bitmex, "~> 0.2"}]
end

Add your app's api_key and api_secret to config/config.exs:

config :bitmex, api_key: ""
config :bitmex, api_secret: ""
config :bitmex, test_mode: false

Set test_mode to true if you want to simulate your app using BitMEX Testnet instead of the production version.

REST API

You may call methods in modules Bitmex.Rest.* (eg. Bitmex.Rest.OrderBook) to access the REST API.

View the Hex Documentation and BitMEX API Explorer for a full list of endpoints and return types.

Usage Examples

Position

Get the current position:

Bitmex.Rest.Position.get()

Orders

Get all your open orders:

Bitmex.REST.Order.get_open()

Create a order:

params_bi = %{"symbol" => "XBTUSD", "side" => "Buy", "orderQty" => 15,
              "ordType" => "Market"}
Bitmex.Rest.Order.create(params_bi)

Create a bulk order:

p1 = %{"symbol" => "XBTUSD", "side" => "Buy", "orderQty" => 15,
       "price" => 4000.1, "ordType" => "Limit"}
Bitmex.Rest.Order.create_bulk(%{orders: [p1, p1]})

Rate Limit

You 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.

WebSocket API

To enable WebSocket subscriptions, use Bitmex.WS module and override the handle_response function:

defmodule Caravan.WS.MessageHandler do
  use Bitmex.WS
  def handle_response(resp), do: Caravan.WS.process(resp)
end

defmodule Caravan.WS do
  require Logger
  import Task.Supervisor, only: [start_child: 2]

  # API

  def start_link(opts \\ []) do
    Agent.start_link(fn -> [] end, opts)
  end

  def process(resp) do
    Agent.cast(__MODULE__, fn _ ->
      start_child(TemporaryTaskSup, fn -> handle_response(resp) end)
      []
    end)
  end

  # Your callbacks

  @doc """
  Handles order book data.
  """
  def handle_response(%{"table" => "orderBook10", "action" => action,
                        "data" => datums}) do
    # ...
  end

  @doc """
  Handles position data.
  """
  def handle_response(%{"table" => "position", "action" => action,
                        "data" => datums}) do
    # ...
  end

  @doc """
  Handles margin data.
  """
  def handle_response(%{"table" => "margin", "action" => _action,
                        "data" => [_datum]}) do
    # ...
  end

  @doc """
  Handles order data.
  """
  def handle_response(%{"table" => "order", "action" => action,
                        "data" => datums}) do
    # ...
  end

  @doc """
  Handles table subscriptions.
  """
  def handle_response(%{"request" => %{"op" => "subscribe"},
                      "subscribe" => table, "success" => true}) do
    Logger.info "Subscribed #{table}"
    # ...
  end

  @doc """
  Handles unexpected data.
  """
  def handle_response(resp) do
    Logger.warn inspect(resp, limit: 500)
    # ...
  end
end

License

The MIT License

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory