Exchange v0.2.3 Exchange.Order View Source

A struct representing an Order to be placed in the Exchange

side: :buy, :sell type: :market, :limit

trader_id: Alchemist or the user_id expiration_time: unix timestamp in milliseconds when the order expires

Link to this section Summary

Functions

It set the price of an order considering an order book

Decodes the payload to an Order struct

Function that checks if a order's price is correct for the given order book.

Link to this section Types

Specs

order() :: %Exchange.Order{
  acknowledged_at: term(),
  exp_time: integer() | atom(),
  initial_size: size_in_grams(),
  modified_at: term(),
  order_id: String.t(),
  price: price_in_cents(),
  side: atom(),
  size: size_in_grams(),
  stop: integer(),
  ticker: atom(),
  trader_id: String.t(),
  type: atom()
}

Specs

price_in_cents() :: integer()

Specs

size_in_grams() :: integer()

Link to this section Functions

Link to this function

assign_prices(order, order_book)

View Source

Specs

assign_prices(order :: order(), order_book :: Exchange.OrderBook.order_book()) ::
  order()

It set the price of an order considering an order book

Parameters

order: Order to assign the price order_book: Reference order book

Link to this function

decode_from_jason(order)

View Source

Specs

decode_from_jason(map()) :: order()

Decodes the payload to an Order struct

Parameters

  • payload: map with necessary parameters to populate the struct
Link to this function

validate_price(order, order_book)

View Source

Function that checks if a order's price is correct for the given order book.

Parameters

order: Order to validate the price order_book: Reference order book