README.md

# pregão

[prəˈgɐ̃w]

An elixir parser for the [BM&F Bovespa BDI file format](http://www.bmfbovespa.com.br/pt_br/servicos/market-data/consultas/boletim-diario/boletim-diario-do-mercado/).

## What is this

[BM&F Bovespa](http://www.bmfbovespa.com.br/en_us/index.htm) is the main stock exchange in Brazil. It publishes end-of-day data and detailed trading activity using a custom file format called BDI (Boletim diário de informações). BDI files for the last 10 trading days are usually publicly available at [their website](http://www.bmfbovespa.com.br/pt_br/servicos/market-data/consultas/boletim-diario/boletim-diario-do-mercado/).

## Installation

Add `pregao` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [{:pregao, "~> 0.1.0"}]
end
```

## Usage

Call `Pregao.Bdi.parse` specifying the path to the file you want to parse. It will return a struct containing all the information in the BDI file:

```elixir
iex> bdi = Pregao.Bdi.parse("./test/fixtures/bdi0930")
# ... (should output a huge struct)

iex> bdi.header
%Pregao.Bdi.Header{generated_at: ~N[2016-09-30 18:07:00], source: "BOVESPA",
                   trading_date: ~D[2016-09-30]}

iex> Enum.at(bdi.indexes, 21)
%Pregao.Bdi.IndexSummary{id: 24,
                         name: "IND FDO IMOB",
                         prices: %{open: 1810, low: 1809, high: 1818, close: 1816, 
                                   average: 1814, vwap: 1811, settlement: 1815},
                         ytd_range: %{
                           high: %{date: ~D[2016-09-30], value: 1816},
                           low:  %{date: ~D[2016-01-28], value: 1305}},
                         ticker_stats: %{up: 39, down: 17, flat: 11, total: 70},
                         pct_changes:  %{open: 0.33, last: 0.37, week: 1.41, month: 3.02, year: 29.68, 
                                         wtd: 1.41, mtd: 2.77, ytd: 28.89}}
```

## What's with the name?

**Pregão [prəˈgɐ̃w]**: Brazilian Portuguese for [open outcry](https://en.wikipedia.org/wiki/Open_outcry): a method of communication between professionals on a stock exchange or futures exchange typically on a trading floor. It involves shouting and the use of hand signals to transfer information primarily about buy and sell orders.

In Brazilian stock trading circles the word "pregão" is normally used as a synonym for "trading day".

## License

[MIT](https://opensource.org/licenses/MIT). Go crazy.