Git Product home page Git Product logo

binance.ex's Introduction

binance.ex

Elixir wrapper for interacting with the Binance API.

Installation

  1. The package can be installed by adding binance to your list of dependencies in mix.exs:
def deps do
  [
    {:binance, "~> 0.9.0"}
  ]
end
  1. Add :binance to your applications
def application do
  [applications: [:binance]]
end
  1. Add your Binance API credentials to your config.exs file, like so (you can create a new API key here):
config :binance,
  api_key: "xxx",
  secret_key: "xxx",
  end_point: "https://api.binance.us" # Add for the US API end point. The default is for "https://api.binance.com"

Usage

Documentation available at https://hexdocs.pm/binance.

Get all prices

iex> Binance.get_all_prices
{:ok,
 [%Binance.SymbolPrice{price: "0.07718300", symbol: "ETHBTC"},
  %Binance.SymbolPrice{price: "0.01675400", symbol: "LTCBTC"},
  %Binance.SymbolPrice{price: "0.00114690", symbol: "BNBBTC"},
  %Binance.SymbolPrice{price: "0.00655900", symbol: "NEOBTC"},
  %Binance.SymbolPrice{price: "0.00030000", symbol: "123456"},
  %Binance.SymbolPrice{price: "0.04754000", symbol: "QTUMETH"},
  %Binance.SymbolPrice{price: "0.00778500", symbol: "EOSETH"}
  ...]}

Buy 100 REQ for the current market price

iex> Binance.order_market_buy("REQETH", 100)
{:ok, %{}}

Trade pair normalization

For convenience, all functions that require a symbol in the form of "ETHBTC" also accept a %Binance.TradePair{} struct in the form of %Binance.TradePair{from: "ETH", to: "BTC"}. The order of symbols in %Binance.TradePair{} does not matter. All symbols are also case insensitive.

Binance.find_symbol/1 will return the correct string representation as it is listed on binance

Binance.find_symbol(%Binance.TradePair{from: "ReQ", to: "eTH"})
{:ok, "REQETH"}

Binance.find_symbol(%Binance.TradePair{from: "ETH", to: "REQ"})
{:ok, "REQETH"}

License

MIT

binance.ex's People

Contributors

ccjr avatar cdesch avatar cinderella-man avatar dvcrn avatar gilacost avatar jakuj avatar luizparreira avatar mikaak avatar rupurt avatar

Watchers

 avatar

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.