Exchange v0.2.5 Exchange.Trade View Source

Placeholder to define trades

Link to this section Summary

Functions

Decodes the payload to a Trade struct

Function that creates a trade given two matching orders

Link to this section Functions

Link to this function

decode_from_jason(trade)

View Source

Specs

decode_from_jason(map()) :: %Exchange.Trade{
  acknowledged_at: term(),
  buy_init_size: term(),
  buy_order_id: term(),
  buyer_id: term(),
  currency: term(),
  price: term(),
  sell_init_size: term(),
  sell_order_id: term(),
  seller_id: term(),
  size: term(),
  ticker: term(),
  trade_id: term(),
  type: term()
}

Decodes the payload to a Trade struct

Parameters

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

generate_trade(order, matched_order, type, currency)

View Source

Specs

generate_trade(
  order :: Exchange.Order.order(),
  matched_order :: Exchange.Order.order(),
  type :: atom(),
  currency :: atom()
) :: %Exchange.Trade{
  acknowledged_at: term(),
  buy_init_size: term(),
  buy_order_id: term(),
  buyer_id: term(),
  currency: term(),
  price: term(),
  sell_init_size: term(),
  sell_order_id: term(),
  seller_id: term(),
  size: term(),
  ticker: term(),
  trade_id: term(),
  type: term()
}

Function that creates a trade given two matching orders

Parameters

  • order: Newly placed order
  • matched_order: Order that is in the Exchange.OrderBook that matches the newly placed order
  • type: Atom that can either be :partial_fill or :fulfill