mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
* add ecb balance of payments * missing __init__.py files
This commit is contained in:
@@ -209,3 +209,43 @@ def test_economy_gdp_real(params, headers):
|
||||
result = requests.get(url, headers=headers, timeout=10)
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
(
|
||||
{
|
||||
"report_type": "summary",
|
||||
"frequency": "monthly",
|
||||
"country": None,
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"report_type": "direct_investment",
|
||||
"frequency": "monthly",
|
||||
"country": None,
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"report_type": "main",
|
||||
"frequency": "quarterly",
|
||||
"country": "united_states",
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_balance_of_payments(params, headers):
|
||||
params = {p: v for p, v in params.items() if v}
|
||||
|
||||
query_str = get_querystring(params, [])
|
||||
url = f"http://0.0.0.0:8000/api/v1/economy/balance_of_payments?{query_str}"
|
||||
result = requests.get(url, headers=headers, timeout=10)
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
@@ -174,3 +174,42 @@ def test_economy_gdp_real(params, obb):
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
(
|
||||
{
|
||||
"report_type": "summary",
|
||||
"frequency": "monthly",
|
||||
"country": None,
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"report_type": "direct_investment",
|
||||
"frequency": "monthly",
|
||||
"country": None,
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"report_type": "main",
|
||||
"frequency": "quarterly",
|
||||
"country": "united_states",
|
||||
"provider": "ecb",
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_balance_of_payments(params, obb):
|
||||
params = {p: v for p, v in params.items() if v}
|
||||
|
||||
result = obb.economy.balance_of_payments(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
@@ -49,3 +49,14 @@ def risk_premium(
|
||||
) -> OBBject[BaseModel]:
|
||||
"""Historical Market Risk Premium."""
|
||||
return OBBject(results=Query(**locals()).execute())
|
||||
|
||||
|
||||
@router.command(model="BalanceOfPayments")
|
||||
def balance_of_payments(
|
||||
cc: CommandContext,
|
||||
provider_choices: ProviderChoices,
|
||||
standard_params: StandardParams,
|
||||
extra_params: ExtraParams,
|
||||
) -> OBBject[BaseModel]:
|
||||
"""Balance of Payments Reports."""
|
||||
return OBBject(results=Query(**locals()).execute())
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
"""Balance of Payments Models"""
|
||||
|
||||
from datetime import (
|
||||
date as dateType,
|
||||
)
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
|
||||
|
||||
class BalanceOfPaymentsQueryParams(QueryParams):
|
||||
"""Balance Of Payments Query Params."""
|
||||
|
||||
|
||||
class ECBMain(Data):
|
||||
"""ECB Main Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
current_account: Optional[float] = Field(
|
||||
default=None, description="Current Account Balance (Billions of EUR)"
|
||||
)
|
||||
goods: Optional[float] = Field(
|
||||
default=None, description="Goods Balance (Billions of EUR)"
|
||||
)
|
||||
services: Optional[float] = Field(
|
||||
default=None, description="Services Balance (Billions of EUR)"
|
||||
)
|
||||
primary_income: Optional[float] = Field(
|
||||
default=None, description="Primary Income Balance (Billions of EUR)"
|
||||
)
|
||||
secondary_income: Optional[float] = Field(
|
||||
default=None, description="Secondary Income Balance (Billions of EUR)"
|
||||
)
|
||||
capital_account: Optional[float] = Field(
|
||||
default=None, description="Capital Account Balance (Billions of EUR)"
|
||||
)
|
||||
net_lending_to_rest_of_world: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Balance of net lending to the rest of the world (Billions of EUR)",
|
||||
)
|
||||
financial_account: Optional[float] = Field(
|
||||
default=None, description="Financial Account Balance (Billions of EUR)"
|
||||
)
|
||||
direct_investment: Optional[float] = Field(
|
||||
default=None, description="Direct Investment Balance (Billions of EUR)"
|
||||
)
|
||||
portfolio_investment: Optional[float] = Field(
|
||||
default=None, description="Portfolio Investment Balance (Billions of EUR)"
|
||||
)
|
||||
financial_derivatives: Optional[float] = Field(
|
||||
default=None, description="Financial Derivatives Balance (Billions of EUR)"
|
||||
)
|
||||
other_investment: Optional[float] = Field(
|
||||
default=None, description="Other Investment Balance (Billions of EUR)"
|
||||
)
|
||||
reserve_assets: Optional[float] = Field(
|
||||
default=None, description="Reserve Assets Balance (Billions of EUR)"
|
||||
)
|
||||
errors_and_ommissions: Optional[float] = Field(
|
||||
default=None, description="Errors and Omissions (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBSummary(Data):
|
||||
"""ECB Summary Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
current_account_credit: Optional[float] = Field(
|
||||
default=None, description="Current Account Credit (Billions of EUR)"
|
||||
)
|
||||
current_account_debit: Optional[float] = Field(
|
||||
default=None, description="Current Account Debit (Billions of EUR)"
|
||||
)
|
||||
current_account_balance: Optional[float] = Field(
|
||||
default=None, description="Current Account Balance (Billions of EUR)"
|
||||
)
|
||||
goods_credit: Optional[float] = Field(
|
||||
default=None, description="Goods Credit (Billions of EUR)"
|
||||
)
|
||||
goods_debit: Optional[float] = Field(
|
||||
default=None, description="Goods Debit (Billions of EUR)"
|
||||
)
|
||||
services_credit: Optional[float] = Field(
|
||||
default=None, description="Services Credit (Billions of EUR)"
|
||||
)
|
||||
services_debit: Optional[float] = Field(
|
||||
default=None, description="Services Debit (Billions of EUR)"
|
||||
)
|
||||
primary_income_credit: Optional[float] = Field(
|
||||
default=None, description="Primary Income Credit (Billions of EUR)"
|
||||
)
|
||||
primary_income_employee_compensation_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Primary Income Employee Compensation Credit (Billions of EUR)",
|
||||
)
|
||||
primary_income_debit: Optional[float] = Field(
|
||||
default=None, description="Primary Income Debit (Billions of EUR)"
|
||||
)
|
||||
primary_income_employee_compensation_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Primary Income Employee Compensation Debit (Billions of EUR)",
|
||||
)
|
||||
secondary_income_credit: Optional[float] = Field(
|
||||
default=None, description="Secondary Income Credit (Billions of EUR)"
|
||||
)
|
||||
secondary_income_debit: Optional[float] = Field(
|
||||
default=None, description="Secondary Income Debit (Billions of EUR)"
|
||||
)
|
||||
capital_account_credit: Optional[float] = Field(
|
||||
default=None, description="Capital Account Credit (Billions of EUR)"
|
||||
)
|
||||
capital_account_debit: Optional[float] = Field(
|
||||
default=None, description="Capital Account Debit (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBServices(Data):
|
||||
"""ECB Services Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
services_total_credit: Optional[float] = Field(
|
||||
default=None, description="Services Total Credit (Billions of EUR)"
|
||||
)
|
||||
services_total_debit: Optional[float] = Field(
|
||||
default=None, description="Services Total Debit (Billions of EUR)"
|
||||
)
|
||||
transport_credit: Optional[float] = Field(
|
||||
default=None, description="Transport Credit (Billions of EUR)"
|
||||
)
|
||||
transport_debit: Optional[float] = Field(
|
||||
default=None, description="Transport Debit (Billions of EUR)"
|
||||
)
|
||||
travel_credit: Optional[float] = Field(
|
||||
default=None, description="Travel Credit (Billions of EUR)"
|
||||
)
|
||||
travel_debit: Optional[float] = Field(
|
||||
default=None, description="Travel Debit (Billions of EUR)"
|
||||
)
|
||||
financial_services_credit: Optional[float] = Field(
|
||||
default=None, description="Financial Services Credit (Billions of EUR)"
|
||||
)
|
||||
financial_services_debit: Optional[float] = Field(
|
||||
default=None, description="Financial Services Debit (Billions of EUR)"
|
||||
)
|
||||
communications_credit: Optional[float] = Field(
|
||||
default=None, description="Communications Credit (Billions of EUR)"
|
||||
)
|
||||
communications_debit: Optional[float] = Field(
|
||||
default=None, description="Communications Debit (Billions of EUR)"
|
||||
)
|
||||
other_business_services_credit: Optional[float] = Field(
|
||||
default=None, description="Other Business Services Credit (Billions of EUR)"
|
||||
)
|
||||
other_business_services_debit: Optional[float] = Field(
|
||||
default=None, description="Other Business Services Debit (Billions of EUR)"
|
||||
)
|
||||
other_services_credit: Optional[float] = Field(
|
||||
default=None, description="Other Services Credit (Billions of EUR)"
|
||||
)
|
||||
other_services_debit: Optional[float] = Field(
|
||||
default=None, description="Other Services Debit (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBInvestmentIncome(Data):
|
||||
"""ECB Investment Income Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
investment_total_credit: Optional[float] = Field(
|
||||
default=None, description="Investment Total Credit (Billions of EUR)"
|
||||
)
|
||||
investment_total_debit: Optional[float] = Field(
|
||||
default=None, description="Investment Total Debit (Billions of EUR)"
|
||||
)
|
||||
equity_credit: Optional[float] = Field(
|
||||
default=None, description="Equity Credit (Billions of EUR)"
|
||||
)
|
||||
equity_reinvested_earnings_credit: Optional[float] = Field(
|
||||
default=None, description="Equity Reinvested Earnings Credit (Billions of EUR)"
|
||||
)
|
||||
equity_debit: Optional[float] = Field(
|
||||
default=None, description="Equity Debit (Billions of EUR)"
|
||||
)
|
||||
equity_reinvested_earnings_debit: Optional[float] = Field(
|
||||
default=None, description="Equity Reinvested Earnings Debit (Billions of EUR)"
|
||||
)
|
||||
debt_instruments_credit: Optional[float] = Field(
|
||||
default=None, description="Debt Instruments Credit (Billions of EUR)"
|
||||
)
|
||||
debt_instruments_debit: Optional[float] = Field(
|
||||
default=None, description="Debt Instruments Debit (Billions of EUR)"
|
||||
)
|
||||
portfolio_investment_equity_credit: Optional[float] = Field(
|
||||
default=None, description="Portfolio Investment Equity Credit (Billions of EUR)"
|
||||
)
|
||||
portfolio_investment_equity_debit: Optional[float] = Field(
|
||||
default=None, description="Portfolio Investment Equity Debit (Billions of EUR)"
|
||||
)
|
||||
portfolio_investment_debt_instruments_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Portfolio Investment Debt Instruments Credit (Billions of EUR)",
|
||||
)
|
||||
portofolio_investment_debt_instruments_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Portfolio Investment Debt Instruments Debit (Billions of EUR)",
|
||||
)
|
||||
other_investment_credit: Optional[float] = Field(
|
||||
default=None, description="Other Investment Credit (Billions of EUR)"
|
||||
)
|
||||
other_investment_debit: Optional[float] = Field(
|
||||
default=None, description="Other Investment Debit (Billions of EUR)"
|
||||
)
|
||||
reserve_assets_credit: Optional[float] = Field(
|
||||
default=None, description="Reserve Assets Credit (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBDirectInvestment(Data):
|
||||
"""ECB Direct Investment Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
assets_total: Optional[float] = Field(
|
||||
default=None, description="Assets Total (Billions of EUR)"
|
||||
)
|
||||
assets_equity: Optional[float] = Field(
|
||||
default=None, description="Assets Equity (Billions of EUR)"
|
||||
)
|
||||
assets_debt_instruments: Optional[float] = Field(
|
||||
default=None, description="Assets Debt Instruments (Billions of EUR)"
|
||||
)
|
||||
assets_mfi: Optional[float] = Field(
|
||||
default=None, description="Assets MFIs (Billions of EUR)"
|
||||
)
|
||||
assets_non_mfi: Optional[float] = Field(
|
||||
default=None, description="Assets Non MFIs (Billions of EUR)"
|
||||
)
|
||||
assets_direct_investment_abroad: Optional[float] = Field(
|
||||
default=None, description="Assets Direct Investment Abroad (Billions of EUR)"
|
||||
)
|
||||
liabilities_total: Optional[float] = Field(
|
||||
default=None, description="Liabilities Total (Billions of EUR)"
|
||||
)
|
||||
liabilities_equity: Optional[float] = Field(
|
||||
default=None, description="Liabilities Equity (Billions of EUR)"
|
||||
)
|
||||
liabilities_debt_instruments: Optional[float] = Field(
|
||||
default=None, description="Liabilities Debt Instruments (Billions of EUR)"
|
||||
)
|
||||
liabilities_mfi: Optional[float] = Field(
|
||||
default=None, description="Liabilities MFIs (Billions of EUR)"
|
||||
)
|
||||
liabilities_non_mfi: Optional[float] = Field(
|
||||
default=None, description="Liabilities Non MFIs (Billions of EUR)"
|
||||
)
|
||||
liabilities_direct_investment_euro_area: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Liabilities Direct Investment in Euro Area (Billions of EUR)",
|
||||
)
|
||||
|
||||
|
||||
class ECBPortfolioInvestment(Data):
|
||||
"""ECB Portfolio Investment Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
assets_total: Optional[float] = Field(
|
||||
default=None, description="Assets Total (Billions of EUR)"
|
||||
)
|
||||
assets_equity_and_fund_shares: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Assets Equity and Investment Fund Shares (Billions of EUR)",
|
||||
)
|
||||
assets_equity_shares: Optional[float] = Field(
|
||||
default=None, description="Assets Equity Shares (Billions of EUR)"
|
||||
)
|
||||
assets_investment_fund_shares: Optional[float] = Field(
|
||||
default=None, description="Assets Investment Fund Shares (Billions of EUR)"
|
||||
)
|
||||
assets_debt_short_term: Optional[float] = Field(
|
||||
default=None, description="Assets Debt Short Term (Billions of EUR)"
|
||||
)
|
||||
assets_debt_long_term: Optional[float] = Field(
|
||||
default=None, description="Assets Debt Long Term (Billions of EUR)"
|
||||
)
|
||||
assets_resident_sector_eurosystem: Optional[float] = Field(
|
||||
default=None, description="Assets Resident Sector Eurosystem (Billions of EUR)"
|
||||
)
|
||||
assets_resident_sector_mfi_ex_eurosystem: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Assets Resident Sector MFIs outside Eurosystem (Billions of EUR)",
|
||||
)
|
||||
assets_resident_sector_government: Optional[float] = Field(
|
||||
default=None, description="Assets Resident Sector Government (Billions of EUR)"
|
||||
)
|
||||
assets_resident_sector_other: Optional[float] = Field(
|
||||
default=None, description="Assets Resident Sector Other (Billions of EUR)"
|
||||
)
|
||||
liabilities_total: Optional[float] = Field(
|
||||
default=None, description="Liabilities Total (Billions of EUR)"
|
||||
)
|
||||
liabilities_equity_and_fund_shares: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Liabilities Equity and Investment Fund Shares (Billions of EUR)",
|
||||
)
|
||||
liabilities_equity: Optional[float] = Field(
|
||||
default=None, description="Liabilities Equity (Billions of EUR)"
|
||||
)
|
||||
liabilities_investment_fund_shares: Optional[float] = Field(
|
||||
default=None, description="Liabilities Investment Fund Shares (Billions of EUR)"
|
||||
)
|
||||
liabilities_debt_short_term: Optional[float] = Field(
|
||||
default=None, description="Liabilities Debt Short Term (Billions of EUR)"
|
||||
)
|
||||
liabilities_debt_long_term: Optional[float] = Field(
|
||||
default=None, description="Liabilities Debt Long Term (Billions of EUR)"
|
||||
)
|
||||
liabilities_resident_sector_government: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Liabilities Resident Sector Government (Billions of EUR)",
|
||||
)
|
||||
liabilities_resident_sector_other: Optional[float] = Field(
|
||||
default=None, description="Liabilities Resident Sector Other (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBOtherInvestment(Data):
|
||||
"""ECB Other Investment Balance of Payments Items."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
assets_total: Optional[float] = Field(
|
||||
default=None, description="Assets Total (Billions of EUR)"
|
||||
)
|
||||
assets_currency_and_deposits: Optional[float] = Field(
|
||||
default=None, description="Assets Currency and Deposits (Billions of EUR)"
|
||||
)
|
||||
assets_loans: Optional[float] = Field(
|
||||
default=None, description="Assets Loans (Billions of EUR)"
|
||||
)
|
||||
assets_trade_credit_and_advances: Optional[float] = Field(
|
||||
default=None, description="Assets Trade Credits and Advances (Billions of EUR)"
|
||||
)
|
||||
assets_eurosystem: Optional[float] = Field(
|
||||
default=None, description="Assets Eurosystem (Billions of EUR)"
|
||||
)
|
||||
assets_other_mfi_ex_eurosystem: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Assets Other MFIs outside Eurosystem (Billions of EUR)",
|
||||
)
|
||||
assets_government: Optional[float] = Field(
|
||||
default=None, description="Assets Government (Billions of EUR)"
|
||||
)
|
||||
assets_other_sectors: Optional[float] = Field(
|
||||
default=None, description="Assets Other Sectors (Billions of EUR)"
|
||||
)
|
||||
liabilities_total: Optional[float] = Field(
|
||||
default=None, description="Liabilities Total (Billions of EUR)"
|
||||
)
|
||||
liabilities_currency_and_deposits: Optional[float] = Field(
|
||||
default=None, description="Liabilities Currency and Deposits (Billions of EUR)"
|
||||
)
|
||||
liabilities_loans: Optional[float] = Field(
|
||||
default=None, description="Liabilities Loans (Billions of EUR)"
|
||||
)
|
||||
liabilities_trade_credit_and_advances: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Liabilities Trade Credits and Advances (Billions of EUR)",
|
||||
)
|
||||
liabilities_eurosystem: Optional[float] = Field(
|
||||
default=None, description="Liabilities Eurosystem (Billions of EUR)"
|
||||
)
|
||||
liabilities_other_mfi_ex_eurosystem: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Liabilities Other MFIs outside Eurosystem (Billions of EUR)",
|
||||
)
|
||||
liabilities_government: Optional[float] = Field(
|
||||
default=None, description="Liabilities Government (Billions of EUR)"
|
||||
)
|
||||
liabilities_other_sectors: Optional[float] = Field(
|
||||
default=None, description="Liabilities Other Sectors (Billions of EUR)"
|
||||
)
|
||||
|
||||
|
||||
class ECBCountry(Data):
|
||||
"""ECB Balance of Payments Items by Country."""
|
||||
|
||||
period: dateType = Field(
|
||||
default=None,
|
||||
description="The date representing the beginning of the reporting period.",
|
||||
)
|
||||
current_account_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Current Account Balance (Billions of EUR)",
|
||||
)
|
||||
current_account_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Current Account Credits (Billions of EUR)",
|
||||
)
|
||||
current_account_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Current Account Debits (Billions of EUR)",
|
||||
)
|
||||
goods_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Goods Balance (Billions of EUR)",
|
||||
)
|
||||
goods_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Goods Credits (Billions of EUR)",
|
||||
)
|
||||
goods_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Goods Debits (Billions of EUR)",
|
||||
)
|
||||
services_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Services Balance (Billions of EUR)",
|
||||
)
|
||||
services_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Services Credits (Billions of EUR)",
|
||||
)
|
||||
services_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Services Debits (Billions of EUR)",
|
||||
)
|
||||
primary_income_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Primary Income Balance (Billions of EUR)",
|
||||
)
|
||||
primary_income_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Primary Income Credits (Billions of EUR)",
|
||||
)
|
||||
primary_income_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Primary Income Debits (Billions of EUR)",
|
||||
)
|
||||
investment_income_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Investment Income Balance (Billions of EUR)",
|
||||
)
|
||||
investment_income_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Investment Income Credits (Billions of EUR)",
|
||||
)
|
||||
investment_income_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Investment Income Debits (Billions of EUR)",
|
||||
)
|
||||
secondary_income_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Secondary Income Balance (Billions of EUR)",
|
||||
)
|
||||
secondary_income_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Secondary Income Credits (Billions of EUR)",
|
||||
)
|
||||
secondary_income_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Secondary Income Debits (Billions of EUR)",
|
||||
)
|
||||
capital_account_balance: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Capital Account Balance (Billions of EUR)",
|
||||
)
|
||||
capital_account_credit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Capital Account Credits (Billions of EUR)",
|
||||
)
|
||||
capital_account_debit: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Capital Account Debits (Billions of EUR)",
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
"""ECB provider module."""
|
||||
|
||||
from openbb_ecb.models.balance_of_payments import ECBBalanceOfPaymentsFetcher
|
||||
from openbb_ecb.models.currency_reference_rates import ECBCurrencyReferenceRatesFetcher
|
||||
from openbb_ecb.models.eu_yield_curve import ECBEUYieldCurveFetcher
|
||||
from openbb_provider.abstract.provider import Provider
|
||||
@@ -11,6 +12,7 @@ ecb_provider = Provider(
|
||||
The portal also provides options to download data and comprehensive metadata for each dataset.
|
||||
Statistical publications and dashboards offer a compilation of key data on selected topics.""",
|
||||
fetcher_dict={
|
||||
"BalanceOfPayments": ECBBalanceOfPaymentsFetcher,
|
||||
"CurrencyReferenceRates": ECBCurrencyReferenceRatesFetcher,
|
||||
"EUYieldCurve": ECBEUYieldCurveFetcher,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
"""ECB Balance of Payments Models."""
|
||||
|
||||
import concurrent.futures
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
import pandas as pd
|
||||
from openbb_ecb.utils.bps_series import (
|
||||
BPS_COUNTRIES,
|
||||
BPS_FREQUENCIES,
|
||||
BPS_REPORT_TYPES,
|
||||
generate_bps_series_ids,
|
||||
)
|
||||
from openbb_ecb.utils.ecb_helpers import get_series_data
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.standard_models.balance_of_payments import (
|
||||
BalanceOfPaymentsQueryParams,
|
||||
ECBCountry,
|
||||
ECBDirectInvestment,
|
||||
ECBInvestmentIncome,
|
||||
ECBMain,
|
||||
ECBOtherInvestment,
|
||||
ECBPortfolioInvestment,
|
||||
ECBServices,
|
||||
ECBSummary,
|
||||
)
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class ECBBalanceOfPaymentsQueryParams(BalanceOfPaymentsQueryParams):
|
||||
"""ECB Balance of Payments Query Params."""
|
||||
|
||||
report_type: BPS_REPORT_TYPES = Field(
|
||||
default="main",
|
||||
description="The report type, the level of detail in the data.",
|
||||
)
|
||||
frequency: BPS_FREQUENCIES = Field(
|
||||
default="monthly",
|
||||
description="The frequency of the data. Monthly is valid only for ['main', 'summary'].",
|
||||
)
|
||||
country: BPS_COUNTRIES = Field(
|
||||
default=None,
|
||||
description="The country/region of the data. This parameter will override the 'report_type' parameter.",
|
||||
)
|
||||
|
||||
|
||||
class ECBBalanceOfPaymentsData(
|
||||
ECBMain,
|
||||
ECBSummary,
|
||||
ECBServices,
|
||||
ECBInvestmentIncome,
|
||||
ECBDirectInvestment,
|
||||
ECBPortfolioInvestment,
|
||||
ECBOtherInvestment,
|
||||
ECBCountry,
|
||||
):
|
||||
"""ECB Balance of Payments Data."""
|
||||
|
||||
|
||||
class ECBBalanceOfPaymentsFetcher(
|
||||
Fetcher[ECBBalanceOfPaymentsQueryParams, List[ECBBalanceOfPaymentsData]]
|
||||
):
|
||||
"""ECB Balance of Payments Fetcher."""
|
||||
|
||||
@staticmethod
|
||||
def transform_query(params: Dict[str, Any]) -> ECBBalanceOfPaymentsQueryParams:
|
||||
"""Transform query."""
|
||||
return ECBBalanceOfPaymentsQueryParams(**params)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(
|
||||
query: ECBBalanceOfPaymentsQueryParams,
|
||||
credentials: Optional[Dict[str, str]],
|
||||
**kwargs: Any,
|
||||
) -> List[Dict]:
|
||||
"""Extract data."""
|
||||
|
||||
results: List[Dict] = []
|
||||
|
||||
_series_ids = generate_bps_series_ids(
|
||||
query.frequency, query.report_type, country=query.country
|
||||
)
|
||||
names = list(_series_ids)
|
||||
series_ids = list(_series_ids.values())
|
||||
data = {}
|
||||
|
||||
def get_one(series_id, name):
|
||||
result = {}
|
||||
temp = get_series_data(series_id)
|
||||
result.update({name: {d["PERIOD"]: d["OBS_VALUE_AS_IS"] for d in temp}})
|
||||
data.update(result)
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
executor.map(get_one, series_ids, names)
|
||||
if data != {}:
|
||||
results = (
|
||||
pd.DataFrame(data)
|
||||
.sort_index()
|
||||
.reset_index()
|
||||
.rename(columns={"index": "period"})
|
||||
.to_dict("records")
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
query: ECBBalanceOfPaymentsQueryParams, data: List[Dict], **kwargs: Any
|
||||
) -> List[ECBBalanceOfPaymentsData]:
|
||||
"""Transform and validate data through the model."""
|
||||
return [ECBBalanceOfPaymentsData.model_validate(d) for d in data]
|
||||
228
openbb_platform/providers/ecb/openbb_ecb/utils/bps_series.py
Normal file
228
openbb_platform/providers/ecb/openbb_ecb/utils/bps_series.py
Normal file
@@ -0,0 +1,228 @@
|
||||
"""Definitions and helpers for the BPS (Balance of Payments) ECB Series."""
|
||||
|
||||
from typing import Any, Literal, Optional
|
||||
|
||||
BPS_FREQUENCIES = Literal["monthly", "quarterly"]
|
||||
BPS_FREQUENCIES_DICT = {"monthly": "M", "quarterly": "Q"}
|
||||
BPS_REPORT_TYPES = Literal[
|
||||
"main",
|
||||
"summary",
|
||||
"services",
|
||||
"investment_income",
|
||||
"direct_investment",
|
||||
"portfolio_investment",
|
||||
"other_investment",
|
||||
]
|
||||
|
||||
BPS_COUNTRIES = Literal[
|
||||
"brazil",
|
||||
"canada",
|
||||
"china",
|
||||
"eu_ex_euro_area",
|
||||
"eu_institutions",
|
||||
"india",
|
||||
"japan",
|
||||
"russia",
|
||||
"switzerland",
|
||||
"united_kingdom",
|
||||
"united_states",
|
||||
"total",
|
||||
None,
|
||||
]
|
||||
|
||||
BPS_COUNTRIES_DICT = {
|
||||
"brazil": "BR",
|
||||
"canada": "CA",
|
||||
"china": "CN",
|
||||
"eu_ex_euro_area": "K11",
|
||||
"eu_institutions": "4A",
|
||||
"india": "IN",
|
||||
"japan": "JP",
|
||||
"russia": "RU",
|
||||
"switzerland": "CH",
|
||||
"united_kingdom": "GB",
|
||||
"united_states": "US",
|
||||
"total": "W1",
|
||||
}
|
||||
|
||||
|
||||
def generate_bps_series_ids(
|
||||
frequency: BPS_FREQUENCIES = "monthly",
|
||||
report_type: BPS_REPORT_TYPES = "main",
|
||||
country: Optional[BPS_COUNTRIES] = None,
|
||||
) -> Any:
|
||||
"""Generate series ids for EU area balance of payments reports."""
|
||||
|
||||
freq = (
|
||||
BPS_FREQUENCIES_DICT[frequency]
|
||||
if report_type in ["main", "summary"] and not country
|
||||
else "Q"
|
||||
)
|
||||
|
||||
if country is not None and country in BPS_COUNTRIES_DICT:
|
||||
country_items = dict(
|
||||
current_account_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
current_account_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
current_account_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.G._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.G._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.G._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
investment_income_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.D4P._T.F._Z.EUR._T._X.N.ALL", # noqa: E501
|
||||
investment_income_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.D4P._T.F._Z.EUR._T._X.N.ALL", # noqa: E501
|
||||
investment_income_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.D4P._T.F._Z.EUR._T._X.N.ALL",
|
||||
secondary_income_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.IN2._Z._Z._Z.EUR._T._X.N.ALL", # noqa: E501
|
||||
secondary_income_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.IN2._Z._Z._Z.EUR._T._X.N.ALL", # noqa: E501
|
||||
secondary_income_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.IN2._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account_balance=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.B.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account_credit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.C.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account_debit=f"BPS.{freq}.N.I9.{BPS_COUNTRIES_DICT[country]}.S1.S1.T.D.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
)
|
||||
return country_items
|
||||
|
||||
if report_type == "main":
|
||||
main_items = dict(
|
||||
current_account=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.G._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
secondary_income=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.IN2._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
net_lending_to_rest_of_world=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.CKA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
financial_account=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.FA._T.F._Z.EUR._T._X.N.ALL",
|
||||
direct_investment=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
portfolio_investment=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
financial_derivatives=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.FA.F.F7.T.EUR._T.T.N.ALL",
|
||||
other_investment=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
reserve_assets=f"BPS.{freq}.N.I9.W1.S121.S1.T.A.FA.R.F._Z.EUR.X1._X.N.ALL",
|
||||
errors_and_ommissions=f"BPS.{freq}.N.I9.W1.S1.S1.T.N.EO._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
)
|
||||
return main_items
|
||||
|
||||
if report_type == "summary":
|
||||
summary_items = dict(
|
||||
current_account_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
current_account_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
current_account_balance=f"BPS.{freq}.N.I9.W1.S1.S1.T.B.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.G._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
goods_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.CA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_employee_compensation_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.IN1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
primary_income_employee_compensation_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D1._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
secondary_income_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.IN2._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
secondary_income_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.IN2._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
capital_account_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.KA._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
)
|
||||
return summary_items
|
||||
|
||||
if report_type == "services":
|
||||
services_items = dict(
|
||||
services_total_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
services_total_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.S._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
transport_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SC._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
transport_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SC._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
travel_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SD._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
travel_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SD._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
financial_services_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SF._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SG._Z._Z._Z.EUR._T._X.N.ALL", # noqa E501
|
||||
financial_services_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SF._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SG._Z._Z._Z.EUR._T._X.N.ALL", # noqa E501
|
||||
communications_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SI._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
communications_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SI._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
other_business_services_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SJ._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
other_business_services_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SJ._Z._Z._Z.EUR._T._X.N.ALL",
|
||||
other_services_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.SA._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SB._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SE._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SH._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SK._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SL._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.C.SN._Z._Z._Z.EUR._T._X.N.ALL", # noqa E501
|
||||
other_services_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.SA._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SB._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SE._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SH._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SK._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SL._Z._Z._Z.EUR._T._X.N.ALL%20OR%20BPS.{freq}.N.I9.W1.S1.S1.T.D.SN._Z._Z._Z.EUR._T._X.N.ALL", # noqa E501
|
||||
)
|
||||
return services_items
|
||||
|
||||
if report_type == "investment_income":
|
||||
investment_income_items = dict(
|
||||
investment_total_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D4P._T.F._Z.EUR._T._X.N.ALL",
|
||||
investment_total_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D4P._T.F._Z.EUR._T._X.N.ALL",
|
||||
equity_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D4S.D.F5._Z.EUR._T._X.N.ALL",
|
||||
equity_reinvested_earnings_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D43S.D.F5._Z.EUR._T._X.N.ALL",
|
||||
equity_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D4S.D.F5._Z.EUR._T._X.N.ALL",
|
||||
equity_reinvested_earnings_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D43S.D.F5._Z.EUR._T._X.N.ALL",
|
||||
debt_insruments_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D4Q.D.FL._Z.EUR._T._X.N.ALL",
|
||||
debt_insruments_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D4Q.D.FL._Z.EUR._T._X.N.ALL",
|
||||
portfolio_investment_equity_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D4S.P.F5._Z.EUR._T._X.N.ALL",
|
||||
portfolio_investment_equity_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D4S.P.F5._Z.EUR._T._X.N.ALL",
|
||||
portfolio_investment_debt_instruments_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D41.P.F3.T.EUR._T._X.N.ALL",
|
||||
portfolio_investment_debt_instruments_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D41.P.F3.T.EUR._T._X.N.ALL",
|
||||
other_investment_credit=f"BPS.{freq}.N.I9.W1.S1.S1.T.C.D4P.O.F._Z.EUR._T._X.N.ALL",
|
||||
other_investment_debit=f"BPS.{freq}.N.I9.W1.S1.S1.T.D.D4P.O.F._Z.EUR._T._X.N.ALL",
|
||||
reserve_assets_credit=f"BPS.{freq}.N.I9.W1.S121.S1.T.C.D4P.R.F._Z.EUR.X1._X.N.ALL",
|
||||
)
|
||||
return investment_income_items
|
||||
|
||||
if report_type == "direct_investment":
|
||||
direct_investment_items = dict(
|
||||
assets_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
assets_equity=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.D.F5._Z.EUR._T._X.N.ALL",
|
||||
assets_debt_instruments=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.D.FL._Z.EUR._T._X.N.ALL",
|
||||
assets_mfi=f"BPS.{freq}.N.I9.W1.S12K.S1.LE.A.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
assets_non_mfi=f"BPS.{freq}.N.I9.W1.S1Q.S1.LE.A.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
assets_direct_investment_abroad=f"BPS.{freq}.N.I9.W1.S1.S1.LE.NO.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_equity=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.D.F5._Z.EUR._T._X.N.ALL",
|
||||
liabilities_debt_instruments=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.D.FL._Z.EUR._T._X.N.ALL",
|
||||
liabilities_mfi=f"BPS.{freq}.N.I9.W1.S12K.S1.LE.L.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_non_mfi=f"BPS.{freq}.N.I9.W1.S1Q.S1.LE.L.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_direct_investment_euro_area=f"BPS.{freq}.N.I9.W1.S1.S1.LE.NI.FA.D.F._Z.EUR._T._X.N.ALL",
|
||||
)
|
||||
return direct_investment_items
|
||||
|
||||
if report_type == "portfolio_investment":
|
||||
portfolio_investment_items = dict(
|
||||
assets_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_equity_and_fund_shares=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F5._Z.EUR._T.M.N.ALL",
|
||||
assets_equity=f"BPS{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F51._Z.EUR._T.M.N.ALL",
|
||||
assets_investment_fund_shares=f"BPS{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F52._Z.EUR._T.M.N.ALL",
|
||||
assets_debt_short_term=f"BPS{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F3.S.EUR._T.M.N.ALL",
|
||||
assets_debt_long_term=f"BPS{freq}.N.I9.W1.S1.S1.LE.A.FA.P.F3.L.EUR._T.M.N.ALL",
|
||||
assets_resident_sector_eurosystem=f"BPS{freq}.N.I9.W1.S121.S1.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_resident_sector_mfi_ex_eurosystem=f"BPS{freq}.N.I9.W1.S12T.S1.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_resident_sector_government=f"BPS{freq}.N.I9.W1.S13.S1.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_resident_sector_other=f"BPS{freq}.N.I9.W1.S1P.S1.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_issuer_sector_mfi=f"BPS{freq}.N.I9.W1.S1.S12K.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_issuer_sector_government=f"BPS{freq}.N.I9.W1.S1.S13.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
assets_issuer_sector_other=f"BPS{freq}.N.I9.W1.S1.S1P.LE.A.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
liabilities_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
liabilities_equity_and_fund_shares=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F5._Z.EUR._T.M.N.ALL",
|
||||
liabilities_equity=f"BPS{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F51._Z.EUR._T.M.N.ALL",
|
||||
liabilities_investment_fund_shares=f"BPS{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F52._Z.EUR._T.M.N.ALL",
|
||||
liabilities_debt_short_term=f"BPS{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F3.S.EUR._T.M.N.ALL",
|
||||
liabilities_debt_long_term=f"BPS{freq}.N.I9.W1.S1.S1.LE.L.FA.P.F3.L.EUR._T.M.N.ALL",
|
||||
liabilities_resident_sector_government=f"BPS{freq}.N.I9.W1.S13.S1.LE.L.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
liabilities_resident_sector_other=f"BPS{freq}.N.I9.W1.S1P.S1.LE.L.FA.P.F._Z.EUR._T.M.N.ALL",
|
||||
)
|
||||
return portfolio_investment_items
|
||||
|
||||
if report_type == "other_investment":
|
||||
other_investment_items = dict(
|
||||
assets_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
assets_currency_and_deposits=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.O.F2.T.EUR._T.N.N.ALL",
|
||||
assets_loans=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.O.F4.T.EUR._T.N.N.ALL",
|
||||
assets_trade_credits_and_advances=f"BPS.{freq}.N.I9.W1.S1.S1.LE.A.FA.O.F81.T.EUR._T._X.N.ALL",
|
||||
assets_eurosystem=f"BPS.{freq}.N.I9.W1.S121.S1.LE.A.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
assets_other_mfi_ex_eurosystem=f"BPS.{freq}.N.I9.W1.S12T.S1.LE.A.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
assets_government=f"BPS.{freq}.N.I9.W1.S13.S1.LE.A.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
assets_other_sectors=f"BPS.{freq}.N.I9.W1.S1P.S1.LE.A.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_total=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_currency_and_deposits=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.O.F2.T.EUR._T.N.N.ALL",
|
||||
liabilities_loans=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.O.F4.T.EUR._T.N.N.ALL",
|
||||
liabilities_trade_credits_and_advances=f"BPS.{freq}.N.I9.W1.S1.S1.LE.L.FA.O.F81.T.EUR._T._X.N.ALL",
|
||||
liabilities_eurosystem=f"BPS.{freq}.N.I9.W1.S121.S1.LE.L.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_other_mfi_ex_eurosystem=f"BPS.{freq}.N.I9.W1.S12T.S1.LE.L.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_government=f"BPS.{freq}.N.I9.W1.S13.S1.LE.L.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
liabilities_other_sectors=f"BPS.{freq}.N.I9.W1.S1P.S1.LE.L.FA.O.F._Z.EUR._T._X.N.ALL",
|
||||
)
|
||||
return other_investment_items
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ import datetime
|
||||
|
||||
import pytest
|
||||
from openbb_core.app.service.user_service import UserService
|
||||
from openbb_ecb.models.balance_of_payments import ECBBalanceOfPaymentsFetcher
|
||||
from openbb_ecb.models.currency_reference_rates import ECBCurrencyReferenceRatesFetcher
|
||||
from openbb_ecb.models.eu_yield_curve import ECBEUYieldCurveFetcher
|
||||
|
||||
@@ -41,3 +42,13 @@ def test_ecb_currency_reference_rates_fetcher(credentials=test_credentials):
|
||||
fetcher = ECBCurrencyReferenceRatesFetcher()
|
||||
result = fetcher.test(params, credentials)
|
||||
assert result is None
|
||||
|
||||
|
||||
@pytest.mark.record_http
|
||||
def test_ecb_balance_of_payments_fetcher(credentials=test_credentials):
|
||||
"""Test ECB Balance Of Payments Fetcher."""
|
||||
params = {"date": datetime.date(2023, 1, 1)}
|
||||
|
||||
fetcher = ECBBalanceOfPaymentsFetcher()
|
||||
result = fetcher.test(params, credentials)
|
||||
assert result is None
|
||||
|
||||
Reference in New Issue
Block a user