Skip to content

acuityinnovations/huobi.ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExHuobi

Huobi API Client for Elixir

Installation

If available in Hex, the package can be installed by adding ex_huobi to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_huobi, "~> 0.3.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ex_huobi.

Config

config = %{access_keys: ["XXX_HUOBI_API_KEY", "XXX_HUOBI_SECRET_KEY"]}

Swap Rest API Usage

Single API

Create a new order

ExHuobi.Swap.Rest.Order.create_order(
 %{ contract_code: "BTC-USD",
   client_order_id: 92233720366,
   volume: 1,
   price: 8000,
   direction: "Buy",
   lever_rate: 5,
   offset: "open",
   order_price_type: "limit"
}, config)

Margin Rest API Usage

Single API

Get account info

ExHuobi.Margin.Rest.Account.get(config)

Create a new order

ExHuobi.Margin.Rest.Order.create(
  %{
    "account-id": 12345678,
    amount: 0.001,
    price: 9900,
    symbol: "btcusdt",
    type: "sell-limit",
    source: "super-margin-api"
  },
  config
)

Cancel an order

ExHuobi.Margin.Rest.Order.cancel(70662287304, config)

Bulk API

Create multiple orders

ExHuobi.Margin.Rest.Order.bulk_create(%{"orders-data" =>
  [
    %{"account-id": 12035991, amount: 0.001, price: 11000 , symbol: "btcusdt", type: "sell-limit", source: "super-margin-api"},
    %{"account-id": 12035991, amount: 0.001, price: 11500 , symbol: "btcusdt", type: "sell-limit", source: "super-margin-api"}
  ]
  },
  config
)

Cancel multiple orders

ExHuobi.Margin.Rest.Order.bulk_cancel(%{"order-ids": [70664141188, 70664141185]}, config)

Futures Exchange API

config = %{access_keys: ["XXX_HUOBI_API_KEY", "XXX_HUOBI_SECRET_KEY"]}
# Get account position

Get futures positions

symbol = "BTC|ETH..."
ExHuobi.Futures.Rest.Account.get_position(symbol, config)

Create new order

order = %{
        "contract_type" => "this_week",
        "direction" => "Buy",
        "lever_rate" => 5,
        "offset" => "open",
        "order_price_type" => "limit",
        "price" => 5000,
        "symbol" => "BTC",
        "volume" => 1
      }
ExHuobi.Futures.Rest.Order.create_order(order, config)

Create multiple orders

orders = [
      %{
        "contract_type" => "this_week",
        "direction" => "Buy",
        "lever_rate" => 1,
        "offset" => "open",
        "order_price_type" => "limit",
        "price" => 5000,
        "symbol" => "BTC",
        "volume" => 1
      },
      %{
        "contract_type" => "next_week",
        "direction" => "Buy",
        "lever_rate" => 5,
        "offset" => "open",
        "order_price_type" => "limit",
        "price" => 5000,
        "symbol" => "BTC",
        "volume" => 1
      },
    ]

ExHuobi.Futures.Rest.Order.create_bulk_orders(orders, config)

Cancel order

order_id = 1234567890
ExHuobi.Futures.Rest.Order.cancel_order(order_id, config)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages