exmarket

ExMarket is a Hex Package designed to provide a clean interface for retrieving real-time stock and crypto data.


Keywords
bitcoin, cryptocurrency, elixir, stock-market, stock-prices
License
MIT

Documentation

CircleCI License

Exmarket

An OTP application that provides real time stock & crypto data. This project is a WIP under active development.

Installation

Package is available in Hex, and can be installed by adding exmarket to your list of dependencies in mix.exs:

def deps do
  [
    {:exmarket, "~> 0.2.0"}
  ]
end

The docs can be found at https://hexdocs.pm/exmarket.

Getting Started

After adding {:exmarket, "~> 0.2.0"} to your list of dependencies, access the API either by creating a unique alias or referring to Exmarket directly. For example:

defmodule MyApp do
  alias Exmarket, as: Market

  def get_price(ticker) do
    Market.get_price(ticker)
  end

end

Calling MyApp.get_price("aapl") returns "204.53".

Calling MyApp.get_price("tsla") returns "258.66".

Previously retrieved stock prices are stored in GenServer state so calling MyApp.get_state() at this point would return %{"aapl" => 204.53, "tsla" => 258.66}.

The current state can be cleared by calling MyApp.reset_state(), which returns :ok.

Getting prices for multiple stocks

Exmarket now supports batch quotes! Simply pass a list of strings for the stock prices you want. For example, Exmarket.batch_quote(["aapl", "tsla", "fb", "msft"]) returns

%{
  "aapl" => 207.16,
  "fb" => 182.58,
  "msft" => 125.01,
  "tsla" => 258.66
  }

If experience any bugs please file an issue so that I may address the concern. Or, if you would like to contribute please feel free to submit a pull request.