xfighter v0.2.0 Xfighter.Stock
Summary
Functions
Place an order to buy a stock
Place an order to buy a stock
List stocks available for trading on a venue
List stocks available for trading on a venue
Get a quick look at the most recent trade information for a stock
Get a quick look at the most recent trade information for a stock
Place an order to sell a stock
Place an order to sell a stock
Types
Functions
Specs
buy(non_neg_integer, String.t, String.t, String.t, String.t, non_neg_integer) ::
{:ok, Xfighter.Order.t} |
{:error, tuple}
Place an order to buy a stock.
Examples:
iex> Xfighter.Stock.buy(10, "FOOBAR", "TESTEX", "EXB123456", "market")
{:ok,
%Xfighter.Order{account: "EXB123456", direction: "buy",
fills: [%{price: 6000, qty: 10, ts: "2015-12-17T23:47:02.081622723Z"}],
id: 1636, ok: true, open: false, orderType: "market", originalQty: 10,
price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
ts: "2015-12-17T23:47:02.081620689Z", venue: "TESTEX"}}
iex> Xfighter.Stock.buy(10, "FOOBAR", "TESTEX", "EXB123456", "limit", 50.16)
iex> Xfighter.Stock.buy(10, "FOOBAR", "TESTEX", "EXB123456", "fok", 40)
iex> Xfighter.Stock.buy(10, "FOOBAR", "TESTEX", "EXB123456", "ioc", 20.5)
iex> Xfighter.Stock.buy(10, "F", "TESTEX", "EXB123456", "limit", 50.16)
{:error, {:request, "Error 200: symbol F does not exist on venue TESTEX"}}
Specs
buy!(non_neg_integer, String.t, String.t, String.t, String.t, non_neg_integer) :: Xfighter.Order.t
Place an order to buy a stock.
A RequestError
exception is raised if:
- the venue could not be found
- the stock is not traded on the venue
- you are not authorized to trade on that account
- a request parameter 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.Stock.buy!(10, "FOOBAR", "TESTEX", "EXB123456", "market")
%Xfighter.Order{account: "EXB123456", direction: "buy",
fills: [%{price: 6000, qty: 10, ts: "2015-12-17T23:47:02.081622723Z"}],
id: 1636, ok: true, open: false, orderType: "market", originalQty: 10,
price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
ts: "2015-12-17T23:47:02.081620689Z", venue: "TESTEX"}
iex> Xfighter.Stock.buy!(10, "FOOBAR", "TESTEX", "EXB123456", "limit", 50.16)
iex> Xfighter.Stock.buy!(10, "FOOBAR", "TESTEX", "EXB123456", "fok", 40)
iex> Xfighter.Stock.buy!(10, "FOOBAR", "TESTEX", "EXB123456", "ioc", 20.5)
iex> Xfighter.Stock.buy!(10, "F", "TESTEX", "EXB123456", "limit", 50.16)
** (RequestError) Error 200: symbol F does not exist on venue TESTEX
Specs
list(String.t) ::
{:ok, Xfighter.Symbols.t} |
{:error, tuple}
List stocks available for trading on a venue.
Examples:
iex> Xfighter.Stock.list("TESTEX")
{:ok,
%Xfighter.Symbols{ok: true,
symbols: [%{name: "Foreign Owned Occluded Bridge Architecture Resources",
symbol: "FOOBAR"}]}}
iex> Xfighter.Stock.list("TEST")
{:error, {:request, "Error 404: No venue exists with the symbol TEST"}}
Specs
list!(String.t) :: Xfighter.Symbols.t
List stocks available for trading on a venue.
A RequestError
exception is raised if the venue could not be found.
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.Stock.list!("TESTEX")
%Xfighter.Symbols{ok: true,
symbols: [%{name: "Foreign Owned Occluded Bridge Architecture Resources",
symbol: "FOOBAR"}]}
iex> Xfighter.Stock.list!("TEST")
** (RequestError) Error 404: No venue exists with the symbol TEST
Specs
quote(String.t, String.t) ::
{:ok, Xfighter.Quote.t} |
{:error, tuple}
Get a quick look at the most recent trade information for a stock.
Examples:
iex> Xfighter.Stock.quote("FOOBAR", "TESTEX")
{:ok,
%Xfighter.Quote{ask: 6000, askDepth: 8310, askSize: 8310, bid: 5850, bidDepth: 21273447,
bidSize: 20437211, last: 6000, lastSize: 10,
lastTrade: "2015-12-17T23:47:02.081622723Z", ok: true,
quoteTime: "2015-12-17T23:52:55.44241142Z", symbol: "FOOBAR",
venue: "TESTEX"}}
iex> Xfighter.Stock.quote("F", "TESTEX")
{:error, {:request, "Error 404: Stock F does not trade on venue TESTEX"}}
Specs
quote!(String.t, String.t) :: Xfighter.Quote.t
Get a quick look at the most recent trade information for a stock.
A RequestError
exception is raised if:
- the venue could not be found
- the stock is not traded on the venue
- a request parameter 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.Stock.quote!("FOOBAR", "TESTEX")
%Xfighter.Quote{ask: 6000, askDepth: 8310, askSize: 8310, bid: 5850, bidDepth: 21273447,
bidSize: 20437211, last: 6000, lastSize: 10,
lastTrade: "2015-12-17T23:47:02.081622723Z",ok: true,
quoteTime: "2015-12-17T23:52:55.44241142Z", symbol: "FOOBAR",
venue: "TESTEX"}
iex> Xfighter.Stock.quote!("F", "TESTEX")
** (RequestError) Error 404: Stock F does not trade on venue TESTEX
Specs
sell(non_neg_integer, String.t, String.t, String.t, String.t, non_neg_integer) ::
{:ok, Xfighter.Order.t} |
{:error, tuple}
Place an order to sell a stock.
Examples:
iex> Xfighter.Stock.sell(10, "FOOBAR", "TESTEX", "EXB123456", "market")
{:ok,
%Xfighter.Order{account: "EXB123456", direction: "sell",
fills: [%{price: 5850, qty: 10, ts: "2015-12-17T23:49:14.340308147Z"}],
id: 1637, ok: true, open: false, orderType: "market", originalQty: 10,
price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
ts: "2015-12-17T23:49:14.340304585Z", venue: "TESTEX"}}
iex> Xfighter.Stock.sell(10, "FOOBAR", "TESTEX", "EXB123456", "limit", 50.16)
iex> Xfighter.Stock.sell(10, "FOOBAR", "TESTEX", "EXB123456", "fok", 40)
iex> Xfighter.Stock.sell(10, "FOOBAR", "TESTEX", "EXB123456", "ioc", 20.5)
iex> Xfighter.Stock.sell(10, "F", "TESTEX", "EXB123456", "limit", 50.16)
{:error, {:request, "Error 200: symbol F does not exist on venue TESTEX"}}
Specs
sell!(non_neg_integer, String.t, String.t, String.t, String.t, non_neg_integer) :: Xfighter.Order.t
Place an order to sell a stock.
A RequestError
exception is raised if:
- the venue could not be found
- the stock is not traded on the venue
- you are not authorized to trade on that account
- a request parameter 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.Stock.sell!(10, "FOOBAR", "TESTEX", "EXB123456", "market")
%Xfighter.Order{account: "EXB123456", direction: "sell",
fills: [%{price: 5850, qty: 10, ts: "2015-12-17T23:49:14.340308147Z"}],
id: 1637, ok: true, open: false, orderType: "market", originalQty: 10,
price: 0, qty: 0, symbol: "FOOBAR", totalFilled: 10,
ts: "2015-12-17T23:49:14.340304585Z", venue: "TESTEX"}
iex> Xfighter.Stock.sell!(10, "FOOBAR", "TESTEX", "EXB123456", "limit", 50.16)
iex> Xfighter.Stock.sell!(10, "FOOBAR", "TESTEX", "EXB123456", "fok", 40)
iex> Xfighter.Stock.sell!(10, "FOOBAR", "TESTEX", "EXB123456", "ioc", 20.5)
iex> Xfighter.Stock.sell!(10, "F", "TESTEX", "EXB123456", "limit", 50.16)
** (RequestError) Error 200: symbol F does not exist on venue TESTEX