Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

bovespaParser
=============
A Python parser for BM&F Bovespa Historical Series Files


### Features:
- Parses COTAHISTXXXX.TXT files
- Parses data passed as string array
- Configurable to retrieve specific data:
* Contains market type filters (VISTA, OPCOES, ...)
* Accepts configuration of desired data fields to be retrieved
* Data fields order can be freely specified

### Installing:
pip install bovespaparser
There are no external dependencies.

### Usage
#### Getting started
In the sample code presented bellow, you can check out how to parse a file and print it's data out:
```python
import bovespaparser.bovespaparser as bvparser

with open('filename', 'rU') as f:
result = bvparser.parsedata(f)

print result
```

The results returned by the `parsedata` function consists of a list of lists: a list of records, where a record holds some information-data for a stock paper in a certain day (a line on the given file).

The `parsedata` function has two optional parameters:
```python
def parsedata(data, opts=[CODNEG, DATA, PREABE, PREMIN, PREMAX, PREULT, QUATOT], market=VISTA):
# implementation ...
```
- **opts** parameter: specifies what information should be retrieved for each stock paper tick;
- **market** parameter: specifies the desired market data (filters out other markets)

Calling the function (using the default parameters) would then return a list of records holding:
- **symbol** - the stock symbol (str)
- **date** - the period of the quotation tick (datetime.datetime)
- **open** - stock tick open value (float)
- **min** - stock tick min value (float)
- **max** - stock tick max value (float)
- **close** - stock tick close value (float)
- **volume** - the volume in the period (int)

So, it easy to analyse results:
```python
for symbol, datetime, f_open, f_min, f_max, f_close, volume in results:
# process data ...
```

To find out more about the available parameter options and its meanings, refer to the official BMFBOVESPA documentation (also present on the docs directory).

#### Importing data into pandas
Bellow, a (not so pretty/optimized) example of how to import data from a file and creating `pandas dataframes` for each stock symbol:
```python
# -*- coding: utf-8 -*-


import pandas
import collections
import bovespaparser.bovespaparser as bvparser


class CotahistImporter(object):

def __init__(self, f):
self.dataFrameMap = {}

dataMap = collections.defaultdict(list)
mapping = [("open", 1), ("high", 2), ("low", 3), ("close", 4), ("volume", 5)]

for symbol, datetime, openv, minv, maxv, close, volume in bvparser.parsedata(f):
symbolData = dataMap.get(symbol)
symbolData.append([datetime, openv, maxv, minv, close, volume])

for symbol in dataMap.keys():
dataMap.get(symbol).sort()
data = zip(*dataMap.get(symbol))
timeseries = dict((column_name, pandas.TimeSeries(data[column_index], index=data[0], name=column_name)) for column_name, column_index in mapping)
self.dataFrameMap[symbol] = pandas.DataFrame(timeseries, columns=['open', 'high', 'low', 'close', 'volume'])

def getDataFrameMap(self):
return self.dataFrameMap
```

### Links:
- [BovespaParser Annoucment Blog Post](http://how.i.drycode.it/2012/09/python-bovespa-parser.html)
- [BovespaParser Git Repository]( https://github.com/rhlobo/bovespaParser)
- [Documentation](http://www.bmfbovespa.com.br/shared/iframe.aspx?idioma=pt-br&url=http://www.bmfbovespa.com.br/pt-br/cotacoes-historicas/FormSeriesHistoricas.asp)
(for Bovespa's Historical Series data files)

---------------------------------------
### Any feedback is always appreciated!
- Write to the author: <rhlobo+stockExperiments@gmail.com>

Release files for bovespaparser 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for bovespaparser 0.6.5
File Size Uploaded
bovespaparser-0.6.5.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bovespaparser 0.6.5
File Interpreter ABI Platform
bovespaparser-0.6.5-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / bovespaparser-0.6.5.tar.gz

Download URL bovespaparser-0.6.5.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
235592bf677cf9527c5d7abe07f4aef3f88bd175af521ac7b2fb717ad869127c
BLAKE2b-256 checksum
How to use checksums
57fbf6e440d9ff3c17cbec9fd31ad0c5517e483f298104c0a30092b31643c8e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / bovespaparser-0.6.5-py3-none-any.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL bovespaparser-0.6.5-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db38d2fb57479adb2bb43381c3292d51be087860862a253178acb1dc1ae42141
BLAKE2b-256 checksum
How to use checksums
6ceaebfcced20eb84780b0945dcdaef854d45d6cb7a6b1bd47dd6b96d134349a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.6.5 This release

2 release files

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.5

0.4

0.3

1 release file

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page