Exchange v0.2.2 Exchange.Utils View Source

Auxiliary functions for Exchange APP

Link to this section Summary

Functions

Fetches the completed trades stored by a Exchange.TimeSeries adapter given a ticker and a id

Fetches the completed stored by a Exchange.TimeSeries adapter given a ticker and a trade id.

Fetches the completed trades stored by a Exchange.TimeSeries adapter given a ticker and a id

Fetches the active orders stored by a Exchange.TimeSeries adapter given a ticker

Function that generates n random orders given a specific ticker

Creates a random order for a given ticker

Creates a expiring limit order for a given ticker

This function places sample buy orders and sell orders in the correct market using the ticker.

Creates a limit order for a given ticker

Creates an Exchange.OrderBook with sample buy and sell orders

Retrieves the module of an adapter of Exchange.TimeSeries

Link to this section Functions

Specs

empty_order_book() :: Exchange.OrderBook.order_book()

Return a empty Exchange.OrderBook

Link to this function

fetch_all_completed_trades(ticker)

View Source

Specs

fetch_all_completed_trades(ticker :: atom()) :: list()

Fetches the completed trades stored by a Exchange.TimeSeries adapter given a ticker and a id

Parameters

  • ticker: Market where the fetch should be made
  • trader_id: The that a given trade must match
Link to this function

fetch_completed_trade_by_trade_id(ticker, trade_id)

View Source

Specs

fetch_completed_trade_by_trade_id(ticker :: atom(), trade_id :: String.t()) ::
  Exchange.Trade

Fetches the completed stored by a Exchange.TimeSeries adapter given a ticker and a trade id.

Parameters

  • ticker: Market where the fetch should be made
  • trade_id: Id of the requested trade
Link to this function

fetch_completed_trades(ticker, trader_id)

View Source

Specs

fetch_completed_trades(ticker :: atom(), trader_id :: String.t()) :: list()

Fetches the completed trades stored by a Exchange.TimeSeries adapter given a ticker and a id

Parameters

  • ticker: Market where the fetch should be made
  • trader_id: The that a given trade must match
Link to this function

fetch_live_orders(ticker)

View Source

Specs

fetch_live_orders(ticker :: atom()) :: list()

Fetches the active orders stored by a Exchange.TimeSeries adapter given a ticker

Parameters

  • ticker: Market where the fetch should be made
Link to this function

generate_random_orders(n, ticker)

View Source

Specs

generate_random_orders(n :: number(), ticker :: atom()) :: [
  Exchange.Order.order()
]

Function that generates n random orders given a specific ticker

Arguments

  • ticker: Market where the order should be placed
  • n: Number of orders to be generated

Specs

random_order(ticker :: atom()) :: Exchange.Order.order()

Creates a random order for a given ticker

Arguments

  • ticker: Market where the order should be placed
Link to this function

sample_expiring_order(map)

View Source

Specs

sample_expiring_order(%{
  price: number(),
  side: atom(),
  size: number(),
  exp_time: number(),
  id: String.t()
}) :: Exchange.Order.order()

Creates a expiring limit order for a given ticker

Link to this function

sample_matching_engine_init(ticker)

View Source

Specs

sample_matching_engine_init(ticker :: atom()) :: :ok

This function places sample buy orders and sell orders in the correct market using the ticker.

Arguments

  • ticker: Market where the orders should be placed

Specs

sample_order(map()) :: Exchange.Order.order()

Creates a limit order for a given ticker

Link to this function

sample_order_book(ticker)

View Source

Specs

sample_order_book(ticker :: atom()) :: Exchange.OrderBook.order_book()

Creates an Exchange.OrderBook with sample buy and sell orders

Arguments

  • ticker: Market where the order book belongs

Specs

time_series() :: any()

Retrieves the module of an adapter of Exchange.TimeSeries