xfighter v0.2.0 Xfighter.Orderbook

Summary

Functions

Get the orderbook for a particular stock

Get the orderbook for a particular stock

Types

entry :: %{price: non_neg_integer, qty: non_neg_integer, isBuy: boolean}
t :: %Xfighter.Orderbook{ok: boolean, venue: String.t, symbol: String.t, bids: [Xfighter.Orderbook.entry], asks: [Xfighter.Orderbook.entry], ts: String.t}

Functions

state(stock, venue)

Specs

state(String.t, String.t) ::
  {:ok, Xfighter.Orderbook.t} |
  {:error, tuple}

Get the orderbook for a particular stock.

Examples:

iex> Xfighter.Orderbook.state("FOOBAR", "TESTEX")
{:ok,
 %Xfighter.Orderbook{
   asks: [%{isBuy: false, price: 6000, qty: 3320},
          %{isBuy: false, price: 6000, qty: 5000}],
   bids: [%{isBuy: true, price: 5850, qty: 2554654},
          %{isBuy: true, price: 5000, qty: 375879}],
   ok: true, symbol: "FOOBAR", ts: "2015-12-17T23:30:37.455298328Z",
   venue: "TESTEX"}}

iex> Xfighter.Orderbook.state("FOOBAR", "TEST")
{:error, {:request, "Error 404:  No venue exists with the symbol TEST"}}
state!(stock, venue)

Get the orderbook for a particular stock.

A RequestError exception is raised if the venue could not be found or the stock is not traded on the venue.

A ConnectionError exception is raised if a connection attempt to the venue failed.

An UnhandledAPIResponse exception is raised if an unexpected event occurs.

An InvalidJSON is raised if the response is not a valid JSON.

Examples:

iex> Xfighter.Orderbook.state!("FOOBAR", "TESTEX")
 %Xfighter.Orderbook{
   asks: [%{isBuy: false, price: 6000, qty: 3320},
          %{isBuy: false, price: 6000, qty: 5000}],
   bids: [%{isBuy: true, price: 5850, qty: 2554654},
          %{isBuy: true, price: 5000, qty: 375879}],
   ok: true, symbol: "FOOBAR", ts: "2015-12-17T23:30:37.455298328Z",
   venue: "TESTEX"}

iex> Xfighter.Orderbook.state!("FOOBAR", "TEST")
** (RequestError) Error 404:  No venue exists with the symbol TEST