pregão
[prəˈgɐ̃w]
An elixir parser for the BM&F Bovespa BDI file format.
What is this
BM&F Bovespa 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.
Installation
Add pregao to your list of dependencies in mix.exs:
def deps do
[{:pregao, "~> 0.1.0"}]
endUsage
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:
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: 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. Go crazy.