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
)
)
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
)
)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file getbisy-0.0.2.tar.gz.
File metadata
- Download URL: getbisy-0.0.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc68badcd03aad8ee6ec3bf450db3408637d795769ec29bf3302536d5e589a0e
|
|
| MD5 |
6ea17849044ec6d66c7c02e241595f67
|
|
| BLAKE2b-256 |
ac5c87db67be781b868792cd98ff36940009fba5d19c45c1eeba9e781a7834d8
|
Provenance
The following attestation bundles were made for getbisy-0.0.2.tar.gz:
Publisher:
publish.yml on matthew-potts/getBISy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
getbisy-0.0.2.tar.gz -
Subject digest:
bc68badcd03aad8ee6ec3bf450db3408637d795769ec29bf3302536d5e589a0e - Sigstore transparency entry: 427707541
- Sigstore integration time:
-
Permalink:
matthew-potts/getBISy@ec0cf3bfbbc15ce322053d44aa1b1bd03737a1ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthew-potts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ec0cf3bfbbc15ce322053d44aa1b1bd03737a1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file getbisy-0.0.2-py3-none-any.whl.
File metadata
- Download URL: getbisy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
361f42322a84c173851a23e66cadc35a2a7e47992b8b552e150d69af281f0573
|
|
| MD5 |
a643e2548d69bf556ccd6ecb1a8b9e48
|
|
| BLAKE2b-256 |
1acacd17b9d53a36bc0b9fe44aacb34e4d4518bb060d7eae461db72f5e95c92c
|
Provenance
The following attestation bundles were made for getbisy-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on matthew-potts/getBISy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
getbisy-0.0.2-py3-none-any.whl -
Subject digest:
361f42322a84c173851a23e66cadc35a2a7e47992b8b552e150d69af281f0573 - Sigstore transparency entry: 427707544
- Sigstore integration time:
-
Permalink:
matthew-potts/getBISy@ec0cf3bfbbc15ce322053d44aa1b1bd03737a1ae -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthew-potts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ec0cf3bfbbc15ce322053d44aa1b1bd03737a1ae -
Trigger Event:
push
-
Statement type: