tai v0.0.1 Tai.Advisor behaviour

A behavior for implementing a server that receives order book changes.

It can be used to monitor multiple quote streams and create, update or cancel orders.

Link to this section Summary

Functions

Returns an atom that will identify the process

Callbacks

Callback when the highest bid or lowest ask changes price or size

Callback when order book has bid or ask changes

Callback when an order has been cancelled on the exchange

Callback when an order has been cancelled in the outbox but before the request has been sent to the exchange

Callback when an order creation fails

Callback when an order is created on the server

Callback when an order is enqueued

Link to this section Functions

Link to this function to_name(advisor_id)

Returns an atom that will identify the process

Examples

iex> Tai.Advisor.to_name(:my_test_advisor) :advisor_my_test_advisor

Link to this section Callbacks

Link to this callback handle_inside_quote(order_book_feed_id, symbol, bid, ask, snapshot_or_changes, state)
handle_inside_quote(
  order_book_feed_id :: Atom.t(),
  symbol :: Atom.t(),
  bid :: Map.t(),
  ask :: Map.t(),
  snapshot_or_changes :: Map.t() | List.t(),
  state :: Map.t()
) :: :ok | {:ok, actions :: Map.t()}

Callback when the highest bid or lowest ask changes price or size

Link to this callback handle_order_book_changes(order_book_feed_id, symbol, changes, state)
handle_order_book_changes(
  order_book_feed_id :: Atom.t(),
  symbol :: Atom.t(),
  changes :: term(),
  state :: Map.t()
) :: :ok

Callback when order book has bid or ask changes

Link to this callback handle_order_cancelled(order, state)
handle_order_cancelled(order :: Tai.Trading.Order.t(), state :: Map.t()) :: :ok

Callback when an order has been cancelled on the exchange

Link to this callback handle_order_cancelling(order, state)
handle_order_cancelling(order :: Tai.Trading.Order.t(), state :: Map.t()) :: :ok

Callback when an order has been cancelled in the outbox but before the request has been sent to the exchange.

Link to this callback handle_order_create_error(reason, order, state)
handle_order_create_error(
  reason :: term(),
  order :: Tai.Trading.Order.t(),
  state :: Map.t()
) :: :ok

Callback when an order creation fails

Link to this callback handle_order_create_ok(order, state)
handle_order_create_ok(order :: Tai.Trading.Order.t(), state :: Map.t()) :: :ok

Callback when an order is created on the server

Link to this callback handle_order_enqueued(order, state)
handle_order_enqueued(order :: Tai.Trading.Order.t(), state :: Map.t()) :: :ok

Callback when an order is enqueued