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
  • Debt securities

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.11.tar.gz (10.5 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.11-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: getbisy-0.0.11.tar.gz
  • Upload date:
  • Size: 10.5 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.11.tar.gz
Algorithm Hash digest
SHA256 2511fb967f6e9740a50b63102eb8acdc0a65cc5c165a67e4810d541589d570b6
MD5 37b7e993a86175985cb50c311765aa4b
BLAKE2b-256 7437581c116417724b6521c21a4f34a4b82c5851cc696934d8805a33b6f3866c

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbisy-0.0.11.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.11-py3-none-any.whl.

File metadata

  • Download URL: getbisy-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 9.7 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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 fe4d6bdd6af62725004f9337d951ad96652073607d05b0f3edf9c2022c181eea
MD5 28d19bf0aca432633405798918a8b707
BLAKE2b-256 552409582c90e345d1526adf919ad950ce11dbe03f19b92083412fa40071021b

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbisy-0.0.11-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