xfighter v0.2.1 Xfighter.Order
Summary
Functions
Cancel a list of orders
Cancel an order
Cancel a list of orders
Cancel an order
Get the status of a list of existing orders
Get the status of an existing order
Get the status of a list of existing orders
Get the status of an existing order
Types
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
Specs
cancel([Xfighter.Order.t]) ::
{:ok, [Xfighter.OrderStatus.t]} |
{:error, tuple}
cancel(Xfighter.Order.t) ::
{:ok, Xfighter.OrderStatus.t} |
{:error, tuple}
Cancel a list of orders.
Examples:
iex> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order]
iex> Xfighter.Order.cancel(orders)
{: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"},
%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> order2 = %Xfighter.Order(:id => 1660, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order2]
iex> Xfighter.Order.cancel(orders)
{:error,
{:request,
"Error 404: order 1660 not found (highest available on this venue is 1650)"}}
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)"}}
Specs
cancel!([Xfighter.Order.t]) :: [Xfighter.OrderStatus.t]
cancel!(Xfighter.Order.t) :: Xfighter.OrderStatus.t
Cancel a list of orders.
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> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order]
iex> Xfighter.Order.cancel!(orders)
[%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"},
%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> order2 = %Xfighter.Order(:id => 1660, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order2]
iex> Xfighter.Order.cancel!(orders)
** (RequestError) Error 404: order 1660 not found (highest available on this venue is 1650)
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)
Specs
status([Xfighter.Order.t]) ::
{:ok, [Xfighter.OrderStatus.t]} |
{:error, tuple}
status(Xfighter.Order.t) ::
{:ok, Xfighter.OrderStatus.t} |
{:error, tuple}
Get the status of a list of existing orders.
Examples:
iex> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order]
iex> Xfighter.Order.status(orders)
{: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> order2 = %Xfighter.Order(:id => 1660, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order2]
iex> Xfighter.Order.status(orders)
{:error,
{:request,
"Error 404: order 1660 not found (highest available on this venue is 1650)"}}
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)"}}
Specs
status!([Xfighter.Order.t]) :: [Xfighter.OrderStatus.t]
status!(Xfighter.Order.t) :: Xfighter.OrderStatus.t
Get the status of a list of existing orders.
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> order = %Xfighter.Order(:id => 1649, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order]
iex> Xfighter.Order.status!(orders)
[%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"},
%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> order2 = %Xfighter.Order(:id => 1660, :symbol => "FOOBAR", :venue => "TESTEX")
iex> orders = [order, order2]
iex> Xfighter.Order.status!(orders)
** (RequestError) Error 404: order 1660 not found (highest available on this venue is 1650)
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)