Dealer

An api library for Stockfighter in Elixir, providing functions to interact with the Stock as well as the GM apis.

Build StatusHex.pm VersionDocsHex.pm Downloads

Installation

  1. Add dealer to your list of dependencies in mix.exs:

    def deps do

     [{:dealer, "~> 0.0.1"}]

    end

  2. Ensure dealer is started before your application:

    def application do

     [applications: [:dealer]]

    end

Usage

Start application

If you havn’t specified starting dealer application in your mix.exs, or you are in a normal iex session, you should explicitly call Dealer.start to start the application.

Authentication

You should set DEALER_API_KEY environment variable, or set the application env by Application.put_env(:dealer, :api_key, "your_api_key").

Response

If the api request is successful, the response will be a Dealer.Response struct, which is a struct defined containing three fields:

Or something bad might happen during the reuqest, the response will be: {:error, term}.

API Documentation

Check The Api Is Up

Documentation link: https://starfighter.readme.io/docs/heartbeat

iex> Dealer.Heartbeat.get

Check The Venue Is Up

Documentation link: https://starfighter.readme.io/docs/venue-healthcheck

iex> Dealer.Venue.heartbeat("RQOVEX")

Stocks on a Venue

Documentation link: https://starfighter.readme.io/docs/list-stocks-on-venue

iex> Dealer.Stocks.on_venue("RQOVEX")

The Orderbook For A Stock

Documentation link: https://starfighter.readme.io/docs/get-orderbook-for-stock

iex> Dealer.Stock.orderbook("RQOVEX", "DIUW")

A New Order For A Stock

Documentation link: https://starfighter.readme.io/docs/place-new-order

iex> Dealer.Orders.create("QWYIEX", "YPII", %{account: "TOB1728377", price: 33, qty: 100, direction: "buy", orderType: "limit"})

A Quote For A Stock

Documentation link: https://starfighter.readme.io/docs/a-quote-for-a-stock

iex> Dealer.Stock.quote("LBPTEX", "GVOE")

Status For An Existing Order

Documentaion link: https://starfighter.readme.io/docs/status-for-an-existing-order

iex> Dealer.Order.status("LBPTEX", "GVOE", 306)

Cancel An Order

Documentation link: https://starfighter.readme.io/docs/cancel-an-order

iex> Dealer.Order.cancel("LBPTEX", "GVOE", 306)

Status For All Orders

Documentation link: https://starfighter.readme.io/docs/status-for-all-orders

iex> Dealer.Orders.status("LBPTEX", "ACCOUNT_NAME")

Status For All Orders In A Stock

Documentation link: https://starfighter.readme.io/docs/status-for-all-orders-in-a-stock

iex> Dealer.Orders.status("LBPTEX", "ACCOUNT_NAME", "GVOE")