tai v0.0.4 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

Types

t()

State of the running advisor

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 during initilization. Allows the store to be updated before it starts responding to events

Link to this section Types

Link to this type t()
t() :: %Tai.Advisor{
  advisor_id: atom(),
  inside_quotes: map(),
  order_books: map(),
  store: map()
}

State of the running advisor

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, inside_quote, changes, state)
handle_inside_quote(
  order_book_feed_id :: atom(),
  symbol :: atom(),
  inside_quote :: Tai.Markets.Quote.t(),
  changes :: map() | list(),
  state :: Tai.Advisor.t()
) :: :ok | {:ok, store :: map()}

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(),
  symbol :: atom(),
  changes :: term(),
  state :: Tai.Advisor.t()
) :: :ok

Callback when order book has bid or ask changes

Link to this callback init_store(state)
init_store(state :: t()) :: {:ok, map()}

Callback during initilization. Allows the store to be updated before it starts responding to events