GithubHelp home page GithubHelp logo

huobi.ex's Introduction

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.