Dwarves.BinanceSpot (dwarves_binancex v0.1.17)

Link to this section Summary

Functions

Pings binance API. Returns {:ok, %{}} if successful, {:error, reason} otherwise

Universal Transfer (For Master Account).

Link to this section Functions

Link to this function

account_snapshot(params, api_key, api_secret, is_testnet \\ false)

Get Daily Account Snapshot.

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://binance-docs.github.io/apidocs/spot/en/#daily-account-snapshot-user_data to understand all the parameters

Examples

account_snapshot(%{"type" => "FUTURES", "start_time" => 1642032000000, "end_time" => 1642032000000}, "api_key", "api_secret")

Result:

{:ok,
 %{
    code: 200,
    msg: "",
    snapshotVos: [...]
  }
or
{:error, {:binance_error, %{
      code: -3026,
      msg: "request param 'type' wrong, shoud be in ('SPOT', 'MARGIN', 'FUTURES')"
    }
  }
}
Link to this function

get_endpoint(is_testnet)

Link to this function

ping(is_testnet \\ false)

Pings binance API. Returns {:ok, %{}} if successful, {:error, reason} otherwise

Link to this function

universal_transfer(params, api_key, api_secret)

Universal Transfer (For Master Account).

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://binance-docs.github.io/apidocs/spot/en/#universal-transfer-for-master-account to understand all the parameters

Examples

universal_transfer(%{"from_email" => "email@gmail.com", "to_email" => "email@gmail.com", "from_account_type" => "USDT_FUTURE", "to_account_type" => "SPOT", "asset" => "USDT", "amount" => 100},"api_key",  "secret_key")

Result:

{:ok,
 %{
    tranId: "tranId"
  }
or
{:error, {:binance_error, %{
      code: -1000,
      msg: "No enum constant com.binance.accountsubuser.enums.TranferWay.FUTURE_TO_FUTURE"
    }
  }
}