FixAlchemy.Feed.Pipeline behaviour (FIXAlchemy v0.2.2)

View Source

Turns a permission stage into a price transform.

FixAlchemy.Feed keys its tree on stages and never interprets them. A venue implements this behaviour to say what each stage does to a price.

defmodule MyVenue.Prices do
  @behaviour FixAlchemy.Feed.Pipeline

  @impl true
  def apply_stage({:spread, points}, price) do
    %{price | bid: price.bid - points, ask: price.ask + points}
  end

  def apply_stage({:markup, points}, price) do
    %{price | ask: price.ask + points}
  end

  def apply_stage({:commission, :none}, price), do: price
end

apply_stage/2 is called once per live edge of the tree, not once per subscriber, and runs in the publishing process. It must be pure and must not block.

Summary

Callbacks

Apply one stage to a price.

Callbacks

apply_stage(stage, price)

@callback apply_stage(stage :: term(), price :: term()) :: term()

Apply one stage to a price.

The returned value is delivered to the sessions subscribed at that node and becomes the input to every stage below it.