xfighter v0.2.0 Xfighter.Order

Summary

Functions

Cancel an order

Cancel an order

Get the status of an existing order

Get the status of an existing order

Get the status of an existing order

Get the status of an existing order

Types

fill :: %{price: non_neg_integer, qty: non_neg_integer, ts: String.t}
t :: %Xfighter.Order{ok: boolean, symbol: String.t, venue: String.t, direction: String.t, originalQty: non_neg_integer, qty: non_neg_integer, price: non_neg_integer, type: String.t, id: non_neg_integer, account: String.t, ts: String.t, fills: [Xfighter.Order.fill], totalFilled: non_neg_integer, open: boolean}

Functions

cancel(order)

Specs

cancel(Xfighter.Order.t) ::
  {:ok, Xfighter.OrderStatus.t} |
  {:error, tuple}

Cancel an order.

Examples:

iex> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> Xfighter.Order.cancel(order)
{:ok,
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}}

iex> Xfighter.Order.cancel(1660, "FOOBAR", "TESTEX")
{:error,
 {:request,
   "Error 404:  order 1660 not found (highest available on this venue is 1650)"}}
cancel(order_id, stock, venue)

Specs

cancel(integer, String.t, String.t) ::
  {:ok, Map.t} |
  {:error, tuple}

Cancel an order.

Examples:

iex> Xfighter.Order.cancel(1649, "FOOBAR", "TESTEX")
{:ok,
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}}

iex> Xfighter.Order.cancel(1660, "FOOBAR", "TESTEX")
{:error,
 {:request,
   "Error 404:  order 1660 not found (highest available on this venue is 1650)"}}
cancel!(order)

Cancel an order.

A RequestError exception is raised if:

  • the venue could not be found
  • the stock is not traded on the venue
  • the order id is invalid

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.Order.cancel!(order)
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}

iex> Xfighter.Order.cancel!(1660, "FOOBAR", "TESTEX")
** (RequestError) Error 404:  order 1660 not found (highest available on this venue is 1650)
cancel!(order_id, stock, venue)

Specs

cancel!(integer, String.t, String.t) :: Xfighter.OrderStatus.t

Cancel an order.

A RequestError exception is raised if:

  • the venue could not be found
  • the stock is not traded on the venue
  • the order id is invalid

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.Order.cancel!(1649, "FOOBAR", "TESTEX")
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}

iex> Xfighter.Order.cancel!(1660, "FOOBAR", "TESTEX")
** (RequestError) Error 404:  order 1660 not found (highest available on this venue is 1650)
status(order)

Specs

status(Xfighter.Order.t) ::
  {:ok, Xfighter.OrderStatus.t} |
  {:error, tuple}

Get the status of an existing order.

Examples:

iex> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> Xfighter.Order.status(order)
{:ok,
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}}

iex> Xfighter.Order.status(1660, "FOOBAR", "TESTEX")
{:error,
 {:request,
   "Error 404:  order 1660 not found (highest available on this venue is 1650)"}}
status(order_id, stock, venue)

Specs

status(integer, String.t, String.t) ::
  {:ok, Xfighter.OrderStatus.t} |
  {:error, tuple}

Get the status of an existing order.

Examples:

iex> Xfighter.Order.status(1649, "FOOBAR", "TESTEX")
{:ok,
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}}

iex> Xfighter.Order.status(1660, "FOOBAR", "TESTEX")
{:error,
 {:request,
   "Error 404:  order 1660 not found (highest available on this venue is 1650)"}}
status!(order)

Get the status of an existing order.

A RequestError exception is raised if:

  • the venue could not be found
  • the stock is not traded on the venue
  • the order id is invalid

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.Order.status!(order)
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}

iex> Xfighter.Order.status!(1660, "FOOBAR", "TESTEX")
** (RequestError) Error 404:  order 1660 not found (highest available on this venue is 1650)
status!(order_id, stock, venue)

Specs

status!(integer, String.t, String.t) :: Xfighter.OrderStatus.t

Get the status of an existing order.

A RequestError exception is raised if:

  • the venue could not be found
  • the stock is not traded on the venue
  • the order id is invalid

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.Order.status!(1649, "FOOBAR", "TESTEX")
 %Xfighter.OrderStatus{account: "EXB123456", direction: "buy",
   fills: [%{price: 6000, qty: 10, ts: "2015-12-18T00:03:40.640740258Z"}],
   id: 1649, ok: true, open: false, orderType: "market", originalQty: 10,
   price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
   ts: "2015-12-18T00:03:40.640738101Z", venue: "TESTEX"}

iex> Xfighter.Order.status!(1660, "FOOBAR", "TESTEX")
** (RequestError) Error 404:  order 1660 not found (highest available on this venue is 1650)