binance v0.5.0 Binance
Link to this section Summary
Functions
Creates a new order on binance
Searches and normalizes the symbol as it is listed on binance
Fetches user account from binance
Get all symbols and current prices listed in binance
Retrieves the bids & asks of the order book up to the depth for the given symbol
Get binance server time in unix epoch
Retrieves the current ticker information for the given trade pair
Creates a new limit buy order
Creates a new limit sell order
Creates a new market buy order
Creates a new market sell order
Pings binance API. Returns {:ok, %{}}
if successful, {:error, reason}
otherwise
Link to this section Functions
Creates a new order on binance
Returns {:ok, %{}}
or {:error, reason}
.
In the case of a error on binance, for example with invalid parameters, {:error, {:binance_error, %{code: code, msg: msg}}}
will be returned.
Please read https://www.binance.com/restapipub.html#user-content-account-endpoints to understand all the parameters
Searches and normalizes the symbol as it is listed on binance.
To retrieve this information, a request to the binance API is done. The result is then cached to ensure the request is done only once.
Order of which symbol comes first, and case sensitivity does not matter.
Returns {:ok, "SYMBOL"}
if successfully, or {:error, reason}
otherwise.
Examples
These 3 calls will result in the same result string:
find_symbol(%Binance.TradePair{from: "ETH", to: "REQ"})
find_symbol(%Binance.TradePair{from: "REQ", to: "ETH"})
find_symbol(%Binance.TradePair{from: "rEq", to: "eTH"})
Result: {:ok, "REQETH"}
Fetches user account from binance
Returns {:ok, %Binance.Account{}}
or {:error, reason}
.
In the case of a error on binance, for example with invalid parameters, {:error, {:binance_error, %{code: code, msg: msg}}}
will be returned.
Please read https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data to understand API
Get all symbols and current prices listed in binance
Returns {:ok, [%Binance.SymbolPrice{}]}
or {:error, reason}
.
Example
{:ok,
[%Binance.SymbolPrice{price: "0.07579300", symbol: "ETHBTC"},
%Binance.SymbolPrice{price: "0.01670200", symbol: "LTCBTC"},
%Binance.SymbolPrice{price: "0.00114550", symbol: "BNBBTC"},
%Binance.SymbolPrice{price: "0.00640000", symbol: "NEOBTC"},
%Binance.SymbolPrice{price: "0.00030000", symbol: "123456"},
%Binance.SymbolPrice{price: "0.04895000", symbol: "QTUMETH"},
...]}
Retrieves the bids & asks of the order book up to the depth for the given symbol
Returns {:ok, %{bids: [...], asks: [...], lastUpdateId: 12345}}
or {:error, reason}
Example
{:ok,
%Binance.OrderBook{
asks: [
["8400.00000000", "2.04078100", []],
["8405.35000000", "0.50354700", []],
["8406.00000000", "0.32769800", []],
["8406.33000000", "0.00239000", []],
["8406.51000000", "0.03241000", []]
],
bids: [
["8393.00000000", "0.20453200", []],
["8392.57000000", "0.02639000", []],
["8392.00000000", "1.40893300", []],
["8390.09000000", "0.07047100", []],
["8388.72000000", "0.04577400", []]
],
last_update_id: 113634395
}
}
Get binance server time in unix epoch.
Returns {:ok, time}
if successful, {:error, reason}
otherwise
Example
{:ok, 1515390701097}
Retrieves the current ticker information for the given trade pair.
Symbol can be a binance symbol in the form of "ETHBTC"
or %Binance.TradePair{}
.
Returns {:ok, %Binance.Ticker{}}
or {:error, reason}
Example
{:ok,
%Binance.Ticker{ask_price: "0.07548800", bid_price: "0.07542100",
close_time: 1515391124878, count: 661676, first_id: 16797673,
high_price: "0.07948000", last_id: 17459348, last_price: "0.07542000",
low_price: "0.06330000", open_price: "0.06593800", open_time: 1515304724878,
prev_close_price: "0.06593800", price_change: "0.00948200",
price_change_percent: "14.380", volume: "507770.18500000",
weighted_avg_price: "0.06946930"}}
Creates a new limit buy order
Symbol can be a binance symbol in the form of "ETHBTC"
or %Binance.TradePair{}
.
Returns {:ok, %{}}
or {:error, reason}
Creates a new limit sell order
Symbol can be a binance symbol in the form of "ETHBTC"
or %Binance.TradePair{}
.
Returns {:ok, %{}}
or {:error, reason}
Creates a new market buy order
Symbol can be a binance symbol in the form of "ETHBTC"
or %Binance.TradePair{}
.
Returns {:ok, %{}}
or {:error, reason}
Creates a new market sell order
Symbol can be a binance symbol in the form of "ETHBTC"
or %Binance.TradePair{}
.
Returns {:ok, %{}}
or {:error, reason}
Pings binance API. Returns {:ok, %{}}
if successful, {:error, reason}
otherwise