Skip to main content

B3 CDI Curve by Fluxonaut

This package is a collection of Python scripts that extracts, consolidates and interpolates data from the Brazilian CDI Curve provided on the B3 Exchange web site. It allows you to produce a historical data series for any given duration (considering it respects the maximum available duration). It stores all the term structure of the CDI curve in a local SQLite database as well.

Setup and usage

Just install from PyPI as shown below.

pip install b3-cdi-curve

Now just import it to your project. The package exposes two methods, sync_db() and create_time_series(duration: int). Below you can find a basic usage example and a more detailed explanation.

import b3cdi

# Create and/or update local DB
b3cdi.sync_db()

# Create time series for the desired duration (in days)
b3cdi.create_time_series(360)

Creating database

sync_db

This method loops through all the dates between the beginning of the series and the last working day looking for the prices on the B3 web site. It then generates and saves a local SQLite database (located on ./output/cdi.db).

The first run takes around two and half hours to build the database and it takes around 1.35 GB of disk space.

After it runs once, it'll check for the last inserted date, so it'll look only for working days after the last update. This keeps the database updated for each time you run the code.

create_time_series

create_time_series(duration: int)

This method queries the local database to produce a Pandas DataFrame with the historical series of the requested duration. It then saves it as a CSV file on the ./output/ folder. The parameter of the method is where you input your desired duration (e.g. 360).

Contributing

Pull requests are welcome. Please open an issue first to discuss what you would like to change.

To-do

  • Tests
  • Optimize db size

Fluxonaut

This code was made possible by the amazing people working at Fluxonaut who dedicated their free time to help the community. Please be sure to check our our website at https://fluxonaut.com.

License

This project is under the MIT license.

Metadata

Release files for b3-cdi-curve 1.2.0

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

Source distribution (sdist)

Source distribution for b3-cdi-curve 1.2.0
File Size Uploaded
b3-cdi-curve-1.2.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for b3-cdi-curve 1.2.0
File Interpreter ABI Platform
b3_cdi_curve-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / b3-cdi-curve-1.2.0.tar.gz

Download URL b3-cdi-curve-1.2.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c30ec1932b838de20962abb67410a74d7306c2569190ef0c73a92caea53c7e47
BLAKE2b-256 checksum
How to use checksums
45654baa3f44bee3724f90ee97a4997cd9762c85c60efbbf1f851e04bdc39235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.4

Release files / b3_cdi_curve-1.2.0-py3-none-any.whl

Download URL b3_cdi_curve-1.2.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b455d5ee7af4ed651068d6917fcf9f6a0b20435508ae8480a5f52e458f82202
BLAKE2b-256 checksum
How to use checksums
d68835c25ae0c1b60ba1295492bc6e405015a80edfeb0913da8d3375e1dcdd11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

1.2.0 This release

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