https://github.com/brunobcardoso/pyptax
PyPtax is a Python library and CLI to retrieve information on Ptax rates
https://github.com/brunobcardoso/pyptax
bcb ptax python
Last synced: 5 months ago
JSON representation
PyPtax is a Python library and CLI to retrieve information on Ptax rates
- Host: GitHub
- URL: https://github.com/brunobcardoso/pyptax
- Owner: brunobcardoso
- License: mit
- Created: 2020-01-20T04:43:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-21T02:52:54.000Z (over 5 years ago)
- Last Synced: 2025-09-29T07:08:05.543Z (9 months ago)
- Topics: bcb, ptax, python
- Language: Python
- Homepage: https://pyptax.readthedocs.io
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
PyPtax
PyPtax is a Python library and CLI to retrieve information on Ptax rates
Features |
Installation |
Quickstart |
Documentation |
Contributing
## What is Ptax?
[Ptax exchange rate](https://www.bcb.gov.br/conteudo/relatorioinflacao/EstudosEspeciais/EE042_A_taxa_de_cambio_de_referencia_Ptax.pdf)
is the reference exchange rate for U.S. Dollar, expressed as the amount of Brazilian Reais per one U.S. Dollar,
published by the [Central Bank of Brazil](https://www.bcb.gov.br/en).
## Features
- Closing Ptax rates for a requested date
- Historical Ptax rates for a requested period
- Intermediary Ptax rates for a requested date
## Installation
```bash
$ pip install pyptax
```
## Quickstart
### Closing Ptax rates for a requested date
**Command line:**
```bash
$ pyptax close --date 2020-01-20
```
**Module:**
```
>>> from pyptax import ptax
>>> bulletin = ptax.close("2020-01-20")
>>> bulletin.as_dict
{
"datetime": "2020-01-20 13:09:02.871",
"bid": 4.1823,
"ask": 4.1829,
"bulletin_type":
"close"
}
>>> bulletin.datetime
"2020-01-20 13:09:02.871"
>>> bulletin.bid
4.1823
>>> bulletin.ask
4.1829
```
### Historical Ptax rates for a requested period
**Command line:**
```bash
$ pyptax historical --start_date 2020-01-01 --end_date 2020-01-05
```
**Module:**
```
>>> from pyptax import ptax
>>> historical_bulletin = ptax.historical('2020-01-01', '2020-01-05')
>>> historical_bulletin
HistoricalBulletin(
start_date="2020-01-01",
end_date="2020-01-03",
bulletins=[
Bulletin("2020-01-02 13:11:10.762", 4.0207, 4.0213, "close"),
Bulletin("2020-01-03 13:06:22.606", 4.0516, 4.0522, "close"),
],
)
>>> historical_bulletin.as_dict
{
"start_date": "2020-01-01",
"end_date": "2020-01-03",
"bulletins": [
{
"datetime": "2020-01-02 13:11:10.762",
"bid": 4.0207,
"ask": 4.0213,
"bulletin_type": "close"
},
{
"datetime": "2020-01-03 13:06:22.606",
"bid": 4.0516,
"ask": 4.0522,
"bulletin_type": "close"
},
],
}
```
> :warning: Enter all dates in the format **_YYYY-MM-DD_**
## Documentation
The full documentation is available on https://pyptax.readthedocs.io/.
## Contributing
Please see the [contributing page](https://github.com/brunobcardoso/pyptax/blob/master/CONTRIBUTING.rst)
for guidance on setting up a development environment and how to contribute.