This is a simple Yahoo Finance module capable of getting current data for several symbols in bulk as well as individually. Additional features include getting stock symbols filtered by stock market.
-
Add yahoo_finanza to your list of dependencies in
mix.exs
:def deps do [{:yahoo_finanza, "~> 0.3.0"}] end
-
Ensure yahoo_finanza is started before your application:
def application do [applications: [:yahoo_finanza]] end
Getting symbol list for a market
YahooFinanza.Symbol.symbols_for "market" ## => {:ok, ["symbol1", "symbol2", ..., "symboln"]}
Note: The available markets are: "amex", "nyse", "sp_500", "dow_jones", "nasdaq" To add a new market or listing simply add the csv file to the markets directory and add the market or listing name to the markets.csv file.
Getting stock quote for a single symbol
{:ok, quotes} = YahooFinanza.Quote.fetch(["AAPL"]) ## => {:ok, [%{"Symbol" => "AAPL", ... }]}
It's properties can be accessed like so:
quote = quotes |> List.first
quote["Ask"] ## => 12.0
Getting stock quote for multiple symbols
{:ok, quotes} = YahooFinanza.Quote.fetch(["AAPL", "FB"]) ## => {:ok, [%{"Symbol" => "AAPL", ... }, %{"Symbol" => "FB", ... }]}
Each quote can be accessed like so:
apple = quotes |> List.first ## => %{"Symbol" => "AAPL", ... }
Combining the Symbol and Quote Modules
{:ok, nyse_symbols} = YahooFinanza.Symbol.symbols_for "nyse"
{:ok, nyse_quotes} = nyse_symbols |> Enum.take(100) |> YahooFinanza.Quote.fetch
- Fork it ( https://github.com/[my-github-username]/yahoo_finanza/fork )
- Create your feature branch (
git checkout -b feature/my_new_feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Daniel Berkompas (@danielberkompas)
- Benjamin Tan Wei Hao
- Johnny Mejias (@datajohnny)
- Thiago Araújo (@thiagoa)