Skip to main content

TiMBA Trade Logo


Bilateral Trade Module of TiMBA

This is an additional module for TiMBA that computes bilateral trade flows per commodity and balances them to the export and import totals. BACI trade data serves as the starting point for bilateral trade; the balancing is done with RAS (iterative proportional fitting).

Workflow

  1. TiMBA provides the total export and import targets of each country and a growth factor for bilateral trade, based on price developments in both countries.
  2. The BACI database provides the initial information on bilateral exports.
  3. The RAS method scales rows and columns alternately until row sums = export targets and column sums = import targets.
  4. This process is repeated recursively, with each period building on the previous result, until all TiMBA periods are processed.
  5. The results are returned as a pandas DataFrame or, if the saving flag is activated, saved as a Parquet file.

Notes

  • Within the RAS process, an additional RoW (Rest of World) node is added to account for countries that are not represented in TiMBA.
  • Countries with a target but no observed trade are moved to RoW.
  • RoW absorbs any difference between total exports and total imports.
  • RAS settings can be changed in src/Trade_Module/config/user_config.yml.

Run

The module can be executed in two ways:

  1. Run the module directly from the repository root:

    python -m src.timba_trade.main
    

2. Run the Module via the Command-Line Interface (CLI)

After installing the package, you can run the trade module directly from the command line:

trade_module run

The CLI supports the following optional arguments:

  • -S / --save_file: Controls whether the output is saved as a Parquet file. Defaults to True.
  • -P / --folder_path: Specifies the directory containing the input data. The output files and logs are also saved to this directory.

Example:

trade_module run -S True -P "C:\your_data_folder"

Default behavior:

  • If --save_file is omitted, the output is automatically saved as a Parquet file.
  • If --folder_path is omitted, the module uses its package directory as the default location for input data, output files, and logs.

Note: Replace C:\your_data_folder with the path to your actual data directory.

Expected folder structure

The specified folder_path must contain the following files in the indicated directory structure:

your_data_folder/
├── data/
│   └── input/
│       └── BACI_DATA_as_vector.parquet
│       └── timba_result.pkl

Logging

The module writes a log file for debugging to src/Trade_Module/data/output/logs (LOG_PATH). The console shows INFO; the log file additionally contains DEBUG details.

Metadata

Release files for TiMBA-Trade 0.1.4

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

Source distribution (sdist)

Source distribution for TiMBA-Trade 0.1.4
File Size Uploaded Provenance Actions
timba_trade-0.1.4.tar.gz 29.6 kB Without provenance Details for timba_trade-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for TiMBA-Trade 0.1.4
File Interpreter ABI Platform Actions
timba_trade-0.1.4-py3-none-any.whl Python 3 none any Details for timba_trade-0.1.4-py3-none-any.whl

Total release size: 63.4 kB

Release files / timba_trade-0.1.4.tar.gz

Download URL timba_trade-0.1.4.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3a02e908a8b8c06f68438242bfec882c0cde0698bd8c3f799ed9ac91dceb8dd0
BLAKE2b-256 checksum
How to use checksums
620e08c4fed7f46cff6e67fa0a652d33672089bd359587789a995c20fe1385e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / timba_trade-0.1.4-py3-none-any.whl

Download URL timba_trade-0.1.4-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e07ac0d836a73c99f02f4b417ad7cdd36e4eb544a84ba0eb7d5f745e18da0f1
BLAKE2b-256 checksum
How to use checksums
b17e244283a6b6d417de1b0d45f2fd9cadb3a8f1f701f8e21b678658ea7a3dfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for TiMBA-Trade 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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