tai v0.0.5 Tai.Exchanges.Account behaviour

Uniform interface for private exchange actions

Link to this section Summary

Functions

Fetches all balances for the given account

Create a buy limit order from the given order struct. It returns an error tuple when the type is not accepted

Create a buy limit order on the exchange with the given

Cancels the order on the exchange and returns the order_id

Fetches the status of the order from the exchange

Create a sell limit order from the given order struct. It returns an error tuple when the type is not accepted

Create a sell limit order on the exchange with the given

Returns an atom which identifies the process for the given account_id

Link to this section Types

Link to this type credential_error()
credential_error() :: Tai.CredentialError.t()
Link to this type insufficient_balance_error()
insufficient_balance_error() :: Tai.Trading.InsufficientBalanceError.t()
Link to this type invalid_order_type_error()
invalid_order_type_error() :: Tai.Trading.OrderResponses.InvalidOrderType.t()
Link to this type order_response()
order_response() :: Tai.Trading.OrderResponse.t()
Link to this type timeout_error()
timeout_error() :: Tai.TimeoutError.t()

Link to this section Functions

Link to this function all_balances(exchange_id, account_id)
all_balances(atom(), atom()) ::
  {:ok, map()} | {:error, credential_error() | timeout_error()}

Fetches all balances for the given account

Link to this function buy_limit(order)
buy_limit(order()) ::
  {:ok, order_response()}
  | {:error, invalid_order_type_error() | insufficient_balance_error()}

Create a buy limit order from the given order struct. It returns an error tuple when the type is not accepted.

{:error, %Tai.Trading.OrderResponses.InvalidOrderType{}}

Link to this function buy_limit(exchange_id, account_id, symbol, price, size, time_in_force \\ :ioc)
buy_limit(atom(), atom(), atom(), float(), float(), atom()) ::
  {:ok, order_response()} | {:error, insufficient_balance_error()}

Create a buy limit order on the exchange with the given

  • symbol
  • price
  • size
  • time_in_force
Link to this function cancel_order(exchange_id, account_id, order_id)

Cancels the order on the exchange and returns the order_id

Link to this function order_status(exchange_id, account_id, order_id)

Fetches the status of the order from the exchange

Link to this function sell_limit(order)

Create a sell limit order from the given order struct. It returns an error tuple when the type is not accepted.

{:error, %Tai.Trading.OrderResponses.InvalidOrderType{}}

Link to this function sell_limit(exchange_id, account_id, symbol, price, size, time_in_force \\ :ioc)

Create a sell limit order on the exchange with the given

  • symbol
  • price
  • size
  • time_in_force
Link to this function to_name(exchange_id, account_id)

Returns an atom which identifies the process for the given account_id

Examples

iex> Tai.Exchanges.Account.to_name(:my_test_exchange, :my_test_account) :”Elixir.Tai.Exchanges.Account_my_test_exchange_my_test_account”

Link to this section Callbacks

Link to this callback all_balances()
all_balances() :: {:ok, balances :: map()} | {:error, reason :: term()}
Link to this callback buy_limit(symbol, price, size, time_in_force)
buy_limit(
  symbol :: atom(),
  price :: float(),
  size :: float(),
  time_in_force :: atom()
) ::
  {:ok, order_response :: Tai.Trading.OrderResponse.t()}
  | {:error, reason :: term()}
Link to this callback sell_limit(symbol, price, size, time_in_force)
sell_limit(
  symbol :: atom(),
  price :: float(),
  size :: float(),
  time_in_force :: atom()
) ::
  {:ok, order_response :: Tai.Trading.OrderResponse.t()}
  | {:error, reason :: term()}