Skip to main content

package description

Project description

getBISy

A Python package for programmatically fetching and working with Bank for International Settlements (BIS) datasets.

The package currently allows access to the following sets of international financial statistics via the BIS data portal.

  • Central Bank policy rates
  • Bilateral exchange rates
  • Locational banking statistics
  • International debt securities
  • Global liquidity data

All major parameters are declared in custom enums to ensure error-resistant paramaterisation.

Installation

Clone the repository and install dependencies:

pip install -r requirements.txt

Usage

The below covers gathering and plotting two datasets gathered from the BIS Data Portal using this package: locational banking statistics (LBS) and Global Liquidity Indicators (GLI)

Locational Banking Statistics

Import the relevant data functions and enums:

# Test LBS

import getBISy.data as data
import getBISy.enums as enums

# Developing Asia and Pacific, Non-banks, Cross-border Credit, USD
s1 = data.get_locational_banking_data('Q',
                                        enums.LbsMeasure.Stocks,
                                        enums.Position.Claims,
                                        enums.Instrument.LoansAndDeposits,
                                        'USD',
                                        enums.CurrencyType.All,
                                        '5J',
                                        enums.Institution.All,
                                        '5A',
                                        enums.Sector.NonBanks,
                                        enums.Region.DevelopingAsiaAndPacific,
                                        enums.PositionType.CrossBorder)

s1['Description'] = 'Developing Asia and Pacific, Non-banks, Cross-border Credit, USD'

# European Developed Countries, Non-banks, Cross-border Credit, USD
s2 = data.get_locational_banking_data('Q',
                                        enums.LbsMeasure.Stocks,
                                        enums.Position.Claims,
                                        enums.Instrument.LoansAndDeposits,
                                        'USD',
                                        enums.CurrencyType.All,
                                        '5J',
                                        enums.Institution.All,
                                        '5A',
                                        enums.Sector.NonBanks,
                                        enums.Region.EuropeanDevelopedCountries,
                                        enums.PositionType.CrossBorder)

s2['Description'] = 'European Developed Countries, Non-banks, Cross-border Credit, USD'

Once you have the data, we can plot it and give it a descriptive title.

from pandas import DataFrame, PeriodIndex, to_numeric
import plotly.express as px
import plotly.graph_objects as go

fig = go.Figure()

for df in [s1, s2]:
    # Convert quarterly periods to timestamps
    df['Date'] = PeriodIndex(df['Date'], freq='Q').to_timestamp()
    df['Value'] = to_numeric(df['Value'], errors='coerce')
    df = df.dropna(subset=['Value'])
    df = df.sort_values(by='Date')

    fig.add_trace(go.Scatter(
        x=df['Date'],
        y=df['Value'],
        mode='lines+markers',
        name=df['Description'].iloc[0]
    ))

fig.update_layout(
    title=dict(
        text='Paths of cross-border bank credit between Europe vs. Developing Asia are diverging',
        x=0.5,
        xanchor='center',
        font=dict(size=20)
    ),
    xaxis_title='Date',
    yaxis_title='USD (millions)',
    hovermode='x unified',
    yaxis=dict(autorange=True, tickformat=".0f"),
    width=1000,
    height=600,
    legend=dict(
        title=dict(text='Series'),
        font=dict(size=12),
        orientation='h',
        yanchor='top',
        y=-0.2,  # Move legend below the plot
        xanchor='center',
        x=0.5
    )
)

LBS Example

Global Liquidity Indicators

As in the LBS example above, import the relevant functions and enums:

import getBISy.data as data
import getBISy.enums as enums

s1 = data.get_global_liquidity_data(freq='Q',
                               currency='TO1',
                               borrowing_country=enums.Region.DevelopingAsiaAndPacific,
                               borrowing_sector=enums.Sector.NonFinancialPrivateSector,
                               lending_sector=enums.Sector.Banks,
                               position_type= enums.PositionType.Local,
                               instrument_type=enums.Instrument.Credit,
                               unit_of_measure=enums.UnitOfMeasure.PercentageOfGDP
                               )

s2 = data.get_global_liquidity_data(freq='Q',
                               currency='TO1',
                               borrowing_country=enums.Region.EuroArea,
                               borrowing_sector=enums.Sector.NonFinancialPrivateSector,
                               lending_sector=enums.Sector.Banks,
                               position_type= enums.PositionType.Local,
                               instrument_type=enums.Instrument.Credit,
                               unit_of_measure=enums.UnitOfMeasure.PercentageOfGDP
                               )

Given the below plot in the context of the above, we infer that local bank credit to non-financial private sector in Developing Asia is replacing cross-border credit.

from pandas import PeriodIndex, to_numeric
import plotly.express as px
import plotly.graph_objects as go

fig = go.Figure()

for df in [s1, s2]:
    # Convert quarterly periods to timestamps
    df['Date'] = PeriodIndex(df['Date'], freq='Q').to_timestamp()
    df['Value'] = to_numeric(df['Value'], errors='coerce')
    df = df.dropna(subset=['Value'])
    df = df.sort_values(by='Date')

    fig.add_trace(go.Scatter(
        x=df['Date'],
        y=df['Value'],
        mode='lines+markers',
        name=df['Description'].iloc[0]
    ))

fig.update_layout(
    title=dict(
        text='Local bank credit to non-financial private sector in Developing Asia is replacing cross-border credit',
        x=0.5,
        xanchor='center',
        font=dict(size=20)
    ),
    xaxis_title='Date',
    yaxis_title='Percentage of GDP',
    hovermode='x unified',
    yaxis=dict(autorange=True, tickformat=".0f"),
    width=1000,
    height=600,
    legend=dict(
        title=dict(text='Series'),
        font=dict(size=12),
        orientation='h',
        yanchor='top',
        y=-0.2,  # Move legend below the plot
        xanchor='center',
        x=0.5
    )
)

GLI Example

Project Structure

getBISy/
├── src/
│   ├── __init__.py
│   ├── data.py         # Main data-fetching functions
│   ├── enums.py        # Enum definitions for all API parameters
│   └── fetcher.py      # Fetcher classes for making API requests
├── requirements.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

getbisy-0.0.6.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

getbisy-0.0.6-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file getbisy-0.0.6.tar.gz.

File metadata

  • Download URL: getbisy-0.0.6.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for getbisy-0.0.6.tar.gz
Algorithm Hash digest
SHA256 60b8776b13ff9ce86e382fbafa1802ce9295941d84c4d8764b6d198377f4a055
MD5 448c1fdc67a5809a44f8a0e6efb82003
BLAKE2b-256 8471dde65b856b6fde09f26b3b414a79d82fbb1ea3f5f1badc544c4034f6c72f

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbisy-0.0.6.tar.gz:

Publisher: publish.yml on matthew-potts/getBISy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file getbisy-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: getbisy-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for getbisy-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cf37486426ff9c84294a240ab1af008bff915ecd48ace1489349ed234380eb3d
MD5 f5dde8eccf8b596405a07aa549466ad9
BLAKE2b-256 bc887efea50313e914c3f7c2c8fa03fa105fa3652d531fe3ca9c2b61ae040a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbisy-0.0.6-py3-none-any.whl:

Publisher: publish.yml on matthew-potts/getBISy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page