Trading.MarketData.Feed (trading v0.1.0)

Market data feed handler for processing real-time market data updates.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets the current state of an order book.

Processes a market data update.

Starts a market data feed.

Subscribes to market data updates.

Unsubscribes from market data updates.

Types

market_data_type()

@type market_data_type() ::
  :trade | :quote | :order_book_update | :order_book_snapshot

subscriber()

@type subscriber() :: pid() | {module(), atom()}

t()

@type t() :: %Trading.MarketData.Feed{
  buffer: list(),
  feed_type: atom(),
  last_updates: %{required(String.t()) => integer()},
  order_books: %{required(String.t()) => Trading.OrderBook.t()},
  subscribers: MapSet.t(subscriber())
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_order_book(server, symbol)

@spec get_order_book(GenServer.server(), String.t()) ::
  {:ok, Trading.OrderBook.t()} | {:error, term()}

Gets the current state of an order book.

process_update(server, update)

@spec process_update(GenServer.server(), map()) :: :ok

Processes a market data update.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts a market data feed.

subscribe(server, subscriber, symbols \\ [])

@spec subscribe(GenServer.server(), subscriber(), [String.t()]) :: :ok

Subscribes to market data updates.

unsubscribe(server, subscriber)

@spec unsubscribe(GenServer.server(), subscriber()) :: :ok

Unsubscribes from market data updates.